diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-01-01 14:36:55 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-01-01 14:36:55 -0800 |
commit | ec4eed4f35910aa27ca353fceea38155806ef188 (patch) | |
tree | 584f2856096548fca66984e84649ee5db2ea7500 /backend.c | |
parent | fd85c8d7a74d44f169db4a51a600295042682ee8 (diff) |
Remove some of the hard coded assumptions about the memory map from the CPU cores
Diffstat (limited to 'backend.c')
-rw-r--r-- | backend.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -51,3 +51,24 @@ void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_fun } } +void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts) +{ + memmap_chunk * memmap = opts->memmap; + address &= opts->address_mask; + for (uint32_t chunk = 0; chunk < opts->memmap_chunks; chunk++) + { + if (address >= memmap[chunk].start && address < memmap[chunk].end) { + if (!(memmap[chunk].flags & MMAP_READ)) { + return NULL; + } + uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX + ? mem_pointers[memmap[chunk].ptr_index] + : memmap[chunk].buffer; + if (!base) { + return NULL; + } + return base + (address & memmap[chunk].mask); + } + } + return NULL; +} |