summaryrefslogtreecommitdiff
path: root/backend.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-12-28 20:39:27 -0800
committerMichael Pavone <pavone@retrodev.com>2016-12-28 20:39:27 -0800
commit67b7c359a5a73f01eeba37af2d5fbae1027b4a7a (patch)
treef2542e2c1a6fc6ae59792e22cbc265e4267d78b6 /backend.c
parent96d5581219aec6c49fadaaf1d30623c0f2eed358 (diff)
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Diffstat (limited to 'backend.c')
-rw-r--r--backend.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/backend.c b/backend.c
index c42a7a0..00a2d03 100644
--- a/backend.c
+++ b/backend.c
@@ -51,6 +51,23 @@ void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_fun
}
}
+memmap_chunk const *find_map_chunk(uint32_t address, cpu_options *opts, uint16_t flags, uint32_t *size_sum)
+{
+ if (size_sum) {
+ *size_sum = 0;
+ }
+ address &= opts->address_mask;
+ for (memmap_chunk const *cur = opts->memmap, *end = opts->memmap + opts->memmap_chunks; cur != end; cur++)
+ {
+ if (address >= cur->start && address < cur->end) {
+ return cur;
+ } else if (size_sum && (cur->flags & flags) == flags) {
+ *size_sum += chunk_size(opts, cur);
+ }
+ }
+ return NULL;
+}
+
void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts)
{
memmap_chunk const * memmap = opts->memmap;