32typedef enum : uint32_t {
105 (void)uc_emu_stop(uc);
134 (void)uc_hook_add(uc,
207 const uint32_t rlar = (uint32_t)value;
301 static uc_hook s_h_mpu_rlar;
302 static uc_hook s_h_mpu_ctrl;
303 (void)uc_hook_add(uc,
310 (void)uc_hook_add(uc,
Shared Unicorn engine access utilities for the board emulator.
static uint32_t reg_get(uc_engine *uc, int reg)
Read a Unicorn 32-bit register by its UC_ARM_REG_* id.
static uint32_t rd32(uc_engine *uc, uint64_t addr)
Read a 32-bit little-endian word from emulated memory.
static void wr32(uc_engine *uc, uint64_t addr, uint32_t v)
Write a 32-bit little-endian word to emulated memory.
Cortex-M exception model constants and interfaces for ra8_emulator.
@ k_scb_cfsr
Config Fault Status (MMFSR low byte).
@ k_scb_mmfar
MemManage Fault Address Register.
@ k_mpu_rbar
MPU_RBAR (BASE[31:5]|SH|AP[2:1]|XN).
@ k_exc_memmanage
MemManage exception / vector index.
@ k_mpu_ctrl
MPU_CTRL (ENABLE in bit 0).
@ k_mpu_rnr
MPU_RNR (region number select).
@ k_mpu_rlar
MPU_RLAR (LIMIT[31:5]|AttrIdx|EN).
uint32_t exc_vector(uc_engine *uc, uint32_t vtor_base, uint32_t exc_num)
Read the handler address for an exception from the vector table.
void exc_enter(uc_engine *uc, uint32_t exc_num, uint32_t handler)
Enter a Cortex-M exception: stack the basic frame and vector in.
static uint32_t s_mpu_ro_hook_n
Installed hook count.
static uc_hook s_mpu_ro_hook[k_mpu_max_regions]
RO-range write hooks.
static RA8_INTERNAL void internal_on_mpu_ctrl_write(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user)
UC_HOOK_MEM_WRITE handler for MPU_CTRL – arm / disarm enforcement.
static mpu_region_t s_mpu_region[k_mpu_max_regions]
Per-region shadow.
bool emu_mpu_fault_pending(void)
Implementation of emu_mpu_fault_pending() – plain flag read.
static RA8_INTERNAL void internal_mpu_remove_ro_hooks(uc_engine *uc)
Remove every installed RO-region write hook.
static bool s_mpu_enabled
CTRL.ENABLE active.
static uint32_t s_mpu_fault_pc
PC of faulting store.
static RA8_INTERNAL void internal_on_mpu_ro_write(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user)
UC_HOOK_MEM_WRITE handler for a write into an enforced RO MPU region.
static RA8_INTERNAL void internal_mpu_install_ro_hooks(uc_engine *uc)
Install a write hook on every enabled, read-only MPU region.
void emu_mpu_clear_fault(void)
Implementation of emu_mpu_clear_fault() – plain flag clear.
void mpu_synth_memmanage(uc_engine *uc, uint32_t vtor_base)
Synthesise a MemManage (#4) fault for a trapped RO-region write.
static RA8_INTERNAL void internal_on_mpu_rlar_write(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user)
UC_HOOK_MEM_WRITE handler for MPU_RLAR – capture one region.
static bool s_mpu_fault
RO write trapped.
mpu_field_t
Armv8-M MPU register field bits ra8_emulator enforces.
@ k_mpu_rlar_en_bit
RLAR.EN region-enable.
@ k_mpu_max_regions
Modelled data regions (DREGION).
@ k_mpu_rnr_mask
8 regions -> 3-bit select.
@ k_mpu_region_low_mask
Low 5 bits of an inclusive limit.
@ k_mpu_ctrl_enable_bit
MPU_CTRL.ENABLE.
@ k_mpu_rbar_ap_ro_bit
RBAR.AP[2]=1 -> read-only.
@ k_mpu_addr_mask
BASE/LIMIT [31:5] (32-byte gran).
@ k_cfsr_mmfsr_mmarvalid
CFSR.MMFSR.MMARVALID.
@ k_cfsr_mmfsr_daccviol
CFSR.MMFSR.DACCVIOL.
void emu_mpu_install(uc_engine *uc)
Implementation of emu_mpu_install() – RLAR capture + CTRL edges.
static uint32_t s_mpu_fault_addr
Address written.
Armv8-M MPU enforcement model for ra8_emulator.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
One captured MPU data region (base/limit + permission/enable).
uint32_t limit
Inclusive region top.
bool ro
AP encodes read-only (no privileged write).
uint32_t base
Inclusive region base (32-byte aligned).