|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Armv8-M MPU enforcement model for ra8_emulator. More...
Go to the source code of this file.
Functions | |
| void | emu_mpu_install (uc_engine *uc) |
| Arm the MPU register watchers (RLAR capture + CTRL edge hooks). | |
| bool | emu_mpu_fault_pending (void) |
| Whether an RO-region write violation is latched. | |
| void | emu_mpu_clear_fault (void) |
| Clear the latched MPU violation. | |
| void | mpu_synth_memmanage (uc_engine *uc, uint32_t vtor_base) |
| Synthesise a MemManage (#4) fault for a trapped RO-region write. | |
Armv8-M MPU enforcement model for ra8_emulator.
The firmware programs the MPU via ra8_mpu (RNR -> RBAR -> RLAR per region, then CTRL). ra8_emulator watches those writes (no banked per-region storage in the flat-RAM PPB, so each region is captured at its RLAR write) and, while CTRL.ENABLE is set, faults a privileged store into any read-only region with a synthesised MemManage – the part Unicorn's core does not model. Inert unless the firmware enables the MPU.
Split out of the ra8_emulator main translation unit; behaviour unchanged.
Definition in file emu_mpu.h.
| void emu_mpu_clear_fault | ( | void | ) |
Clear the latched MPU violation.
The run loop clears the latch right before synthesising the MemManage; the warm-reboot path clears it so a rebooted image starts clean.
Clear the latched MPU violation.
Definition at line 326 of file emu_mpu.c.
References s_mpu_fault.
Referenced by internal_run_inner_take_exception(), and warm_reboot().
| bool emu_mpu_fault_pending | ( | void | ) |
Whether an RO-region write violation is latched.
| false | No MPU violation is pending. |
Whether an ro-region write violation is latched; this step is contained within the emu MPU model and uses bounded caller or module-owned storage.
Whether an RO-region write violation is latched.
Definition at line 320 of file emu_mpu.c.
References s_mpu_fault.
Referenced by internal_run_inner_take_exception().
| void emu_mpu_install | ( | uc_engine * | uc | ) |
Arm the MPU register watchers (RLAR capture + CTRL edge hooks).
uc is initialised with the PPB mapped as RAM. Arm the mpu register watchers (rlar capture + ctrl edge hooks); this step is contained within the emu MPU model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
Arm the MPU register watchers (RLAR capture + CTRL edge hooks).
Definition at line 295 of file emu_mpu.c.
References internal_on_mpu_ctrl_write(), internal_on_mpu_rlar_write(), k_mpu_ctrl, and k_mpu_rlar.
Referenced by internal_main_install_core_seams().
| void mpu_synth_memmanage | ( | uc_engine * | uc, |
| uint32_t | vtor_base ) |
Synthesise a MemManage (#4) fault for a trapped RO-region write.
Called by the run loop after the RO-write hook latched a violation. Latches CFSR.MMFSR.DACCVIOL + MMARVALID and MMFAR (so a fault handler – and the HIL alive probe – see the architectural status), forces PC back to the faulting store so the exception entry stacks that address (a recovering handler skips exactly one store), and vectors into the application's MemManage_Handler. If no handler is installed the violation is dropped (no escalation modelled).
| [in,out] | uc | Unicorn engine. |
| [in] | vtor_base | Fallback vector base if VTOR reads as 0. |
Called by the run loop after internal_on_mpu_ro_write latched a violation. Latches CFSR.MMFSR.DACCVIOL + MMARVALID and MMFAR (so a fault handler – and the HIL alive probe – see the architectural status), forces PC back to the faulting store so exc_enter stacks that address (a recovering handler skips exactly one store), and vectors into the application's MemManage_Handler. If no handler is installed the violation is dropped (no escalation modelled).
| [in,out] | uc | Unicorn engine. |
| [in] | vtor_base | Fallback vector base if VTOR reads as 0. |
Definition at line 281 of file emu_mpu.c.
References exc_enter(), exc_vector(), k_cfsr_mmfsr_daccviol, k_cfsr_mmfsr_mmarvalid, k_exc_memmanage, k_scb_cfsr, k_scb_mmfar, rd32(), s_mpu_fault_addr, s_mpu_fault_pc, and wr32().
Referenced by internal_run_inner_take_exception().