From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31629 invoked by alias); 8 Dec 2003 09:51:33 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31617 invoked from network); 8 Dec 2003 09:51:30 -0000 Received: from unknown (HELO sohm.kpit.com) (203.129.230.82) by sources.redhat.com with SMTP; 8 Dec 2003 09:51:30 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: PATCH : H8300 GDB simulator Date: Mon, 08 Dec 2003 09:51:00 -0000 Message-ID: <69595093233BB547BB70CF5E492B63F20324E1F0@sohm.kpit.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: From: "Anil Paranjape" To: "Michael Snyder" Cc: X-SW-Source: 2003-12/txt/msg00252.txt.bz2 Hi Michael, Please find following source code in C as a testcase for H8 simulator bug, ***************************************************************************= ****** int main() { unsigned char test[10]; unsigned short *pWord; pWord =3D (unsigned short *) &test[1]; memset ( test, 0, sizeof(test)); *pWord =3D 0x1234; printf ("Test[0] =3D 0x%02x\r\n", test[0] ); printf ("Test[1] =3D 0x%02x\r\n", test[1] ); return ( 0 ); } ***************************************************************************= ******* Simulator output before patch, Test[0] =3D 0x00 Test[1] =3D 0x12 Simulator output after patch and same as in case of H/W, Test[0] =3D 0x12 Test[1] =3D 0x34 Regards, Anil -----Original Message----- From: Michael Snyder [mailto:msnyder@redhat.com] Sent: Friday, December 05, 2003 1:08 AM To: Anil Paranjape Cc: gdb-patches@sources.redhat.com Subject: Re: PATCH : H8300 GDB simulator Anil Paranjape wrote: > Hi, >=20 > The CPU can access word data and longword data in memory, but word or lon= gword data must begin at an even address. If an attempt is made to access w= ord or longword data at an odd address, no address error occurs but the lea= st significant bit of the address is regarded as 0, so the access starts at= the preceding address. This is the case in actual H/W. >=20 > Now if an odd address is assigned to any word or long word memory pointer= in H8 simulator and then if data at that address is accessed byte by byte = then simulator was neither showing correct data (which is the case in actua= l H/W) not generating SIGBUS exception (which is the case in SH). >=20 > Patch below fixes this problem and after patch, simulator shows correct v= alue as is the case in actual H/W. This sounds good (though I hope one of the folks with more knowledge of the architecture will verify it). One request -- could you include a testcase for the sim testsuite, such that it will fail before your mods, and pass after? Existing tests (for examples) are at sim/testsuite/sim/h8300. Thanks, Michael > ChangeLog/sim/h8300 >=20 > 2003-12-03 Anil Paranjpe >=20 > * compile.c : In all word and double word memory operations,=20 > address is forced to be always even. >=20 > Patch for /sim/h8300/compile.c >=20 > --- compile.c.orig Fri Oct 17 18:15:56 2003 > +++ compile.c Wed Dec 3 22:04:22 2003 > @@ -1265,20 +1265,19 @@ >=20=20 > #define GET_MEMORY_L(X) \ > ((X) < memory_size \ > - ? ((h8_get_memory (sd, (X)+0) << 24) | (h8_get_memory (sd, (X)+1) << = 16) \ > - | (h8_get_memory (sd, (X)+2) << 8) | (h8_get_memory (sd, (X)+3) << = 0)) \ > - : ((h8_get_eightbit (sd, ((X)+0) & 0xff) << 24) \ > - | (h8_get_eightbit (sd, ((X)+1) & 0xff) << 16) \ > - | (h8_get_eightbit (sd, ((X)+2) & 0xff) << 8) \ > - | (h8_get_eightbit (sd, ((X)+3) & 0xff) << 0))) > + ? ((h8_get_memory (sd, ((X) & 0xfffffffe)+0) << 24) | (h8_get_memory = (sd, ((X) & 0xfffffffe)+1) << 16) \ > + | (h8_get_memory (sd, ((X) & 0xfffffffe)+2) << 8) | (h8_get_memory = (sd, ((X) & 0xfffffffe)+3) << 0)) \ > + : ((h8_get_eightbit (sd, (((X) & 0xfffffffe)+0) & 0xff) << 24) \ > + | (h8_get_eightbit (sd, (((X) & 0xfffffffe)+1) & 0xff) << 16) \ > + | (h8_get_eightbit (sd, (((X) & 0xfffffffe)+2) & 0xff) << 8) \ > + | (h8_get_eightbit (sd, (((X) & 0xfffffffe)+3) & 0xff) << 0))) >=20=20 > #define GET_MEMORY_W(X) \ > ((X) < memory_size \ > - ? ((h8_get_memory (sd, (X)+0) << 8) \ > - | (h8_get_memory (sd, (X)+1) << 0)) \ > - : ((h8_get_eightbit (sd, ((X)+0) & 0xff) << 8) \ > - | (h8_get_eightbit (sd, ((X)+1) & 0xff) << 0))) > - > + ? ((h8_get_memory (sd, ((X) & 0xfffffffe)+0) << 8) \ > + | (h8_get_memory (sd, ((X) & 0xfffffffe)+1) << 0)) \ > + : ((h8_get_eightbit (sd, (((X) & 0xfffffffe)+0) & 0xff) << 8) \ > + | (h8_get_eightbit (sd, (((X) & 0xfffffffe)+1) & 0xff) << 0))) >=20=20 > #define GET_MEMORY_B(X) \ > ((X) < memory_size ? (h8_get_memory (sd, (X))) \ > @@ -1286,16 +1285,16 @@ >=20=20 > #define SET_MEMORY_L(X, Y) \ > { register unsigned char *_p; register int __y =3D (Y); \ > - _p =3D ((X) < memory_size ? h8_get_memory_buf (sd) + (X) : \ > - h8_get_eightbit_buf (sd) + ((X) & 0xff)); \ > + _p =3D ((X) < memory_size ? h8_get_memory_buf (sd) + ((X) & 0xfff= ffffe) : \ > + h8_get_eightbit_buf (sd) + (((X) & 0xffffff= fe) & 0xff)); \ > _p[0] =3D __y >> 24; _p[1] =3D __y >> 16; \ > _p[2] =3D __y >> 8; _p[3] =3D __y >> 0; \ > } >=20=20 > #define SET_MEMORY_W(X, Y) \ > { register unsigned char *_p; register int __y =3D (Y); \ > - _p =3D ((X) < memory_size ? h8_get_memory_buf (sd) + (X) : \ > - h8_get_eightbit_buf (sd) + ((X) & 0xff)); \ > + _p =3D ((X) < memory_size ? h8_get_memory_buf (sd) + ((X) & 0xffff= fffe) : \ > + h8_get_eightbit_buf (sd) + (((X) & 0xffffff= fe) & 0xff)); \ > _p[0] =3D __y >> 8; _p[1] =3D __y; \ > } >=20=20 >=20 > Regards, > Anil Paranjpe >=20 >=20