make writes to readonly pages cause a page fault correctly

This commit is contained in:
hyenasky 2022-10-26 12:08:13 -06:00 committed by Ry
parent 7d383cff3c
commit 072cb452e1
2 changed files with 5 additions and 1 deletions

View File

@ -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); 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 offset = address & 0x00000FFF;
uint32_t physical_address = virtual_page->physical_address | offset; uint32_t physical_address = virtual_page->physical_address | offset;
address_end = physical_address + size; address_end = physical_address + size;

View File

@ -5,7 +5,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <setjmp.h> #include <setjmp.h>
#define FOX32_CPU_HZ 10000000 #define FOX32_CPU_HZ 33000000
#define FOX32_MEMORY_RAM 0x04000000 // 64 MiB #define FOX32_MEMORY_RAM 0x04000000 // 64 MiB
#define FOX32_MEMORY_ROM 0x00080000 // 512 KiB #define FOX32_MEMORY_ROM 0x00080000 // 512 KiB