sim: common: change sim_read & sim_write to use void* buffers

When reading/writing arbitrary data to the system's memory, the unsigned
char pointer type doesn't make that much sense.  Switch it to void so we
align a bit with standard C library read/write functions, and to avoid
having to sprinkle casts everywhere.
This commit is contained in:
Mike Frysinger
2022-10-26 21:53:30 +05:45
parent f2462532e2
commit 5b94c38081
21 changed files with 97 additions and 88 deletions

View File

@@ -1526,25 +1526,26 @@ sim_engine_run (SIM_DESC sd,
}
int
sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
sim_write (SIM_DESC sd, SIM_ADDR addr, const void *buffer, int size)
{
int osize = size;
if (addr >= 0 && addr < SRAM_VADDR)
{
const unsigned char *data = buffer;
while (size > 0 && addr < (MAX_AVR_FLASH << 1))
{
word val = flash[addr >> 1].op;
if (addr & 1)
val = (val & 0xff) | (buffer[0] << 8);
val = (val & 0xff) | (data[0] << 8);
else
val = (val & 0xff00) | buffer[0];
val = (val & 0xff00) | data[0];
flash[addr >> 1].op = val;
flash[addr >> 1].code = OP_unknown;
addr++;
buffer++;
data++;
size--;
}
return osize - size;
@@ -1562,12 +1563,13 @@ sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
}
int
sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
sim_read (SIM_DESC sd, SIM_ADDR addr, void *buffer, int size)
{
int osize = size;
if (addr >= 0 && addr < SRAM_VADDR)
{
unsigned char *data = buffer;
while (size > 0 && addr < (MAX_AVR_FLASH << 1))
{
word val = flash[addr >> 1].op;
@@ -1575,7 +1577,7 @@ sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
if (addr & 1)
val >>= 8;
*buffer++ = val;
*data++ = val;
addr++;
size--;
}