raw_acpi/ecdt.rs
1use crate::{GenericAddressStructure, SDTHeader};
2use core::ffi::CStr;
3
4#[derive(Copy, Clone)]
5#[repr(C, packed)]
6/// ## Embedded Controller Boot Resources Table (ECDT)
7///
8/// This optional table provides the processor-relative, translated resources of an Embedded Controller.
9/// The presence of this table allows OSPM to provide Embedded Controller operation region space access before the namespace has been evaluated.
10/// If this table is not provided, the Embedded Controller region space will not be available
11/// until the Embedded Controller device in the AML namespace has been discovered and enumerated.
12/// The availability of the region space can be detected by providing a _REG method object underneath the Embedded Controller device.
13pub struct EmbeddedControllerBootResourcesTable {
14 /// - **Signature** - "ECDT"
15 pub header: SDTHeader,
16 /// Contains the processor relative address, represented in Generic Address Structure format, of the Embedded Controller Command/Status register.
17 ///
18 /// Note: Only System I/O space and System Memory space are valid for values for `address_space_id`.
19 pub ec_control: GenericAddressStructure,
20 /// Contains the processor-relative address, represented in Generic Address Structure format, of the Embedded Controller Data register.
21 ///
22 /// Note: Only System I/O space and System Memory space are valid for values for `address_space_id`.
23 pub ec_data: GenericAddressStructure,
24 /// Unique ID-Same as the value returned by the _UID under the device in the namespace that represents this embedded controller.
25 pub uid: u32,
26 /// The bit assignment of the SCI interrupt within the GPEx_STS register of a GPE block described in the FADT that the embedded controller triggers.
27 pub gpe_bit: u8,
28 /// ASCII, null terminated, string that contains a fully qualified reference to the namespace object that is this embedded controller device (for example, "\_SB.PCI0.ISA.EC").
29 /// Quotes are omitted in the data field.
30 pub ec_id: [u8; 0],
31}
32impl EmbeddedControllerBootResourcesTable {
33 pub const fn ec_id(&self) -> &CStr {
34 unsafe {
35 CStr::from_bytes_with_nul_unchecked(core::slice::from_raw_parts(
36 (self as *const _ as *const u8).add(0x41),
37 self.header.length as usize - 0x41,
38 ))
39 }
40 }
41}