Skip to main content

raw_acpi/srat/affinity/
memory.rs

1#[derive(Copy, Clone)]
2/// ## Flags - Memory Affinity Structure
3pub struct MemoryAffinityStructureFlags(u32);
4impl MemoryAffinityStructureFlags {
5    /// If clear, the OSPM ignores the contents of the Memory Affinity Structure.
6    /// This allows system firmware to populate the SRAT with a static number of structures but only enable then as necessary.
7    pub const fn enabled(&self) -> bool {
8        self.0 & 0b001 != 0
9    }
10    /// The information conveyed by this bit depends on the value of the Enabled bit.
11    ///
12    /// If the Enabled bit is set and the Hot Pluggable bit is also set.
13    /// The system hardware supports hot-add and hot-remove of this memory region If the Enabled bit is set and the Hot Pluggable bit is clear,
14    /// the system hardware does not support hot-add or hot-remove of this memory region.
15    ///
16    /// If the Enabled bit is clear, the OSPM will ignore the contents of the Memory Affinity Structure
17    pub const fn hot_pluggable(&self) -> bool {
18        self.0 & 0b010 != 0
19    }
20    /// If set, the memory region represents Non-Volatile memory
21    pub const fn non_volatile(&self) -> bool {
22        self.0 & 0b100 != 0
23    }
24    // JJ here, the rest of the bits are reserved; no need to implement.
25}
26
27#[derive(Copy, Clone)]
28#[repr(C, packed)]
29/// ## Memory Affinity Structure
30///
31/// The Memory Affinity structure provides the following topology information statically to the operating system:
32///
33/// - The association between a memory range and the proximity domain to which it belongs
34/// - Information about whether the memory range can be hot-plugged.
35pub struct MemoryAffinity {
36    /// 1 - Memory Affinity Structure
37    pub r#type: u8,
38    /// 40
39    pub length: u8,
40    /// Integer that represents the proximity domain to which the memory range belongs.
41    pub proximity_domain: u32,
42    reserved0: u16,
43    /// Low 32 Bits of the Base Address of the memory range.
44    pub base_address_low: u32,
45    /// High 32 Bits of the Base Address of the memory range.
46    pub base_address_high: u32,
47    /// Low 32 Bits of the length of the memory range.
48    pub length_low: u32,
49    /// High 32 Bits of the length of the memory range.
50    pub length_high: u32,
51    reserved1: u32,
52    /// Flags - Memory Affinity Structure.
53    ///
54    /// Indicates whether the region of memory is enabled and can be hot plugged.
55    pub flags: MemoryAffinityStructureFlags,
56    reserved2: u64,
57}