limine_protocol/responses/
smp.rs

1use crate::structures::smpinfo::SMPInfo;
2
3#[repr(C)]
4#[derive(Debug)]
5/// Response to [`SMPRequest`]
6pub struct SMPResponse {
7    /// The response revision number
8    pub revision: u64,
9    /// Flags for the bootloader
10    /// `Bit 0` - X2APIC has been enabled
11    pub flags: u32,
12    /// The boot processor's local APIC ID
13    pub bsp_lapic_id: u32,
14    /// The amount of CPUs available
15    pub cpu_count: u64,
16    /// A pointer to an array of [SMPInfo]
17    pub cpus: *const *const SMPInfo,
18}
19
20impl SMPResponse {
21    /// Get the CPU info slice
22    ///
23    /// # Safety
24    /// The pointer must point to a valid array of [`SMPInfo`]s
25    #[must_use]
26    pub unsafe fn get_cpu_info(&self) -> Option<&[&SMPInfo]> {
27        if self.cpus.is_null() {
28            return None;
29        }
30
31        Some(core::slice::from_raw_parts(
32            self.cpus.cast::<&SMPInfo>(),
33            self.cpu_count.try_into().ok()?,
34        ))
35    }
36}