diff --git a/hosts/host-sdl/host-sdl.c b/hosts/host-sdl/host-sdl.c index 7052f2d..460d85b 100644 --- a/hosts/host-sdl/host-sdl.c +++ b/hosts/host-sdl/host-sdl.c @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) { return 1; } memset(extram_buf, 0x00, extram_len); - uvm32_extram(vmst, extram_buf, extram_len); + uvm32_extram(vmst, (uint8_t *)extram_buf, extram_len); } SDL_SetMainReady(); diff --git a/hosts/host/host.c b/hosts/host/host.c index 9234f05..4e28a9a 100644 --- a/hosts/host/host.c +++ b/hosts/host/host.c @@ -204,7 +204,7 @@ int main(int argc, char *argv[]) { return 1; } memset(extram_buf, 0x00, extram_len); - uvm32_extram(&vmst, extram_buf, extram_len); + uvm32_extram(&vmst, (uint8_t *)extram_buf, extram_len); } // setup terminal for getch() diff --git a/test/extram/test/tests.c b/test/extram/test/tests.c index d1dce73..60ece42 100644 --- a/test/extram/test/tests.c +++ b/test/extram/test/tests.c @@ -16,7 +16,7 @@ void setUp(void) { uvm32_init(&vmst); uvm32_load(&vmst, rom_bin, rom_bin_len); memset(extram, 0x00, sizeof(extram)); - uvm32_extram(&vmst, extram, sizeof(extram)); + uvm32_extram(&vmst, (uint8_t *)extram, sizeof(extram)); } void tearDown(void) { diff --git a/uvm32/uvm32.c b/uvm32/uvm32.c index 5194ae6..c1ccba0 100644 --- a/uvm32/uvm32.c +++ b/uvm32/uvm32.c @@ -80,7 +80,7 @@ void uvm32_init(uvm32_state_t *vmst) { vmst->_status = UVM32_STATUS_PAUSED; vmst->_extramLen = 0; - vmst->_extram = (uint32_t *)NULL; + vmst->_extram = (uint8_t *)NULL; vmst->_extramDirty = false; vmst->_core.pc = MINIRV32_RAM_IMAGE_OFFSET; @@ -130,7 +130,7 @@ bool get_safeptr_null_terminated(uvm32_state_t *vmst, uint32_t addr, uvm32_slice return false; } } - buf->ptr = (uint8_t *)&vmst->_extram[ptrstart/4]; // extram is uint32_t* + buf->ptr = (uint8_t *)&vmst->_extram[ptrstart]; buf->len = p - ptrstart; return true; } @@ -170,7 +170,7 @@ bool get_safeptr(uvm32_state_t *vmst, uint32_t addr, uint32_t len, uvm32_slice_t buf->len = 0; return false; } - buf->ptr = (uint8_t *)&vmst->_extram[ptrstart/4]; // extram is uint32_t* + buf->ptr = (uint8_t *)&vmst->_extram[ptrstart]; buf->len = len; return true; } @@ -444,7 +444,7 @@ uint32_t _uvm32_extramStore(void *userdata, uint32_t addr, uint32_t val, uint32_ return 0; } -void uvm32_extram(uvm32_state_t *vmst, uint32_t *ram, uint32_t len) { +void uvm32_extram(uvm32_state_t *vmst, uint8_t *ram, uint32_t len) { vmst->_extram = ram; vmst->_extramLen = len; } diff --git a/uvm32/uvm32.h b/uvm32/uvm32.h index 1615588..1027686 100644 --- a/uvm32/uvm32.h +++ b/uvm32/uvm32.h @@ -119,7 +119,7 @@ typedef struct { uint8_t _memory[UVM32_MEMORY_SIZE]; /*! Memory */ uvm32_evt_t _ioevt; /*! Event to be returned on next pause */ uint8_t *_stack_canary; /*! Location of stack canary */ - uint32_t *_extram; /*! External RAM pointer, or NULL */ + uint8_t *_extram; /*! External RAM pointer, or NULL */ uint32_t _extramLen; /*! Length of external RAM */ bool _extramDirty; /*! Flag to indicate VM code has modified extram since last run */ } uvm32_state_t; @@ -168,8 +168,8 @@ uvm32_slice_t uvm32_arg_getbuf(uvm32_state_t *vmst, uvm32_evt_t *evt, uvm32_arg_ uvm32_slice_t uvm32_arg_getbuf_fixed(uvm32_state_t *vmst, uvm32_evt_t *evt, uvm32_arg_t arg, uint32_t len); -/*! Setup a block of memory to act as external RAM, it will be available on in VM code at address `UVM32_EXTRAM_BASE`. The memory is not copied, so the caller must ensure it remains available until `uvm32_extram()` is called to setup a different region or the VM is ended */ -void uvm32_extram(uvm32_state_t *vmst, uint32_t *ram, uint32_t len); +/*! Setup a block of memory to act as external RAM, it will be available on in VM code at address `UVM32_EXTRAM_BASE`. The memory is not copied, so the caller must ensure it remains available until `uvm32_extram()` is called to setup a different region or the VM is ended. */ +void uvm32_extram(uvm32_state_t *vmst, uint8_t *extram, uint32_t len); /*! Check to see if the external RAM is marked as dirty. If the VM code writes to the external RAM, this flag is set. The flag is automatically cleared next time uvm32_run() is called */ bool uvm32_extramDirty(uvm32_state_t *vmst);