#include <arm/machine_routines.h>
arm/machine_routines.h
Interrupt handling
functionml_cpu_signal
void ml_cpu_signal(unsigned int cpu_id)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Sends an immediate fast interprocessor interrupt to the CPU identified by cpu_id (an MPIDR-format physical CPU identifier), by writing the Apple ACC IPI request register. Panics on platforms without ACC Fast IPI support.
functionml_cpu_signal_deferred_adjust_timer
void ml_cpu_signal_deferred_adjust_timer(uint64_t nanosecs)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Sets the countdown period used for deferred interprocessor interrupts. nanosecs is converted to timebase ticks and clamped to a 16-bit tick count; the result is written to the global IPI countdown register shared by all cores, and the effective (clamped) period is recorded for ml_cpu_signal_deferred_get_timer. Panics on platforms without ACC Fast IPI support.
functionml_cpu_signal_deferred_get_timer
uint64_t ml_cpu_signal_deferred_get_timer(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the current deferred-IPI countdown period in nanoseconds, as last set by ml_cpu_signal_deferred_adjust_timer; returns 0 on platforms without ACC Fast IPI support.
functionml_cpu_signal_deferred
void ml_cpu_signal_deferred(unsigned int cpu_id)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Posts a deferred fast interprocessor interrupt to the CPU identified by cpu_id (MPIDR format); delivery occurs after the countdown period configured by ml_cpu_signal_deferred_adjust_timer, unless withdrawn first with ml_cpu_signal_retract. Panics on platforms without ACC Fast IPI support.
functionml_cpu_signal_retract
void ml_cpu_signal_retract(unsigned int cpu_id)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Retracts a deferred fast interprocessor interrupt previously posted to the CPU identified by cpu_id (MPIDR format) with ml_cpu_signal_deferred, before its countdown expires. Panics on platforms without ACC Fast IPI support.
functionml_set_interrupts_enabled_with_debug
boolean_t ml_set_interrupts_enabled_with_debug(boolean_t enable, boolean_t debug)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Enables or disables interrupts (the DAIF IRQ/FIQ mask) on the current CPU and returns the previous enable state. When enabling at preemption level zero, pending urgent ASTs are taken first. The debug argument controls whether interrupt-masked-duration diagnostics (SCHED_HYGIENE_DEBUG kernels) measure the masked interval; ml_set_interrupts_enabled passes TRUE. Panics if debug exceptions are enabled in kernel mode.
functionml_set_interrupts_enabled
boolean_t ml_set_interrupts_enabled(boolean_t enable)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Enables (TRUE) or disables (FALSE) interrupts on the current CPU and returns the previous interrupt-enable state. When enabling at preemption level zero, any pending urgent AST is handled first. Equivalent to ml_set_interrupts_enabled_with_debug with duration measurement enabled.
functionml_early_set_interrupts_enabled
boolean_t ml_early_set_interrupts_enabled(boolean_t enable)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Early-boot alias for ml_set_interrupts_enabled; simply calls it and returns the previous interrupt-enable state.
functionsched_perfcontrol_ml_set_interrupts_without_measurement
boolean_t sched_perfcontrol_ml_set_interrupts_without_measurement(boolean_t enable)
Functions for disabling measurements for AppleCLPC only.
functionsched_perfcontrol_abandon_preemption_disable_measurement
void sched_perfcontrol_abandon_preemption_disable_measurement(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/preemption_disable.c
Abandons the in-progress preemption-disable duration measurement on the current CPU, so the interval is neither reported nor subject to timeout panics (SCHED_HYGIENE_DEBUG kernels). Exported for AppleCLPC only; a no-op on kernels built without SCHED_HYGIENE_DEBUG.
functionml_at_interrupt_context
boolean_t ml_at_interrupt_context(void)
Check if running at interrupt context
functionsiq_init
void siq_init(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/sptm/arm_init_sptm.c (call site)
Called once during arm platform bootstrap, immediately after CPU topology parsing, to initialize the SIQ subsystem. The implementation is not present in published xnu sources.
functionsiq_cpu_init
void siq_cpu_init(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/sptm/arm_init_sptm.c (call site)
Per-CPU counterpart of siq_init; called while a CPU is being initialized on the boot and wake paths. The implementation is not present in published xnu sources.
typedeftime_base_enable_t
Type for the Time Base Enable function
typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable)
macroCacheConfig
#define CacheConfig 0x00000000UL
macroCacheControl
#define CacheControl 0x00000001UL
macroCacheClean
#define CacheClean 0x00000002UL
macroCacheCleanRegion
#define CacheCleanRegion 0x00000003UL
macroCacheCleanFlush
#define CacheCleanFlush 0x00000004UL
macroCacheCleanFlushRegion
#define CacheCleanFlushRegion 0x00000005UL
macroCacheShutdown
#define CacheShutdown 0x00000006UL
macroCacheControlEnable
#define CacheControlEnable 0x00000000UL
macroCacheConfigCCSIDR
#define CacheConfigCCSIDR 0x00000001UL
macroCacheConfigSize
#define CacheConfigSize 0x00000100UL
typedefprocessor_idle_t
Type for the Processor Idle function
typedef void (*processor_idle_t)(cpu_id_t cpu_id, boolean_t enter, uint64_t *new_timeout_ticks)
typedefidle_timer_t
Type for the Idle Timer function
typedef void (*idle_timer_t)(void *refcon, uint64_t *new_timeout_ticks)
typedefplatform_error_handler_t
Type for the Platform specific Error Handler
typedef void (*platform_error_handler_t)(void *refcon, vm_offset_t fault_addr)
typedefex_cb_class_t
typedef enum ex_cb_class_t ex_cb_class_t;
typedefex_cb_action_t
typedef enum ex_cb_action_t ex_cb_action_t;
typedefex_cb_state_t
typedef struct ex_cb_state_t ex_cb_state_t;
typedefex_cb_t
Unused. Left for historical reasons.
typedef ex_cb_action_t (*)(ex_cb_class_t, void *, const ex_cb_state_t *) ex_cb_t;
functionex_cb_register
kern_return_t ex_cb_register(ex_cb_class_t cb_class, ex_cb_t cb, void *refcon)
This function is unimplemented. Its definition is left for historical
reasons.
functionex_cb_invoke
ex_cb_action_t ex_cb_invoke(ex_cb_class_t cb_class, vm_offset_t far)
This function is unimplemented. Its definition is left for historical
reasons.
enumcluster_type_t
| CLUSTER_TYPE_INVALID | -1 | |
| CLUSTER_TYPE_SMP | 0 | |
| CLUSTER_TYPE_E | 1 | |
| CLUSTER_TYPE_P | 2 | |
| CLUSTER_TYPE_M | 3 | |
| MAX_CPU_TYPES | 4 |
typedefcluster_type_t
typedef enum cluster_type_t cluster_type_t;
functionml_get_cpu_count
unsigned int ml_get_cpu_count(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the total number of CPUs described by the machine topology, regardless of their current power state.
functionml_get_cpu_number_type
unsigned int ml_get_cpu_number_type( cluster_type_t cluster_type, bool logical, bool available )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Returns the number of CPUs of the given cluster type (CLUSTER_TYPE_E, CLUSTER_TYPE_P, ...). If available is true, only currently active CPUs are counted; otherwise the topology total is returned. The logical flag has no effect, as no supported ARM system features SMT.
functionml_get_cluster_number_type
unsigned int ml_get_cluster_number_type(cluster_type_t cluster_type)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Returns the number of clusters of the given cluster type present in the machine topology.
functionml_cpu_cache_sharing
unsigned int ml_cpu_cache_sharing( unsigned int level, cluster_type_t cluster_type, bool include_all_cpu_types )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Returns the number of CPUs that share a cache at the given level for the given cluster type. Level 0 denotes main memory and returns the total CPU count; level 1 caches are per-core, returning 1; level 2 returns the number of CPUs in the cluster(s) of the requested type; levels above 2 return 0. include_all_cpu_types is currently unused.
functionml_get_cpu_types
unsigned int ml_get_cpu_types(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Returns a bitmask of the cluster types present in the machine topology, with bit (1 << cluster_type) set for each type.
functionml_get_boot_cpu_number
int ml_get_boot_cpu_number(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the logical cpu id of the boot CPU.
functionml_get_cpu_number
int ml_get_cpu_number(uint32_t phys_id)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the logical cpu number of the CPU whose physical id (MPIDR affinity fields Aff0/Aff1) matches phys_id, or -1 if no such CPU exists in the topology.
functionml_get_cpu_number_local
unsigned int ml_get_cpu_number_local(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the logical cpu number of the calling CPU, identified from the constant bits of MPIDR_EL1.
functionml_get_cluster_number
int ml_get_cluster_number(uint32_t phys_id)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the cluster id of the CPU whose physical (MPIDR) id matches phys_id, or -1 if no such CPU exists in the topology.
functionml_get_max_cpu_number
int ml_get_max_cpu_number(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the largest logical cpu id in the machine topology.
functionml_get_max_cluster_number
int ml_get_max_cluster_number(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the largest cluster id in the machine topology.
functionml_get_first_cpu_id
unsigned int ml_get_first_cpu_id(unsigned int cluster_id)
Return the id of a cluster's first cpu.
functionml_get_die_id
unsigned int ml_get_die_id(unsigned int cluster_id)
Return the die id of a cluster.
functionml_get_die_cluster_id
unsigned int ml_get_die_cluster_id(unsigned int cluster_id)
Return the index of a cluster in its die.
functionml_get_max_die_id
unsigned int ml_get_max_die_id(void)
Return the highest die id of the system.
functionml_get_cluster_number_local
int ml_get_cluster_number_local(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the cluster id of the calling CPU, identified from the constant bits of MPIDR_EL1.
structml_cpu_info
Struct for ml_cpu_get_info
| unsigned long | vector_unit | |
| unsigned long | cache_line_size | |
| unsigned long | l1_icache_size | |
| unsigned long | l1_dcache_size | |
| unsigned long | l2_settings | |
| unsigned long | l2_cache_size | |
| unsigned long | l3_settings | |
| unsigned long | l3_cache_size |
typedefml_cpu_info_t
typedef struct ml_cpu_info ml_cpu_info_t
functionml_get_boot_cluster_type
cluster_type_t ml_get_boot_cluster_type(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the cluster type (e.g. CLUSTER_TYPE_P) of the cluster containing the boot CPU.
functionml_map_cpu_pio
void ml_map_cpu_pio(void)
@function ml_map_cpu_pio
@brief Maps per-CPU and per-cluster PIO registers found in EDT. This needs to be
called after arm_vm_init() so it can't be part of ml_parse_cpu_topology().
structml_processor_info
Struct for ml_processor_register
| cpu_id_t | cpu_id | |
| vm_offset_t | start_paddr | |
| boolean_t | supports_nap | |
| void * | platform_cache_dispatch | |
| time_base_enable_t | time_base_enable | |
| processor_idle_t | processor_idle | |
| idle_tickle_t * | idle_tickle | |
| idle_timer_t | idle_timer | |
| void * | idle_timer_refcon | |
| vm_offset_t | powergate_stub_addr | |
| uint32_t | powergate_stub_length | |
| uint32_t | powergate_latency | |
| platform_error_handler_t | platform_error_handler | |
| uint64_t | regmap_paddr | |
| uint32_t | phys_id | |
| uint32_t | log_id | |
| uint32_t | l2_access_penalty | unused |
| uint32_t | cluster_id | |
| cluster_type_t | cluster_type | |
| uint32_t | l2_cache_id | |
| uint32_t | l2_cache_size | |
| uint32_t | l3_cache_id | |
| uint32_t | l3_cache_size |
typedefml_processor_info_t
typedef struct ml_processor_info ml_processor_info_t
functionml_processor_register
kern_return_t ml_processor_register( ml_processor_info_t *ml_processor_info, processor_t *processor, ipi_handler_t *ipi_handler, perfmon_interrupt_handler_func *pmi_handler )
@function ml_processor_register
@abstract callback from platform kext to register processor
@discussion This function is called by the platform kext when a processor is
being registered. This is called while running on the CPU itself, as part of
its initialization.
@param ml_processor_info provides machine-specific information about the
processor to xnu.
@param processor is set as an out-parameter to an opaque handle that should
be used by the platform kext when referring to this processor in the future.
@param ipi_handler is set as an out-parameter to the function that should be
registered as the IPI handler.
@param pmi_handler is set as an out-parameter to the function that should be
registered as the PMI handler.
@returns KERN_SUCCESS on success and an error code, otherwise.
functionml_lockdown_handler_register
kern_return_t ml_lockdown_handler_register(lockdown_handler_t, void *)
Register a lockdown handler
typedefmcache_flush_function
Register a M$ flushing
typedef kern_return_t (*mcache_flush_function)(void *service)
functionml_mcache_flush_callback_register
kern_return_t ml_mcache_flush_callback_register(mcache_flush_function func, void *service)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Registers the callback used by ml_mcache_flush to flush the memory cache; service is an opaque argument passed back to func on each flush. Returns KERN_SUCCESS.
functionml_mcache_flush
kern_return_t ml_mcache_flush(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Invokes the memory-cache flush callback registered by ml_mcache_flush_callback_register and returns its result; panics if no callback has been registered.
functionml_static_vtop
vm_offset_t ml_static_vtop(vm_offset_t)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/arm_vm_init.c, osfmk/arm64/sptm/arm_init_sptm.c
Translates a statically mapped kernel virtual address (kernelcache or physical aperture) to its physical address, consulting the boot-time physical-to-virtual mapping table. Panics if the address is not covered by a static mapping.
functionml_static_verify_page_protections
kern_return_t ml_static_verify_page_protections( uint64_t base, uint64_t size, vm_prot_t prot )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/machine_routines.c
Verifies that every page of the static kernel range [base, base+size) is mapped with at least the protections prot; returns KERN_SUCCESS if so, KERN_FAILURE if any page is unmapped or mapped with weaker protections. base must be page aligned and size a multiple of PAGE_SIZE. The arm implementation is not present in published sources; the contract is verified against the i386 version.
functionml_static_ptovirt
vm_offset_t ml_static_ptovirt(vm_offset_t)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Translates a physical address of managed memory to its virtual address in the kernel's physical aperture (phystokv).
functionml_get_abstime_offset
uint64_t ml_get_abstime_offset(void)
Offset required to obtain absolute time value from tick counter
functionml_get_conttime_offset
uint64_t ml_get_conttime_offset(void)
Offset required to obtain continuous time value from tick counter
functionml_probe_read
boolean_t ml_probe_read(vm_offset_t paddr, unsigned int *val)
PCI config cycle probing
functionml_probe_read_64
boolean_t ml_probe_read_64(addr64_t paddr, unsigned int *val)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Unimplemented on arm; panics if called. Nominally probes the given 64-bit physical address for a readable 32-bit value in the manner of a PCI config cycle probe, storing the value through val.
functionml_phys_read_byte
unsigned int ml_phys_read_byte(vm_offset_t paddr)
Read physical address byte
functionml_phys_read_byte_64
unsigned int ml_phys_read_byte_64(addr64_t paddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Reads one byte from the given 64-bit physical address and returns it zero-extended. The page is accessed through the kernel physical aperture, or through a per-CPU copy window when its memory attributes are not the default cacheable type.
functionml_phys_read_half
unsigned int ml_phys_read_half(vm_offset_t paddr)
Read physical address half word
functionml_phys_read_half_64
unsigned int ml_phys_read_half_64(addr64_t paddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Reads a 16-bit halfword from the given 64-bit physical address and returns it zero-extended, mapping the page through the physical aperture or a per-CPU copy window as needed.
functionml_phys_read_64
unsigned int ml_phys_read_64(addr64_t paddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Reads a 32-bit word from the given 64-bit physical address. Despite the name, the access is 4 bytes wide; the 64 refers to the address width. Use ml_phys_read_double_64 for a 64-bit data read.
functionml_phys_read_word
unsigned int ml_phys_read_word(vm_offset_t paddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Reads a 32-bit word from the given physical address and returns it, mapping the page through the physical aperture or a per-CPU copy window as needed.
functionml_phys_read_word_64
unsigned int ml_phys_read_word_64(addr64_t paddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Reads a 32-bit word from the given 64-bit physical address; identical to ml_phys_read_64.
functionml_phys_read_double
unsigned long long ml_phys_read_double(vm_offset_t paddr)
Read physical address double word
functionml_phys_read_double_64
unsigned long long ml_phys_read_double_64(addr64_t paddr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Reads a 64-bit doubleword from the given 64-bit physical address and returns it, mapping the page through the physical aperture or a per-CPU copy window as needed.
functionml_phys_write_byte
void ml_phys_write_byte(vm_offset_t paddr, unsigned int data)
Write physical address byte
functionml_phys_write_byte_64
void ml_phys_write_byte_64(addr64_t paddr, unsigned int data)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Writes the low byte of data to the given 64-bit physical address, mapping the page through the physical aperture or a per-CPU copy window as needed.
functionml_phys_write_half
void ml_phys_write_half(vm_offset_t paddr, unsigned int data)
Write physical address half word
functionml_phys_write_half_64
void ml_phys_write_half_64(addr64_t paddr, unsigned int data)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Writes the low 16 bits of data to the given 64-bit physical address, mapping the page through the physical aperture or a per-CPU copy window as needed.
functionml_phys_write
void ml_phys_write(vm_offset_t paddr, unsigned int data)
Write physical address word
functionml_phys_write_64
void ml_phys_write_64(addr64_t paddr, unsigned int data)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Writes a 32-bit word to the given 64-bit physical address. Despite the name, the access is 4 bytes wide; the 64 refers to the address width. Use ml_phys_write_double_64 for a 64-bit data write.
functionml_phys_write_word
void ml_phys_write_word(vm_offset_t paddr, unsigned int data)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Writes a 32-bit word to the given physical address, mapping the page through the physical aperture or a per-CPU copy window as needed.
functionml_phys_write_word_64
void ml_phys_write_word_64(addr64_t paddr, unsigned int data)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Writes a 32-bit word to the given 64-bit physical address; identical to ml_phys_write_64.
functionml_phys_write_double
void ml_phys_write_double(vm_offset_t paddr, unsigned long long data)
Write physical address double word
functionml_phys_write_double_64
void ml_phys_write_double_64(addr64_t paddr, unsigned long long data)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Writes a 64-bit doubleword to the given 64-bit physical address, mapping the page through the physical aperture or a per-CPU copy window as needed.
macroBUILD_QUAD_WORD_FUNCS
Not all dependent projects consuming `machine_routines.h` are built using
toolchains that support 128-bit integers.
#define BUILD_QUAD_WORD_FUNCS 0
functionml_static_mfree
void ml_static_mfree(vm_offset_t, vm_size_t)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Releases a page-aligned range of boot-time static kernel memory to the VM free page list, e.g. unused kernelcache segments. Each page is disconnected from all mappings and made readable/writable via ml_static_protect before being handed to the VM; wire counts and kernelcache page counts are adjusted. Addresses below the physical aperture base are silently ignored; failure to update page protections panics.
functionml_static_protect
kern_return_t ml_static_protect(vm_offset_t start, vm_size_t size, vm_prot_t new_prot)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Sets the protection of a page-aligned range of statically (boot-time) mapped kernel memory by rewriting its page table entries. Requests combining VM_PROT_WRITE with VM_PROT_EXECUTE panic (W^X), as do attempts to add execute permission after lockdown. Returns KERN_SUCCESS on success or KERN_FAILURE for addresses outside the physmap. On SPTM systems, frames are instead retyped to XNU_DEFAULT.
functionml_cpu_get_info_type
void ml_cpu_get_info_type(ml_cpu_info_t * ml_cpu_info, cluster_type_t cluster_type)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Fills the ml_cpu_info_t with cache parameters for CPUs of the given cluster type: cache line size, L1 instruction and data cache sizes, and L2 cache size. vector_unit is reported as 0 and no L3 cache is reported. ml_cpu_get_info is the variant that reports the boot cluster.
typedefml_page_protection_t
typedef int ml_page_protection_t
functionml_page_protection_type
ml_page_protection_t ml_page_protection_type(void)
Return the type of page protection supported
functionbzero_phys
void bzero_phys(addr64_t phys_address, vm_size_t length)
Zero bytes starting at a physical address
functionbzero_phys_nc
void bzero_phys_nc(addr64_t src64, vm_size_t bytes)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Zero-fills bytes of physical memory starting at src64. On arm64 this is identical to bzero_phys; the non-cached distinction is historical.
functionbzero_phys_with_options
void bzero_phys_with_options(addr64_t src, vm_size_t bytes, int options)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Zero-fills bytes of physical memory starting at src. The options argument is currently ignored on arm64, making the call equivalent to bzero_phys. Pages with non-default memory attributes are mapped through per-CPU copy windows, and device memory is zeroed without the dc zva fast path.
functionml_thread_policy
void ml_thread_policy(thread_t thread, unsigned policy_id, unsigned policy_info)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Historical machine-dependent thread policy hook (MACHINE_GROUP, MACHINE_NETWORK_WORKLOOP, ...); a no-op on arm.
macroMACHINE_GROUP
#define MACHINE_GROUP 0x00000001
macroMACHINE_NETWORK_GROUP
#define MACHINE_NETWORK_GROUP 0x10000000
macroMACHINE_NETWORK_WORKLOOP
#define MACHINE_NETWORK_WORKLOOP 0x00000001
macroMACHINE_NETWORK_NETISR
#define MACHINE_NETWORK_NETISR 0x00000002
functionml_wait_max_cpus
unsigned int ml_wait_max_cpus(void)
Return the maximum number of CPUs set by ml_set_max_cpus(), waiting if necessary
functionml_cpu_init_completed
extern void ml_cpu_init_completed(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Called once all ml_processor_info_t structures have been initialized and all processors have been started through processor_boot(); notifies the scheduler via sched_cpu_init_completed. Required by the scheduler subsystem.
functionml_cpu_up
extern void ml_cpu_up(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Marks the calling CPU as up by setting its bit in the ml_cpu_up_processors bitmap, which tracks CPUs between ml_cpu_down and ml_cpu_up. Called during machine-dependent CPU bringup; counterpart of ml_cpu_down.
functionml_cpu_down
extern void ml_cpu_down(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Marks the calling CPU as going down: clears its cpu_running flag and its bit in the ml_cpu_up_processors bitmap, migrates its local timer queue to a CPU chosen by ml_find_next_up_processor (poking it with a fire-and-forget SIGPTimerLocal signal), and drains pending IPIs. Runs with interrupts disabled during processor shutdown; the boot CPU powering down for sleep skips timer migration.
functionml_find_next_up_processor
extern int ml_find_next_up_processor(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the cpu number of a processor still marked up: the boot CPU if it is running, otherwise the lowest-numbered CPU in the ml_cpu_up_processors bitmap. Falls back to the boot CPU when no CPU is up, which is legal only while quiescing.
functionml_cpu_up_update_counts
extern void ml_cpu_up_update_counts(int cpu_id)
The update to CPU counts needs to be separate from other actions
in ml_cpu_up() and ml_cpu_down()
because we don't update the counts when CLPC causes temporary
cluster powerdown events, as these must be transparent to the user.
functionml_cpu_down_update_counts
extern void ml_cpu_down_update_counts(int cpu_id)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Decrements the active-CPU count for the cluster type of cpu_id, and the machine_info physical and logical CPU counts. Called from the machine-independent cpu_down(); kept separate from ml_cpu_down so that temporary CLPC cluster powerdown events remain invisible to the user.
functionml_arm_sleep
extern void ml_arm_sleep(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/cpu.c
Enters the platform sleep path on the calling CPU; does not return. The boot CPU first spins until all other CPUs reach the sleep path, records the timebase for use as the wake time (ml_get_wake_timebase), releases the global sleep gate, and arranges warm-boot state (suspend signature or reset vector) before handing off to the platform sleep routine; secondary CPUs clean their caches and power down.
functionml_get_wake_timebase
extern uint64_t ml_get_wake_timebase(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/cpu_common.c
Returns the absolute timebase value recorded by ml_arm_sleep as the system entered its most recent sleep, used as the wake time on resume.
functionml_get_conttime_wake_time
extern uint64_t ml_get_conttime_wake_time(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/machine_routines_common.c
Returns the continuous-time value at which the system last woke. On platforms with a continuous hardware clock this is reconstituted as the wake timebase minus the abstime offset; otherwise it is simply the continuous time offset (ml_get_conttime_offset).
functionml_get_time_since_reset
uint64_t ml_get_time_since_reset(void)
Time since the system was reset (as part of boot/wake)
functionml_set_reset_time
void ml_set_reset_time(uint64_t wake_time)
Called by ApplePMGR to set wake time. Units and epoch are identical
to mach_continuous_time(). Has no effect on !HAS_CONTINUOUS_HWCLOCK
chips. If wake_time == UINT64_MAX, that means the wake time is
unknown and calls to ml_get_time_since_reset() will return UINT64_MAX.
functionarm_debug_read_dscr
extern uint32_t arm_debug_read_dscr(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines_asm.s
Unimplemented on arm64; panics if called. Nominally returns the AArch32 Debug Status and Control Register (DSCR).
functionset_be_bit
extern int set_be_bit(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources
Legacy big-endian tracing-bit interface; declared in machine_routines.h but no arm implementation exists in published xnu sources (the companion clr_be_bit panics if called).
functionclr_be_bit
extern int clr_be_bit(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/loose_ends.c
Panics if called; the big-endian tracing bit is not supported on arm. Legacy interface retained for source compatibility.
functionbe_tracing
extern int be_tracing(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources
Legacy interface nominally reporting whether the big-endian tracing bit is set; declared in machine_routines.h but no arm implementation exists in published xnu sources.
typedefbroadcastFunc
Please note that cpu_broadcast_xcall is not as simple is you would like it to be.
It will sometimes put the calling thread to sleep, and it is up to your callback
to wake it up as needed, where "as needed" is defined as "all other CPUs have
called the broadcast func". Look around the kernel for examples, or instead use
cpu_broadcast_xcall_simple() which does indeed act like you would expect, given
the prototype.
typedef void (*broadcastFunc) (void *)
functioncpu_broadcast_xcall
unsigned int cpu_broadcast_xcall(uint32_t *, boolean_t, broadcastFunc, void *)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/cpu_common.c
Runs func(parm) on every running CPU via cross-call interrupts (SIGPxcall), and directly on the caller when self_xcall is TRUE. synch is a synchronization counter decremented as CPUs complete; the calling thread may be put to sleep, and the callback is responsible for waking it once all CPUs have run the function. Returns the number of CPUs that ran (or were successfully signaled to run) func. cpu_broadcast_xcall_simple provides the straightforward blocking behavior this interface does not.
functioncpu_broadcast_xcall_simple
unsigned int cpu_broadcast_xcall_simple(boolean_t, broadcastFunc, void *)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/cpu_common.c
Runs func(parm) on every running CPU (and on the caller when self_xcall is TRUE), blocking the calling thread until all target CPUs have executed the function; the synchronization counter is managed internally, unlike cpu_broadcast_xcall. Returns the number of CPUs that ran func.
functioncpu_xcall
__result_use_check kern_return_t cpu_xcall(int, broadcastFunc, void *)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/cpu_common.c
Schedules func(param) to run in interrupt context on the CPU designated by cpu_number, using the SIGPxcall cross-call signal; the call is asynchronous. Neither func nor param may be NULL. Returns KERN_SUCCESS if the target CPU was signaled; panics on an invalid or uninitialized cpu number.
functioncpu_immediate_xcall
__result_use_check kern_return_t cpu_immediate_xcall(int, broadcastFunc, void *)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/cpu_common.c
Like cpu_xcall, but sends the cross-call with the immediate IPI class (SIGPxcallImm), which is delivered without deferral. Returns KERN_SUCCESS if the target CPU was signaled; panics on an invalid or uninitialized cpu number.
functionmachine_timeout_suspended
boolean_t machine_timeout_suspended(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns whether machine timeout panics (spinlock, MMIO read/write timeouts) are currently suspended; always FALSE on arm64.
functionml_get_power_state
void ml_get_power_state(boolean_t *, boolean_t *)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the current power context: the first out parameter reports whether the caller is at interrupt context, the second whether all CPUs are idle (the idle count equals the number of CPUs).
functionget_arm_cpu_version
uint32_t get_arm_cpu_version(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the CPU version composed from MIDR_EL1 as an 8-bit value: variant in bits [7:4] and revision in bits [3:0].
functionuser_cont_hwclock_allowed
boolean_t user_cont_hwclock_allowed(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns TRUE if EL0 is allowed to read the virtual timebase (CNTVCT_EL0) as a continuous time source (e.g. for mach_continuous_time), i.e. the platform's hardware clock keeps counting across sleep.
functionuser_timebase_type
uint8_t user_timebase_type(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the type of EL0 timebase access supported:
USER_TIMEBASE_NONE EL0 has no timebase register access
USER_TIMEBASE_SPEC speculative reads of CNTVCT_EL0
USER_TIMEBASE_NOSPEC non-speculative reads (CNTVCTSS_EL0)
USER_TIMEBASE_NOSPEC_APPLE non-speculative reads via Apple's ACNTVCT register
functionml_thread_is64bit
boolean_t ml_thread_is64bit(thread_t thread)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns TRUE if the thread has a 64-bit user address space (thread_is_64bit_addr).
functionml_feature_supported
bool ml_feature_supported(uint64_t feature_bit)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns whether the given implementation-defined feature bit is set in AIDR_EL1, the Apple CPU's auxiliary ID register.
functionml_set_align_checking
void ml_set_align_checking(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources
Enables alignment checking; no implementation is present in current arm64 xnu sources (legacy 32-bit ARM interface).
functionwfe_timeout_configure
extern void wfe_timeout_configure(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Configures, but does not enable, the WFE timeout event stream. Computes the CNTKCTL_EL1.EVENTI bit index of the timebase counter that yields the desired event period, 1 microsecond by default or as given by the wfe_events_sec boot-arg (clamped to 1..USEC_PER_SEC events per second), and stores it for wfe_timeout_init. The event stream bounds the time a CPU can wait in WFE.
functionwfe_timeout_init
extern void wfe_timeout_init(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Enables the timebase event stream at the interval previously computed by wfe_timeout_configure, generating periodic wakeup events that act as a timeout for WFE waits.
functionml_timer_evaluate
void ml_timer_evaluate(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
A no-op on arm; present for symmetry with x86, where it triggers re-evaluation of pending timer deadlines.
functionml_timer_forced_evaluation
boolean_t ml_timer_forced_evaluation(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns FALSE on arm; on x86 it reports whether timer queues are being force-evaluated.
functionml_gpu_stat_update
void ml_gpu_stat_update(uint64_t)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Accounts gpu_ns_delta nanoseconds of GPU time to the resource coalition of the current thread's task (task_coalition_update_gpu_stats).
functionml_gpu_stat
uint64_t ml_gpu_stat(thread_t)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Returns the per-thread GPU time statistic; always 0 on arm64.
variablephy_read_panic
extern uint32_t phy_read_panic
variablephy_write_panic
extern uint32_t phy_write_panic
functionml_hibernate_active_pre
void ml_hibernate_active_pre(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Early resume-from-hibernation hook: if the system is waking from hibernation, rebuilds the VM structures saved in the hibernation image (hibernate_rebuild_vm_structs); otherwise does nothing.
functionml_hibernate_active_post
void ml_hibernate_active_post(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Late resume-from-hibernation hook: if the system is waking from hibernation, runs hibernate_machine_init, releases the hibernation VM lock, and clears the CPU's hibernate flag; otherwise does nothing.
functionml_report_minor_badness
void ml_report_minor_badness(uint32_t badness_id)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm64/machine_routines.c
Records the occurrence of a minor, non-fatal anomaly by atomically setting bit badness_id in a global bitmask on DEVELOPMENT and DEBUG kernels; a no-op on RELEASE kernels.
macroML_MINOR_BADNESS_CONSOLE_BUFFER_FULL
#define ML_MINOR_BADNESS_CONSOLE_BUFFER_FULL 0
macroML_MINOR_BADNESS_MEMFAULT_REPORTING_NOT_ENABLED
#define ML_MINOR_BADNESS_MEMFAULT_REPORTING_NOT_ENABLED 1
macroML_MINOR_BADNESS_PIO_WRITTEN_FROM_USERSPACE
#define ML_MINOR_BADNESS_PIO_WRITTEN_FROM_USERSPACE 2