From ec4eed4f35910aa27ca353fceea38155806ef188 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 1 Jan 2015 14:36:55 -0800 Subject: Remove some of the hard coded assumptions about the memory map from the CPU cores --- backend.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'backend.c') diff --git a/backend.c b/backend.c index eaae9d7..86bc4b5 100644 --- a/backend.c +++ b/backend.c @@ -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; +} -- cgit v1.2.3 From 574281b6ea14c8534582f088b1cbf128ba6b1d76 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 1 Jan 2015 17:31:59 -0800 Subject: Fix some issues with 68K instruction retranslation --- backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backend.c') diff --git a/backend.c b/backend.c index 86bc4b5..8f65f25 100644 --- a/backend.c +++ b/backend.c @@ -53,7 +53,7 @@ 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; + memmap_chunk const * memmap = opts->memmap; address &= opts->address_mask; for (uint32_t chunk = 0; chunk < opts->memmap_chunks; chunk++) { -- cgit v1.2.3 From f439d8688758710b74d4909e77ebce6444b8a448 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 14 Jan 2015 09:38:54 -0800 Subject: Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM --- backend.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'backend.c') diff --git a/backend.c b/backend.c index 8f65f25..1f9e718 100644 --- a/backend.c +++ b/backend.c @@ -72,3 +72,28 @@ void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * } return NULL; } + +uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk) +{ + if (chunk->mask == opts->address_mask) { + return chunk->end - chunk->start; + } else { + return chunk->mask + 1; + } +} + +uint32_t ram_size(cpu_options *opts) +{ + uint32_t size = 0; + for (int i = 0; i < opts->memmap_chunks; i++) + { + if ((opts->memmap[i].flags & (MMAP_WRITE | MMAP_CODE)) == (MMAP_WRITE | MMAP_CODE)) { + if (opts->memmap[i].mask == opts->address_mask) { + size += opts->memmap[i].end - opts->memmap[i].start; + } else { + size += opts->memmap[i].mask + 1; + } + } + } + return size; +} -- cgit v1.2.3