Mercurial > repos > blastem
comparison backend.c @ 653:a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 01 Jan 2015 14:36:55 -0800 |
parents | dc9f178085a0 |
children | 98927f1b005b |
comparison
equal
deleted
inserted
replaced
652:f822d9216968 | 653:a18e3923481e |
---|---|
49 cur = cur->next; | 49 cur = cur->next; |
50 } | 50 } |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts) | |
55 { | |
56 memmap_chunk * memmap = opts->memmap; | |
57 address &= opts->address_mask; | |
58 for (uint32_t chunk = 0; chunk < opts->memmap_chunks; chunk++) | |
59 { | |
60 if (address >= memmap[chunk].start && address < memmap[chunk].end) { | |
61 if (!(memmap[chunk].flags & MMAP_READ)) { | |
62 return NULL; | |
63 } | |
64 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX | |
65 ? mem_pointers[memmap[chunk].ptr_index] | |
66 : memmap[chunk].buffer; | |
67 if (!base) { | |
68 return NULL; | |
69 } | |
70 return base + (address & memmap[chunk].mask); | |
71 } | |
72 } | |
73 return NULL; | |
74 } |