From: Mike Frysinger <vapier@gentoo.org>
To: Jiri Gaisler <jiri@gaisler.se>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v3 03/14] sim/erc32: Switched emulated memory to host endian order.
Date: Mon, 02 Mar 2015 01:13:00 -0000 [thread overview]
Message-ID: <20150302011342.GH19363@vapier> (raw)
In-Reply-To: <1425244244-27709-4-git-send-email-jiri@gaisler.se>
[-- Attachment #1: Type: text/plain, Size: 3190 bytes --]
On 01 Mar 2015 22:10, Jiri Gaisler wrote:
> --- a/sim/erc32/erc32.c
> +++ b/sim/erc32/erc32.c
>
> if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
> - fetch_bytes (asi, &ramb[addr & mem_rammask], data, sz);
> + *data = *((uint32 *) & (ramb[addr & mem_rammask & ~3]));
pretty sure this too should be a memcpy. also applies to the other updates to
this func in this patch.
> --- a/sim/erc32/exec.c
> +++ b/sim/erc32/exec.c
>
> +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 = ((data >> ((2 - (address & 2)) * 8)) & 0xffff);
you could merge these two statements if you wanted
> + if (tmp & 0x8000) tmp |= 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 = ((data >> ((3 - (address & 3)) * 8)) & 0xff);
merge if you want
> + if (tmp & 0x80) tmp |= 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 = (uint32 *) data;
use a union ? :)
> while (section_size > 0) {
> - char buffer[1024];
> int count;
> + char buffer[1024];
> + uint32 *wbuffer = (uint32 *) buffer;
use a union
> +#ifdef HOST_LITTLE_ENDIAN
> + for (i = 0; i < (count / 4); i++) wbuffer[i] = ntohl(wbuffer[i]); // endian swap
> +#endif
sim-endian.h already provides a lot of helper funcs that i'm pretty sure you
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 = (int *) buf;
> + int ibuf[8192];
> + int i, len;
> +
> + if (length >= 4)
> + for (i = 0; i < length; i += 4) {
> + ibuf[i] = 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 = (int *) buf;
> + int i, len;
> +
> + len = sis_memory_read(mem, buf, length);
> + if (length >= 4)
> + for (i = 0; i < length; i += 4) {
> + *ibuf = htonl(*ibuf);
> + ibuf++;
> + }
> + return (len);
> +#else
> return (sis_memory_read(mem, buf, length));
> +#endif
and here
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-03-02 1:13 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-01 21:10 [PATCH v3 00/14] Update of the SPARC SIS simulator Jiri Gaisler
2015-03-01 21:10 ` [PATCH v3 06/14] sim/erc32: Fix a few compiler warnings Jiri Gaisler
2015-03-02 1:18 ` Mike Frysinger
2015-03-01 21:10 ` [PATCH v3 03/14] sim/erc32: Switched emulated memory to host endian order Jiri Gaisler
2015-03-02 1:13 ` Mike Frysinger [this message]
2015-03-12 21:25 ` Jiri Gaisler
2015-03-12 23:55 ` Mike Frysinger
[not found] ` <55029ED9.5070009@gaisler.se>
2015-03-14 7:45 ` Mike Frysinger
[not found] ` <5503FDF9.8000109@gaisler.se>
2015-03-14 10:24 ` Mike Frysinger
2015-03-14 20:44 ` Jiri Gaisler
2015-03-17 8:06 ` Mike Frysinger
2015-03-21 20:40 ` Jiri Gaisler
2015-03-01 21:10 ` [PATCH v3 05/14] sim/erc32: Use memory_iread() function for instruction fetching Jiri Gaisler
2015-03-02 1:15 ` Mike Frysinger
[not found] ` <55020795.4080009@gaisler.se>
2015-03-13 0:15 ` Mike Frysinger
2015-03-01 21:10 ` [PATCH v3 02/14] sim/erc32: Removed type mismatch compiler warnings Jiri Gaisler
2015-03-02 1:04 ` Mike Frysinger
2015-03-01 21:11 ` [PATCH v3 09/14] sim/erc32: Move local extern declarations into sis.h Jiri Gaisler
2015-03-01 21:11 ` [PATCH v3 12/14] sim/erc32: Updated documentation Jiri Gaisler
2015-03-01 21:11 ` [PATCH v3 08/14] sim/erc32: Access memory subsystem through struct memsys Jiri Gaisler
2015-03-02 1:20 ` Mike Frysinger
2015-03-01 21:11 ` [PATCH v3 01/14] sim/erc32: Added -v command line switch for verbose output Jiri Gaisler
2015-03-02 0:59 ` Mike Frysinger
2015-03-01 21:11 ` [PATCH v3 07/14] sim/erc32: Use gdb callback for UART I/O when linked with gdb Jiri Gaisler
2015-03-02 1:19 ` Mike Frysinger
2015-03-01 21:11 ` [PATCH v3 10/14] sim/erc32: Add support for LEON3 processor emulation Jiri Gaisler
2015-03-05 17:35 ` Mike Frysinger
2015-03-05 17:49 ` Joel Brobecker
2015-03-05 18:20 ` Mike Frysinger
2015-03-01 21:11 ` [PATCH v3 04/14] sim/erc32: use SIM_AC_OPTION_HOSTENDIAN to probe for host endianess Jiri Gaisler
2015-03-16 5:19 ` Mike Frysinger
2015-03-01 21:11 ` [PATCH v3 14/14] Add watchpoint support to gdb simulator interface Jiri Gaisler
2015-03-01 21:11 ` [PATCH v3 13/14] sim/erc32: Add data watchpoint support Jiri Gaisler
2015-03-01 21:11 ` [PATCH v3 11/14] sim/erc32: Add support for LEON2 processor emulation Jiri Gaisler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150302011342.GH19363@vapier \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
--cc=jiri@gaisler.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox