From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16208 invoked by alias); 2 Mar 2015 01:13:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16196 invoked by uid 89); 2 Mar 2015 01:13:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 02 Mar 2015 01:13:45 +0000 Received: from vapier (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with SMTP id 7CAD434098E; Mon, 2 Mar 2015 01:13:42 +0000 (UTC) Date: Mon, 02 Mar 2015 01:13:00 -0000 From: Mike Frysinger To: Jiri Gaisler Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 03/14] sim/erc32: Switched emulated memory to host endian order. Message-ID: <20150302011342.GH19363@vapier> Mail-Followup-To: Jiri Gaisler , gdb-patches@sourceware.org References: <1425244244-27709-1-git-send-email-jiri@gaisler.se> <1425244244-27709-4-git-send-email-jiri@gaisler.se> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Yia77v5a8fyVHJSl" Content-Disposition: inline In-Reply-To: <1425244244-27709-4-git-send-email-jiri@gaisler.se> X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00030.txt.bz2 --Yia77v5a8fyVHJSl Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3116 On 01 Mar 2015 22:10, Jiri Gaisler wrote: > --- a/sim/erc32/erc32.c > +++ b/sim/erc32/erc32.c > > if ((addr >=3D mem_ramstart) && (addr < (mem_ramstart + mem_ramsz)))= { > - fetch_bytes (asi, &ramb[addr & mem_rammask], data, sz); > + *data =3D *((uint32 *) & (ramb[addr & mem_rammask & ~3])); pretty sure this too should be a memcpy. also applies to the other updates= to=20 this func in this patch. > --- a/sim/erc32/exec.c > +++ b/sim/erc32/exec.c >=20=20 > +static int > +extract_short (uint32 data, uint32 address) > +{ > + return((data >> ((2 - (address & 2)) * 8)) & 0xffff); needs to be a space after the return > +static int > +extract_short_signed (uint32 data, uint32 address) > +{ > + uint32 tmp; > + tmp =3D ((data >> ((2 - (address & 2)) * 8)) & 0xffff); you could merge these two statements if you wanted > + if (tmp & 0x8000) tmp |=3D 0xffff0000; uncuddle this > + return(tmp); drop the paren > +static int > +extract_byte (uint32 data, uint32 address) > +{ > + return((data >> ((3 - (address & 3)) * 8)) & 0xff); space after the return > +static int > +extract_byte_signed (uint32 data, uint32 address) > +{ > + uint32 tmp; > + tmp =3D ((data >> ((3 - (address & 3)) * 8)) & 0xff); merge if you want > + if (tmp & 0x80) tmp |=3D 0xffffff00; uncuddle > + return(tmp); drop paren > --- a/sim/erc32/func.c > +++ b/sim/erc32/func.c > > + if (isprint(p[j^end])) > + putchar(p[j^end]); spaces around that ^ operator > @@ -841,10 +850,11 @@ dis_mem(addr, len, info) > { > uint32 i; > unsigned char data[4]; > + uint32 *wdata =3D (uint32 *) data; use a union ? :) > while (section_size > 0) { > - char buffer[1024]; > int count; > + char buffer[1024]; > + uint32 *wbuffer =3D (uint32 *) buffer; use a union > +#ifdef HOST_LITTLE_ENDIAN > + for (i =3D 0; i < (count / 4); i++) wbuffer[i] =3D ntohl(wbuffer[i= ]); // endian swap > +#endif sim-endian.h already provides a lot of helper funcs that i'm pretty sure yo= u=20 can use here. > @@ -356,7 +360,19 @@ sim_write(sd, mem, buf, length) > const unsigned char *buf; > int length; > { > +#ifdef HOST_LITTLE_ENDIAN > + int *ibufp =3D (int *) buf; > + int ibuf[8192]; > + int i, len; > + > + if (length >=3D 4) > + for (i =3D 0; i < length; i +=3D 4) { > + ibuf[i] =3D ntohl(ibufp[i]); > + } > + return (sis_memory_write(mem, (char *) ibuf, length)); > +#else > return (sis_memory_write(mem, buf, length)); > +#endif same here > @@ -366,7 +382,20 @@ sim_read(sd, mem, buf, length) > unsigned char *buf; > int length; > { > +#ifdef HOST_LITTLE_ENDIAN > + int *ibuf =3D (int *) buf; > + int i, len; > + > + len =3D sis_memory_read(mem, buf, length); > + if (length >=3D 4) > + for (i =3D 0; i < length; i +=3D 4) { > + *ibuf =3D htonl(*ibuf); > + ibuf++; > + } > + return (len); > +#else > return (sis_memory_read(mem, buf, length)); > +#endif and here -mike --Yia77v5a8fyVHJSl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJU87lGAAoJEEFjO5/oN/WBBWMP/2o13xJ2sEIHGM34sMVP17jo j6F6Xf9VPH/ERyBkOMMgRVvJ0iSj/J6K0vGITvhZVfrs+m19axn1RRWAzBEBHlWr Sf5Hpkg438N3qBuzAZhfID0gXvQ6cEhd/N5a+yDO8dRK3d7tRjlA/X7bvOTBkRe/ lVU8nvuQCLkwIzqWxuPhFivVtYNHLNnards64BGRV849ypP2DN0MUP2YMJBaNNCs Dmxze7EviU4LtBn0b6SjHEjgmRjmrmPNfzIISNUd34YDASnYhJTKoCG+rXh6FUwE ac7IU18Jj1QBNsDfhZEuSfRNsUdBaRQw2BpU48FjgouYnvKvcR8SONf9IwYa2ISU 0pI8O8WD+9LsKQ+vRxkD5CmDzJIhEgO+yRQ7WMQtPb+MfKPQV9+WHJUIqR27IBXb PKbUK+kvHuGg34j0L7ya9zJGzOW6krXtpD3xhMGgomHmnd+5u+NkCR1GFBct8BGw 7PVP3AQflSluLFvWEM/jBMjlMTxFMtNxTLYSTRsVpcyz8AkjJ80krvSg6o64Isyy aYL2GX/yc7YrNcflTHhTei1ELHR6+V5ufCZ4QSeuercotYNXBYqMXYAFTxTY7jtH ER7ICWbDISjpF3MsN6piCuwBhrxek00L07o4v4UpxLvSow6Hlj4QmdLXsUdZrnEV RQDcgdbIrA0Ga9xJGTB6 =3cwP -----END PGP SIGNATURE----- --Yia77v5a8fyVHJSl--