44typedef enum : uint64_t {
55typedef enum : uint32_t {
98 uint32_t vector_base = 0U;
100 if (vector_base == 0U) {
103 uint32_t ns_msp = 0U;
104 uint32_t ns_reset = 0U;
105 (void)
emu_mem_read(uc, (uint64_t)vector_base, &ns_msp,
sizeof(ns_msp));
107 (uint64_t)vector_base + (uint64_t)
sizeof(uint32_t),
110 const uint32_t ns_pc = ns_reset & ~1U;
111 (void)uc_reg_write(uc, UC_ARM_REG_SP, &ns_msp);
112 (void)uc_reg_write(uc, UC_ARM_REG_PC, &ns_pc);
113 (void)uc_emu_stop(uc);
162 uint32_t jn_size = 0U;
163 const uint32_t jump_ns =
elf_sym_addr(elf,
"ra8_tz_secure_boot_jump_ns", &jn_size);
176 if (blxns_at == 0U) {
178 "ra8_tz_secure_boot_jump_ns\n");
182 (void)uc_hook_add(uc,
189 (void)
priv_emu_io_errf(
"ra8_emulator: TZ BLXNS seam armed @ 0x%08X\n", blxns_at);
214 const uint32_t cmse_check_addr =
elf_sym_addr(elf,
"cmse_check_address_range",
nullptr);
215 if (cmse_check_addr != 0U) {
217 (void)
emu_mem_write(uc, (uint64_t)cmse_check_addr, &bx_lr,
sizeof(bx_lr));
Emulator text-console surfaces: UART echo, ITM/SWO echo, escapes.
@ k_sau_type_regs
SAU_TYPE.SREGION: M85 implements 8.
@ k_sau_type_addr
SAU_TYPE (SREGION = implemented regs).
@ k_ns_sram2_base
SRAM2 Non-secure alias (bit[28]=1).
ELF32 image services for the board emulator (load / symbols / vectors).
uint32_t elf_sym_addr(const emu_elf_source_t *elf, const char *name, uint32_t *size_out)
Resolve a function symbol's entry address from the ELF .symtab.
Cortex-M exception model constants and interfaces for ra8_emulator.
@ k_thumb_bx_lr
BX LR (stub a function to return).
@ k_thumb_hw_bytes
Bytes per Thumb halfword.
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
Central first-party Unicorn memory access seam.
uc_err emu_mem_read(uc_engine *uc, uint64_t address, void *bytes, size_t count)
Read guest memory through the central access seam.
uc_err emu_mem_write(uc_engine *uc, uint64_t address, const void *bytes, size_t count)
Write guest memory through the central access seam.
static void internal_on_blxns(uc_engine *uc, uint64_t address, uint32_t size, void *user)
UC_HOOK_CODE at the Secure->NS BLXNS – hand-emulate the world switch.
uint32_t emu_tz_ns_vector_base(void)
Implementation of emu_tz_ns_vector_base() – plain state read.
void emu_tz_install(uc_engine *uc, const emu_elf_source_t *elf)
Implementation of emu_tz_install() – SAU seed + BLXNS scan/hook.
static uint32_t s_ns_vector_base
Fallback NS vector-table base for the BLXNS world switch.
void emu_tz_set_ns_vector_base(uint32_t base)
Implementation of emu_tz_set_ns_vector_base() – –ns override.
void emu_tz_patch_cmse(uc_engine *uc, const emu_elf_source_t *elf)
Implementation of emu_tz_patch_cmse() – flat-domain range check.
vtor_ns_addr_t
SCB VTOR_NS alias address (ARMv8-M B3.2.4; Secure-state view).
@ k_scb_vtor_ns_addr
VTOR_NS: NS vector-table base.
static uint32_t internal_emu_tz_find_blxns(uc_engine *uc, uint32_t from, uint32_t size)
Scan a Thumb function image for its first BLXNS instruction.
blxns_op_t
Thumb encoding of the BLXNS instruction (scanned in jump_ns).
@ k_blxns_mask
Mask isolating the BLXNS fixed bits.
@ k_blxns_match
BLXNS fixed-bit pattern (any Rm).
TrustZone Secure/Non-Secure seams for ra8_emulator.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
One independently owned immutable raw-descriptor ELF source.