summaryrefslogtreecommitdiff
path: root/backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend.c')
-rw-r--r--backend.c25
1 files changed, 25 insertions, 0 deletions
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;
+}