#include <machine/machine_routines.h>
machine/machine_routines.h
enumcpu_event
@enum cpu_event
@abstract Broadcast events allowing clients to hook CPU state transitions.
@constant CPU_BOOT_REQUESTED Called from processor_start(); may block.
@constant CPU_BOOTED Called from platform code on the newly-booted CPU; may not block.
@constant CPU_ACTIVE Called from scheduler code; may block.
@constant CLUSTER_ACTIVE Called from platform code; may block.
@constant CPU_EXIT_REQUESTED Called from processor_exit(); may block.
@constant CPU_DOWN Called from platform code on the disabled CPU; may not block.
@constant CLUSTER_EXIT_REQUESTED Called from platform code; may block.
@constant CPU_EXITED Called after CPU is stopped; may block.
| CPU_BOOT_REQUESTED | 0 | |
| CPU_BOOTED | 1 | |
| CPU_ACTIVE | 2 | |
| CLUSTER_ACTIVE | 3 | |
| CPU_EXIT_REQUESTED | 4 | |
| CPU_DOWN | 5 | |
| CLUSTER_EXIT_REQUESTED | 6 | |
| CPU_EXITED | 7 | |
| PLATFORM_QUIESCE | 8 | |
| PLATFORM_ACTIVE | 9 | |
| PLATFORM_HALT_RESTART | 10 | |
| PLATFORM_PANIC | 11 | |
| PLATFORM_PANIC_SYNC | 12 | |
| PLATFORM_PRE_SLEEP | 13 | |
| PLATFORM_POST_RESUME | 14 |
typedefcpu_callback_t
typedef bool (*cpu_callback_t)(void *param, enum cpu_event event, unsigned int cpu_or_cluster)
functioncpu_event_register_callback
void cpu_event_register_callback(cpu_callback_t fn, void *param)
@function cpu_event_register_callback
@abstract Register a function to be called on CPU state changes.
@param fn Function to call on state change events.
@param param Optional argument to be passed to the callback (e.g. object pointer).
functioncpu_event_unregister_callback
void cpu_event_unregister_callback(cpu_callback_t fn)
@function cpu_event_unregister_callback
@abstract Unregister a previously-registered callback function.
@param fn Function pointer previously passed to cpu_event_register_callback().
functioncpu_event_debug_log
void cpu_event_debug_log(enum cpu_event event, unsigned int cpu_or_cluster)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Appends a CPU lifecycle event (CPU_BOOT_REQUESTED, CPU_BOOTED, CPU_ACTIVE, CLUSTER_EXIT_REQUESTED, PLATFORM_QUIESCE, ...) with a timebase timestamp to a 128-entry in-kernel ring buffer, on DEVELOPMENT and DEBUG kernels only; production kernels log nothing. The record names either a cpu or a cluster id, as appropriate to the event. dump_cpu_event_log prints the ring.
functiondump_cpu_event_log
void dump_cpu_event_log(int (*printf_func)(const char * fmt, ...))
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Prints the CPU event history recorded by cpu_event_debug_log, oldest first, through the supplied printf-style function (e.g. the panic log printer), along with the count of cluster powerdown cycles. Empty on RELEASE kernels.
functionml_io_read
unsigned long long ml_io_read(uintptr_t iovaddr, int iovsz)
@function ml_io_read()
@brief Perform an MMIO read access
@return The value resulting from the read.
functionml_io_read8
unsigned int ml_io_read8(uintptr_t iovaddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Reads a single byte value from the memory-mapped I/O register at kernel virtual address iovaddr. MMIO accesses are timed: slow reads are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.
functionml_io_read16
unsigned int ml_io_read16(uintptr_t iovaddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Reads a 16-bit value from the memory-mapped I/O register at kernel virtual address iovaddr. MMIO accesses are timed: slow reads are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.
functionml_io_read32
unsigned int ml_io_read32(uintptr_t iovaddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Reads a 32-bit value from the memory-mapped I/O register at kernel virtual address iovaddr. MMIO accesses are timed: slow reads are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.
functionml_io_read64
unsigned long long ml_io_read64(uintptr_t iovaddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Reads a 64-bit value from the memory-mapped I/O register at kernel virtual address iovaddr. MMIO accesses are timed: slow reads are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.
functionml_io_read_cpu_reg
uint64_t ml_io_read_cpu_reg(uintptr_t io_vaddr, int io_sz, int logical_cpu)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Reads an I/O register of io_sz bytes (1, 2, 4, or 8) at kernel virtual address io_vaddr, in the manner of ml_io_read32 and relatives; the logical_cpu argument is currently unused.
functionml_io_write
void ml_io_write(uintptr_t vaddr, uint64_t val, int size)
@function ml_io_write()
@brief Perform an MMIO write access
functionml_io_write8
void ml_io_write8(uintptr_t vaddr, uint8_t val)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Writes the byte val to the memory-mapped I/O register at kernel virtual address vaddr. MMIO accesses are timed: slow writes are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.
functionml_io_write16
void ml_io_write16(uintptr_t vaddr, uint16_t val)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Writes the 16-bit value val to the memory-mapped I/O register at kernel virtual address vaddr. MMIO accesses are timed: slow writes are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.
functionml_io_write32
void ml_io_write32(uintptr_t vaddr, uint32_t val)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Writes the 32-bit value val to the memory-mapped I/O register at kernel virtual address vaddr. MMIO accesses are timed: slow writes are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.
functionml_io_write64
void ml_io_write64(uintptr_t vaddr, uint64_t val)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/machine.c
Writes the 64-bit value val to the memory-mapped I/O register at kernel virtual address vaddr. MMIO accesses are timed: slow writes are recorded by iotrace and DTrace, and can panic the system when MMIO timeout panics are enabled.