Skip to content
UniXNUPublic

About

ARM64 CPU, GIC and timer driver for UniXNU

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

ArmCpu

ARM generic interrupt controller and timer.

starts the CPU, GIC and timer on sheng and on the QEMU virt machine.

armcpu_spi_attach registers an exclusive source. armcpu_spi_share registers a level source whose handlers acknowledge their own peripheral status. Registration is serialized; handlers remain installed for the platform lifetime. IRQ dispatch reads the interrupt's route mask and visits only its handlers. armcpu_spi_mask masks or enables a registered line from primary IRQ context.

Cross-core signals are GIC SGI 0, or with armcpu-spi-ipi=1 software-pended SPIs 1008 to 1015 (one per logical core). A deferred signal goes out at once and a cancel takes nothing back. Idle is the kernel's WFI; no PSCI CPU_SUSPEND state is entered. armcpu-edge=1 calls ml_cpu_init_completed after the last core started, which lets the Edge scheduler build its cluster matrix; armcpu_cpu_init_completed reports it.

The per-core SGI/PPI enable mask contains SGI 0 and architectural timer PPI 27. The periodic interrupt self-probe sends the enabled SGI 0 and consumes its acknowledgement while normal interrupts are masked.

armcpu_stats_row(index, row, size) formats wake and idle statistics for a board log. Row 0 is always present: IPIs sent and taken, deferred and cancel requests, the scheduler state and the firmware's PSCI answers. With diag=1 the driver registers the kernel's idle callback, times every IPI and asks the firmware for PSCI_VERSION and PSCI_FEATURES once; one row per core then gives its idle periods by length (under 100 us, under 1 ms, under 8 ms, longer) and the time in each, what ended them (timer, IPI, device interrupt, no interrupt), the cost of a send, and the delay from a send to the target's handler (under 50 us, under 200 us, under 1 ms, longer) for an awake and for an idle target. The start-up IPI a core sends itself (armcpu-self-ipi=1) is counted as sent and taken but is in neither the send cost nor the delays. After the core rows comes one row per core with its timer interrupts by the delay after their deadline (same ranges), again awake and out of idle. The timer is one per core and one-shot; the delay out of idle is the time the core takes to leave idle.

armcpu-idle-latency-us=N registers every core with that time as its power gate latency (default 0: none). The kernel then spins through a delay shorter than N instead of blocking the thread on a timer, sets an idle core's timer N ahead of the deadline, and keeps a core out of WFI for a deadline closer than N. Row 0 shows the value.

Counter sampling orders ISB before reading CNTVCT_EL0. GIC control, SGI and EOI sequences retain their synchronization barriers. Multi-instruction inline assembly uses newline separators.

The sheng scripts/check-bluetooth-shared.py fixture checks the production registration, dispatch, masking and concurrent registration paths. The source also compiles with the selected iPadOS 27 arm64e kernel command.

Platform sleep

platform-sleep=1 enables suspend when the board kernel supplies arm64_platform_sleep_hook and the firmware supplies the PSCI conduit. Boards register wake sources and prepare, restore and periodic tick callbacks through armcpu_sleep_register and the layouts in ArmCpuSleep.h.

Secondary cores use PSCI CPU_OFF. The boot core waits with only the registered wake sources enabled, acknowledges rejected interrupts and masks a source that repeatedly fires. platform-sleep-wake-after=N uses an absolute virtual-timer deadline. Board ticks share that timer. Resume restores interrupt state and sends each returning core its self-IPI.

GIC register accessors emit a single load or store without address writeback, including at -Os and -O2, for hypervisors that emulate register accesses. tools/check-sleep-host.py checks sleep decisions and deadlines; tools/check-mmio-access.py checks the compiled MMIO accessors.

Build and interface details: documentation. Component sources and dependencies: catalog.

About

ARM64 CPU, GIC and timer driver for UniXNU

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages