std.aarch64
AArch64 instructions a kernel needs: exception vectors, system registers, barriers for –target aarch64-freestanding; most need EL1
pub wfi :: fn()waits for the next interrupt
pub wfe :: fn()waits for an event (sev, an interrupt)
pub sev :: fn()pub isb :: fn()instruction barrier: what follows sees a system register just written
pub dsb :: fn()data barriers over the whole system
pub dmb :: fn()mask_interrupts
Section titled “mask_interrupts”pub mask_interrupts :: fn()masks debug, SError, IRQ and FIQ
unmask_interrupts
Section titled “unmask_interrupts”pub unmask_interrupts :: fn()breakpoint
Section titled “breakpoint”pub breakpoint :: fn()brk #0: a synchronous exception; the handler moves elr past it to go on
current_el
Section titled “current_el”pub current_el :: fn() -> u64the exception level running now: 0 to 3
read_mpidr
Section titled “read_mpidr”pub read_mpidr :: fn() -> u64read_cntpct
Section titled “read_cntpct”pub read_cntpct :: fn() -> u64the generic timer’s count and its frequency in Hz
read_cntfrq
Section titled “read_cntfrq”pub read_cntfrq :: fn() -> u64read_sctlr
Section titled “read_sctlr”pub read_sctlr :: fn() -> u64the translation table base and control registers, for paging
write_sctlr
Section titled “write_sctlr”pub write_sctlr :: fn(v: u64)write_ttbr0
Section titled “write_ttbr0”pub write_ttbr0 :: fn(v: u64)write_tcr
Section titled “write_tcr”pub write_tcr :: fn(v: u64)write_mair
Section titled “write_mair”pub write_mair :: fn(v: u64)ExceptionFrame
Section titled “ExceptionFrame”pub ExceptionFrame :: struct { x: [31]u64, elr: u64, spsr: u64, esr: u64, far: u64,}the registers when the exception came, saved by the vectors; elr is where it goes back to
(a handler may change it and the x registers), esr says why (bits 26-31 the class) and far
is the faulting address of an abort
pub SYNC :: 4u64the second parameter of a handler: which of the 16 vectors (a kind from the current level)
pub IRQ :: 5u64pub FIQ :: 6u64SERROR
Section titled “SERROR”pub SERROR :: 7u64set_exception_handler
Section titled “set_exception_handler”pub set_exception_handler :: fn(handler: extern fn(*ExceptionFrame, u64))every exception at EL1 goes to handler, an ordinary function: it gets the saved registers,
and the exception goes back to frame.elr when it returns
exception_class
Section titled “exception_class”pub exception_class :: fn(esr: u64) -> u64the exception class of an esr: 0x3C a brk, 0x15 an svc, 0x24 and 0x25 data aborts, …