Skip to main content

raw_acpi/
rasf.rs

1use crate::{
2    SDTHeader,
3    pcct::subspace::{
4        GenericCommunicationsChannelCommandField, GenericCommunicationsChannelStatusField,
5    },
6};
7
8//#[derive(Copy, Clone)]
9//#[repr(C, packed)]
10//pub struct ParameterBlock {
11//    pub r#type: u16,
12//    pub version: u16,
13//    pub length: u16,
14//    pub patrol_scrub_command: u16,
15//    pub requested_address_range: u128,
16//    pub actual_address_range: u128,
17//    pub flags: u16,
18//    pub requested_speed: u8,
19//}
20
21#[derive(Copy, Clone)]
22/// ## Platform RAS Capabilities Bitmap
23pub struct RASCapabilities(u128);
24impl RASCapabilities {
25    /// Indicates that the platform supports hardware based patrol scrub of DRAM memory
26    pub const fn hardware_based_patrol_scrub_support(&self) -> bool {
27        self.0 & 0b01 != 0
28    }
29    /// Indicates that the platform supports hardware based patrol scrub of DRAM memory and platform exposes this capability to software using this RASF mechanism
30    pub const fn hardware_based_patrol_scrub_support_and_exposed_to_software(&self) -> bool {
31        self.0 & 0b10 != 0
32    }
33    // JJ here, the rest of the values are reserved; no need to implement.
34}
35
36#[derive(Copy, Clone)]
37#[repr(C, packed)]
38/// ## RASF Platform Communication Channel Shared Memory Region
39pub struct RASFCommunicationChannelSMR {
40    /// The PCC Signature of 0x52415346 (corresponds to ASCII signature of RASF)
41    pub signature: u32,
42    /// PCC command field.
43    ///
44    /// See the Platform Communications Channel (PCC).
45    /// 
46    /// Command value 0x01 will execute RASF command.  The rest of the values are reserved.
47    pub command: GenericCommunicationsChannelCommandField,
48    /// PCC status field.
49    ///
50    /// See Platform Communications Channel (PCC).
51    pub status: GenericCommunicationsChannelStatusField,
52    /// - **Byte 0** - Minor Version
53    /// - **Byte 1** - Major Version
54    pub version: u16,
55    /// Bit Map describing the platform RAS capabilities as shown in Platform RAS Capabilities.
56    ///
57    /// The Platform populates this field. The OSPM uses this field to determine the RAS capabilities of the platform.
58    pub ras_capabilites: RASCapabilities,
59    /// Bit Map of the RAS features for which the OSPM is invoking the command.
60    ///
61    /// The Bit Map is described in Section 5.2.20.4. OSPM sets the bit corresponding to a RAS capability to invoke a command on that capability.
62    /// The bitmap implementation allows OSPM to invoke a command on each RAS feature supported by the platform at the same time.
63    pub set_ras_capabilities: RASCapabilities,
64    /// The Number of parameter blocks will depend on how many RAS Capabilities the Platform Supports.
65    ///
66    /// Typically, there will be one Parameter Block per RAS Feature, using which that feature can be managed by OSPM.
67    pub rasf_parameter_block_num: u16,
68    /// - **0b0000** - Success
69    /// - **0b0001** - Not Valid
70    /// - **0b0010** - Not Supported
71    /// - **0b0011** - Busy
72    /// - **0b0100** - FailedF
73    /// - **0b0101** - Aborted
74    /// - **0b0110** - Invalid Data
75    pub set_ras_capabilities_status: u32,
76}
77impl RASFCommunicationChannelSMR {
78    /// Start of the parameter blocks, the structure of which is shown in the Parameter Block Structure for PATROL_SCRUB.
79    /// 
80    /// These parameter blocks are used as communication mailbox between the OSPM and the platform, and there is 1 parameter block for each RAS feature.
81    /// 
82    /// NOTE: There can be only on parameter block per type.
83    pub const fn parameter_blocks(&self) -> ! {
84        todo!()
85    }
86}
87
88#[derive(Copy, Clone)]
89#[repr(C, packed)]
90/// ## ACPI RAS Feature Table (RASF)
91pub struct RASF {
92    /// - **Signature** - "RASF"
93    pub header: SDTHeader,
94    /// Identifier of the RASF Platform Communication Channel.
95    ///
96    /// OSPM should use this value to identify the PCC Sub channel structure in the RASF table
97    pub rasf_platform_communication_channel_id: [u8; 12],
98}