raw_acpi/pcct/subspace/mod.rs
1pub mod extended;
2pub mod generic;
3pub mod hw_reduced;
4pub mod hw_reg;
5
6// JJ here, I most likely will make this into an enum of references, but just so alignment doesn't get hurt, I will not include this.
7/*
8#[derive(Copy, Clone)]
9#[repr(C, packed)]
10/// ## Platform Communications Channel Subspace Structures
11///
12/// PCC Subspaces are described by the PCC Subspace structure in the PCCT table.
13/// The subspace ID of a PCC subspace is its index in the array of subspace structures, starting with subspace 0.
14pub struct PCCSubspace {
15 /// The type of subspace.
16 pub r#type: u8,
17 /// Length of the subspace structure, in bytes.
18 ///
19 /// The next subspace structure begins length bytes after the start of this one.
20 pub length: u8,
21 /// See specific subspace types for more details.
22 pub type_specific_fields: [u8; 0],
23}
24*/
25
26#[derive(Copy, Clone)]
27/// ## Generic Communications Channel Command Field
28///
29/// For channels of type 0 to 2, this 16-bit field is used to select one of the defined commands for the platform to perform.
30/// OSPM is responsible for populating this field before each command invocation.
31pub struct GenericCommunicationsChannelCommandField(u16);
32impl GenericCommunicationsChannelCommandField {
33 /// Command code to execute.
34 ///
35 /// Command codes are application specific and defined by the consumer of this interface.
36 pub const fn command(&self) -> u8 {
37 (self.0 & 0x00FF) as u8
38 }
39 /// If set, the platform should generate a Doorbell interrupt at the completion of this command.
40 /// The interrupt is an SCI for a Type 0 subspace structure, or as described by the Doorbell Interrupt field for Type 1 and Type 2 subspace structures.
41 /// If the Doorbell bit is not set in the PCC global flags, this bit must be cleared.
42 pub const fn notify_on_completion(&self) -> bool {
43 self.0 & 0x8000 != 0
44 }
45 // JJ here, the rest of the bits are reserved; no need to implement them.
46}
47
48#[derive(Copy, Clone)]
49/// ## Generic Communications Channel Status Field
50pub struct GenericCommunicationsChannelStatusField(u16);
51impl GenericCommunicationsChannelStatusField {
52 /// If set, the platform has completed processing the last command.
53 pub const fn command_complete(&self) -> bool {
54 self.0 & 0b0001 != 0
55 }
56 /// If set, the platform has issued a Platform Interrupt to this subspace.
57 ///
58 /// OSPM must check the Command Complete and Platform Notification fields to determine the cause of the Interrupt.
59 pub const fn platform_interrupt(&self) -> bool {
60 self.0 & 0b0010 != 0
61 }
62 /// If set, an error occurred executing the last command.
63 pub const fn error(&self) -> bool {
64 self.0 & 0b0100 != 0
65 }
66 /// If set, indicates the platform is issuing an asynchronous notification to OSPM.
67 pub const fn platform_notification(&self) -> bool {
68 self.0 & 0b1000 != 0
69 }
70 // JJ here, the rest of the bits are reserved; no need to implement them.
71}
72
73#[derive(Copy, Clone)]
74#[repr(C, packed)]
75/// ## Generic Communications Channel Shared Memory Region
76pub struct GenericCommunicationsChannelSMR {
77 /// The PCC signature.
78 ///
79 /// The signature of a subspace is computed by a bitwise-or of the value 0x50434300 with the subspace ID. For example, subspace 3 has the signature 0x50434303.
80 pub signature: u32,
81 /// PCC command field.
82 pub command: GenericCommunicationsChannelCommandField,
83 /// PCC status field.
84 pub status: GenericCommunicationsChannelStatusField,
85 /// Memory region for reading/writing PCC data.
86 ///
87 /// The size of this region is 8 bytes smaller than the size of the shared memory region (specified in the Generic Communications Subspace structure).
88 ///
89 /// The first byte of this field represents PCC address 0.
90 pub communication_subspace: [u8; 0],
91}
92
93#[derive(Copy, Clone)]
94/// ## Master Slave Communications Channel Flags
95pub struct MasterSlaveCommunicationsChannelFlags(u32);
96impl MasterSlaveCommunicationsChannelFlags {
97 /// For master subspaces this field indicates to the platform that it must generate an interrupt when the command has completed.
98 /// - Setting this bit to 1 when sending a command, requests that completion of the command is signaled via the platform interrupt.
99 /// - Setting it to 0 when sending a command, requests that no interrupt is asserted when the command is completed.
100 ///
101 /// For slave subspaces, if the doorbell field of the slave subspace is non zero, and this flag is set, the OSPM must access the doorbell once it has processed the notification.
102 /// This bit is ignored by the platform if the Platform Interrupt field of the PCC flags (Platform Communications Channel Global Flags) is set to zero.
103 pub const fn notify_on_completion(&self) -> bool {
104 self.0 & 0b1 != 0
105 }
106 // JJ here, the rest of the bits are reserved; no need to implement them.
107}
108
109#[derive(Copy, Clone)]
110#[repr(C, packed)]
111/// ## Extended PCC Subspace Shared Memory Region
112///
113/// **JJ's Note: Same thing as Master Slave Communications Channel Shared Memory Region.**
114pub struct MasterSlaveCommunicationsChannelSMR {
115 /// The PCC signature.
116 ///
117 /// The signature of a subspace is computed by a bitwise-or of the value 0x50434300 with the subspace ID.
118 /// For example, subspace 3 has the signature 0x50434303.
119 pub signature: u32,
120 /// Master Slave Communications Channel Flags.
121 pub flags: MasterSlaveCommunicationsChannelFlags,
122 /// Length of payload being transmitted including command field.
123 pub length: u32,
124 /// Command being sent over the subspace.
125 pub command: u32,
126 /// Memory region for reading/writing PCC data.
127 ///
128 /// The maximum size of this region is 16 bytes smaller than the size of the shared memory region (specified in the Master Slave Communications Subspace structure).
129 /// When a command is sent to or received from the platform, the size of the data in this space will be Length (expressed above) minus the 4 bytes taken up by the command.
130 pub communication_subspace: [u8; 0]
131}
132
133#[derive(Copy, Clone)]
134#[repr(C, packed)]
135/// ## Reduced PCC Subspace Shared Memory Region
136pub struct ReducedPCCSubspaceSMR {
137 /// The PCC signature.
138 ///
139 /// The signature of a subspace is computed by a bitwise-or of the value 0x50434300 with the subspace ID.
140 /// For example, subspace 3 has the signature 0x50434303.
141 pub signature: u32,
142 /// Memory region for reading/writing PCC data.
143 ///
144 /// The maximum size of this region is 4 bytes smaller than the size of the shared memory region (specified in the Type 5 PCC Subspace structure).
145 /// When a command is sent to or received from the platform, the size of the data in this space will be Length (expressed above) minus the 4 bytes taken up by the Signature.
146 pub communication_subspace: [u8; 0]
147}