product-mini/platforms/posix/main.c: Adapt to WASM_MEM_DUAL_BUS_MIRROR (#3427)

This commit is contained in:
YAMAMOTO Takashi 2024-05-14 13:16:19 +09:00 committed by GitHub
parent 0f17a1464e
commit 267eaa1747
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -887,6 +887,7 @@ main(int argc, char *argv[])
#if WASM_ENABLE_AOT != 0 #if WASM_ENABLE_AOT != 0
if (wasm_runtime_is_xip_file(wasm_file_buf, wasm_file_size)) { if (wasm_runtime_is_xip_file(wasm_file_buf, wasm_file_size)) {
uint8 *wasm_file_mapped; uint8 *wasm_file_mapped;
uint8 *daddr;
int map_prot = MMAP_PROT_READ | MMAP_PROT_WRITE | MMAP_PROT_EXEC; int map_prot = MMAP_PROT_READ | MMAP_PROT_WRITE | MMAP_PROT_EXEC;
int map_flags = MMAP_MAP_32BIT; int map_flags = MMAP_MAP_32BIT;
@ -897,8 +898,15 @@ main(int argc, char *argv[])
goto fail1; goto fail1;
} }
bh_memcpy_s(wasm_file_mapped, wasm_file_size, wasm_file_buf, #if (WASM_MEM_DUAL_BUS_MIRROR != 0)
wasm_file_size); daddr = os_get_dbus_mirror(wasm_file_mapped);
#else
daddr = wasm_file_mapped;
#endif
bh_memcpy_s(daddr, wasm_file_size, wasm_file_buf, wasm_file_size);
#if (WASM_MEM_DUAL_BUS_MIRROR != 0)
os_dcache_flush();
#endif
wasm_runtime_free(wasm_file_buf); wasm_runtime_free(wasm_file_buf);
wasm_file_buf = wasm_file_mapped; wasm_file_buf = wasm_file_mapped;
is_xip_file = true; is_xip_file = true;