From e7fa2b5bff816e8ac72170886ff293d99cc951a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Sun, 7 Sep 2014 19:29:11 +0000 Subject: [PATCH] check for supervisor protection fault and issue a bus error --- BaS_gcc/sys/exceptions.S | 8 +++++++- BaS_gcc/sys/mmu.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/BaS_gcc/sys/exceptions.S b/BaS_gcc/sys/exceptions.S index a9f7490..f7df27c 100644 --- a/BaS_gcc/sys/exceptions.S +++ b/BaS_gcc/sys/exceptions.S @@ -380,7 +380,7 @@ reset_vector: jmp _rom_entry // no, cold start machine access: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupts move.l d0,-(sp) // ++ vr move.w 4(sp),d0 // get format_status word from stack @@ -400,6 +400,12 @@ access_mmu: move.l MCF_MMU_MMUSR,d0 // did the last fault hit in TLB? btst #1,d0 // yes, it did. So we already mapped that page bne bus_error // and this must be a real bus error + btst #5,d0 // supervisor protection fault? + bne bus_error + btst #4,d0 // read access fault? + bne bus_error + btst #3,d0 // write access fault? + bne bus_error move.l MCF_MMU_MMUAR,d0 cmp.l #__FASTRAM_END,d0 // above max User RAM area? diff --git a/BaS_gcc/sys/mmu.c b/BaS_gcc/sys/mmu.c index f5acc23..8ef1305 100644 --- a/BaS_gcc/sys/mmu.c +++ b/BaS_gcc/sys/mmu.c @@ -235,6 +235,7 @@ int mmu_map_page(uint32_t virt, uint32_t phys, enum mmu_page_size sz, const stru MCF_MMU_MMUTR_ID(flags->page_id) | /* address space id (ASID) */ MCF_MMU_MMUTR_SG | /* shared global */ MCF_MMU_MMUTR_V; /* valid */ + NOP(); MCF_MMU_MMUDR = ((int) phys & size_mask) | /* physical address */ MCF_MMU_MMUDR_SZ(sz) | /* page size */ @@ -243,9 +244,11 @@ int mmu_map_page(uint32_t virt, uint32_t phys, enum mmu_page_size sz, const stru (flags->access & ACCESS_WRITE ? MCF_MMU_MMUDR_W : 0) | /* write access enable */ (flags->access & ACCESS_EXECUTE ? MCF_MMU_MMUDR_X : 0) | /* execute access enable */ (flags->locked ? MCF_MMU_MMUDR_LK : 0); + NOP(); MCF_MMU_MMUOR = MCF_MMU_MMUOR_ACC | /* access TLB, data */ MCF_MMU_MMUOR_UAA; /* update allocation address field */ + NOP(); MCF_MMU_MMUOR = MCF_MMU_MMUOR_ITLB | /* instruction */ MCF_MMU_MMUOR_ACC | /* access TLB */