Runtime
- Startup (
src/arch/start.S) sp = 0x80010000,fp = 0, zero.bss, callmain().mainmust end infw_done()orfw_fatal().- Exceptions
vectors 1–15 →
__exc_entry: fresh stack, readECR/ERET/EFA, callfw_exception()(src/common/exception.c), which stores them infw_diag(.bss, magic"DIAG"), streamsLOG_ID_EXCEPTIONand ends with0xff. Interrupts 16–126 do the same with bit 31 of the cause set.- MMIO (
src/hal/mmio.h) rd16/wr16/rd8/wr8onvolatilepointers;csr_rd(idx)/csr_wr(idx, v)use0x90000000 | idx << 1.- Timer (
src/hal/timer.c) timer_init()enables the RTC if needed (write 2 then 1 to AUX0x103);timer_now()re-reads the high word until it is stable;timer_delay_ticks(n)usesndummy reads of0x90040048below 16 ticks, else polls the 64-bit counter.timer_delay_us()uses the measuredRTC_TICKS_PER_US = 400(experiment 001).- Terminal states
fw_done(): pulse0x900402381→0, major0x07, halt (flag 1).fw_fatal(): pulse 4→0, publish0xffwithout waiting for ACK, halt. The pulse is sent before the code because the host may stop the PMU as soon as it sees the code [design].