22#include <unicorn/unicorn.h>
35typedef enum : uint64_t {
81typedef enum : uint32_t {
143uint32_t
exc_vector(uc_engine* uc, uint32_t vtor_base, uint32_t exc_num);
168void exc_enter(uc_engine* uc, uint32_t exc_num, uint32_t handler);
189void exc_return(uc_engine* uc, uint32_t exc_ret);
215bool exc_take_pending(uc_engine* uc, uint32_t vtor_base,
bool allow_systick);
bool emu_exc_take_exc_return(uint64_t *out_pc)
Consume a latched EXC_RETURN branch (read + clear).
void emu_exc_arm_systick(void)
Pend the periodic SysTick for this outer chunk.
void emu_exc_clear_pendsv_stop(void)
Clear the PendSV context-switch stop marker (per relaunch).
bool idle_spin_at(uc_engine *uc, uint32_t pc)
True if pc sits in a wait-for-interrupt spin (the core is idle).
@ k_fp_s_words
S0-S15 saved in the FP extended frame.
@ k_xpsr_t_bit
xPSR.T (Thumb) – must stay set.
@ k_exc_ret_spsel
EXC_RETURN bit2: return stack = PSP.
@ k_thumb2_insn_bytes
32-bit Thumb-2 instruction width.
@ k_frame_off_xpsr
Basic exception-frame offset of xPSR.
@ k_exc_frame_words
{R0-R3,R12,LR,PC,xPSR} basic frame.
@ k_control_spsel
CONTROL.SPSEL: thread SP = PSP.
@ k_exc_ret_mode
EXC_RETURN bit3: return to Thread.
@ k_xpsr_ipsr_mask
xPSR[8:0] = IPSR (active exception).
@ k_vscclrm_hw0_s
VSCCLRM {s..,VPR} first halfword.
@ k_fpcxtns_pop
VLDR FPCXTNS,[sp],#4 (LE word).
@ k_lo4_mask
Low nibble (register / cond field).
@ k_frame_off_lr
Basic exception-frame offset of LR.
@ k_exc_ret_ftype
EXC_RETURN bit4: 1 = basic, 0 = FP.
@ k_exc_prio_max
Lowest configurable priority value.
@ k_thumb_bx_lr
BX LR (stub a function to return).
@ k_frame_off_pc
Basic exception-frame offset of PC.
@ k_frame_off_fpscr
FP-frame offset of FPSCR (32 + 16*4).
@ k_exc_frame_bytes
8 words * 4 bytes.
@ k_lo16_mask
Low halfword of a 32-bit fetch.
@ k_exc_ret_handler
Return to Handler mode, MSP.
@ k_exc_ret_psp
Return to Thread mode, PSP.
@ k_thumb_hw_bytes
Bytes per Thumb halfword.
@ k_fpcxtns_push
VSTR FPCXTNS,[sp,#-4]! (LE word).
@ k_exc_ret_v8_mask
Armv8-M EXC_RETURN prefix: bits[31:7].
@ k_nvic_prio_shift
Implemented priority is the 4 MSBs.
@ k_vector_erased
Erased-flash / invalid vector word.
@ k_exc_ret_msp
Return to Thread mode, MSP.
@ k_frame_off_r3
Basic exception-frame offset of R3.
@ k_fp_frame_extra
FP ext frame above basic: S0-15+FPSCR.
@ k_bkpt_hw_base
BKPT #imm8 halfword (imm free).
@ k_vscclrm_hw0_d
VSCCLRM {d..,VPR} first halfword.
@ k_exc_nest_max
Tracked active-exception nesting cap.
@ k_byte_bits
Bits per byte (SHPR field width).
@ k_word_bytes
One stacked word.
@ k_frame_off_s0
FP-frame offset of S0 (above basic).
@ k_control_fpca
CONTROL.FPCA: FP context is active.
@ k_clrm_hw0
CLRM {regs} first halfword.
@ k_armv8m_sg_opcode
Armv8-M SG secure-gateway opcode.
@ k_bkpt_hw_mask
Mask isolating the BKPT opcode.
@ k_xpsr_align9
xPSR bit9: stack-frame realignment.
@ k_exc_prio_none
Sentinel "no handler active" prio.
@ k_scb_cfsr
Config Fault Status (MMFSR low byte).
@ k_scb_ccr
Configuration and Control (CCR).
@ k_nvic_en_span
Byte span of one set/clear array.
@ k_scb_mmfar
MemManage Fault Address Register.
@ k_nvic_en_words
ISER/ICER words modelled (256 lines).
@ k_syst_csr
SysTick control/status (SYST_CSR).
@ k_nvic_ipr_base
NVIC IPR priority bytes (one per IRQ).
@ k_scb_aircr
App interrupt/reset control (AIRCR).
@ k_scb_shpr2
System handler priority 2 (SVC=b3).
@ k_mpu_type_seed
8 data regions (matches the M85 MPU).
@ k_icsr_pendstset
ICSR.PENDSTSET bit (request SysTick).
@ k_aircr_sysresetreq
AIRCR.SYSRESETREQ bit (request reset).
@ k_ccr_div_0_trp
CCR.DIV_0_TRP bit4: divide-by-0 traps.
@ k_scb_vtor
Vector table offset register.
@ k_mpu_rbar
MPU_RBAR (BASE[31:5]|SH|AP[2:1]|XN).
@ k_icsr_pendsvset
ICSR.PENDSVSET bit (request PendSV).
@ k_syst_csr_run
ENABLE | TICKINT both set.
@ k_exc_memmanage
MemManage exception / vector index.
@ k_exc_usagefault
UsageFault exception / vector index.
@ k_scb_shpr3
System handler priority 3 (PSV/SYT).
@ k_mpu_ctrl
MPU_CTRL (ENABLE in bit 0).
@ k_mpu_type
MPU_TYPE (DREGION in bits 15:8).
@ k_exc_svcall
SVCall exception / vector index.
@ k_exc_pendsv
PendSV exception / vector index.
@ k_exc_systick
SysTick exception / vector index.
@ k_scb_icsr
Interrupt control/state (ICSR).
@ k_exc_irq_vec0
Vector index of IRQ0 (16 + IRQn).
@ k_mpu_rnr
MPU_RNR (region number select).
@ k_mpu_rlar
MPU_RLAR (LIMIT[31:5]|AttrIdx|EN).
void dwt_cyccnt_advance(uc_engine *uc)
Advance the DWT cycle counter by one outer chunk's worth of cycles.
bool emu_exc_bkpt_hit(void)
Whether the firmware executed a BKPT (deliberate trap / give-up).
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.
bool emu_exc_pendsv_stop(void)
Whether the last engine stop was a PENDSVSET context-switch stop.
uint32_t emu_exc_pendsv_takes(void)
PendSV exceptions taken this run (report + idle signature).
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.
void emu_exc_clear_reboot_request(void)
Clear the latched warm-reboot request (after performing it).
bool emu_exc_reboot_requested(void)
Whether AIRCR.SYSRESETREQ requested a warm reboot.
void emu_exc_install_scb_nvic(uc_engine *uc)
Arm the SCB control-word and NVIC ISER/ICER write watchers.
uint32_t emu_exc_bkpt_pc(void)
PC of the BKPT that halted the run.
void exc_return(uc_engine *uc, uint32_t exc_ret)
Perform a Cortex-M exception return for an observed EXC_RETURN branch.
void emu_exc_install_core(uc_engine *uc)
Arm the core exception hooks (unmapped / INTR / ICSR watch).
uint32_t emu_exc_svc_takes(void)
SVCall exceptions taken this run (report + idle signature).
bool exc_take_pending(uc_engine *uc, uint32_t vtor_base, bool allow_systick)
Take the highest-priority pending exception, if one may activate now.
void emu_exc_reset(void)
Reset the exception bookkeeping for a warm reboot.
uint32_t emu_exc_systick_fires(void)
SysTick exceptions taken this run (report telemetry).
Annotation-attribute framework macros for ra8-firmware.
@ k_nvic_ispr_base
NVIC Interrupt Set-Pending Register array.
@ k_nvic_icer_base
NVIC Interrupt Clear-Enable Register array.
@ k_nvic_iser_base
NVIC Interrupt Set-Enable Register array.