From 072cb452e1b6742fa92b68897e97b7cd4329e0b3 Mon Sep 17 00:00:00 2001 From: hyenasky Date: Wed, 26 Oct 2022 12:08:13 -0600 Subject: [PATCH] make writes to readonly pages cause a page fault correctly --- src/cpu.c | 4 ++++ src/cpu.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpu.c b/src/cpu.c index c479129..322e847 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -453,6 +453,10 @@ static uint8_t *vm_findmemory(vm_t *vm, uint32_t address, uint32_t size, bool wr vm_panic(vm, FOX32_ERR_FAULT_WR); } } + if (!virtual_page->rw && write) { + vm->exception_operand = address; + vm_panic(vm, FOX32_ERR_FAULT_WR); + } uint32_t offset = address & 0x00000FFF; uint32_t physical_address = virtual_page->physical_address | offset; address_end = physical_address + size; diff --git a/src/cpu.h b/src/cpu.h index c05d4ca..ce9874d 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -5,7 +5,7 @@ #include #include -#define FOX32_CPU_HZ 10000000 +#define FOX32_CPU_HZ 33000000 #define FOX32_MEMORY_RAM 0x04000000 // 64 MiB #define FOX32_MEMORY_ROM 0x00080000 // 512 KiB