@@ -81,11 +81,22 @@ impl IcsType {
8181 }
8282}
8383
84+ bitflags ! {
85+ /// Multiple APIC Flags.
86+ ///
87+ /// See ACPI Table 5-44.
88+ pub struct MultipleApicFlags : u32 {
89+ /// Indicates that the system has a PC-AT compatible
90+ /// dual-8259 setup.
91+ const PCAT_COMPAT = 1 ;
92+ }
93+ }
94+
8495bitflags ! {
8596 /// Local APIC Flags.
8697 ///
8798 /// See ACPI Table 5-47.
88- struct ApicFlags : u32 {
99+ pub struct LocalApicFlags : u32 {
89100 /// The processor is ready for use.
90101 const ENABLED = 1 ;
91102 /// If `ENABLED` bit is 0, the processor supports enabling this
@@ -96,10 +107,10 @@ bitflags! {
96107}
97108
98109bitflags ! {
99- /// MPS INI Flags.
110+ /// MPS INTI Flags.
100111 ///
101112 /// See ACPI Table 5-50
102- struct MpsIniFlags : u16 {
113+ pub struct MpsIntiFlags : u16 {
103114 /// Active High Polarity.
104115 const ACTIVE_HIGH = 0x0001 ;
105116 /// Active Low Polarity.
@@ -122,7 +133,7 @@ pub enum Ics {
122133 /// The processors local APIC ID.
123134 apic_id : u8 ,
124135 /// Local APIC Flags.
125- flags : u32 ,
136+ flags : LocalApicFlags ,
126137 } ,
127138 /// I/O APIC Structure.
128139 ///
@@ -146,14 +157,14 @@ pub enum Ics {
146157 /// signal.
147158 gsi : u32 ,
148159 /// MPS INI Flags.
149- flags : u16 ,
160+ flags : MpsIntiFlags ,
150161 } ,
151162 /// Non-Maskable Interrupt Source Structure.
152163 ///
153164 /// See `ACPI § 5.2.12.6`.
154165 NmiSource {
155166 /// MPS INI Flags.
156- flags : u16 ,
167+ flags : MpsIntiFlags ,
157168 /// Global System Interrupt that this NMI will signal.
158169 gsi : u32 ,
159170 } ,
@@ -164,7 +175,7 @@ pub enum Ics {
164175 /// Processor Object ID.
165176 acpi_proc_uid : u8 ,
166177 /// MPS INI Flags.
167- flags : u16 ,
178+ flags : MpsIntiFlags ,
168179 /// Local APIC interrupt input LINTn to which NMI is connected.
169180 local_apic_lint : u8 ,
170181 } ,
@@ -175,7 +186,7 @@ pub enum Ics {
175186 /// Processor local x2APIC ID.
176187 x2apic_id : u32 ,
177188 /// Local APIC Flags.
178- flags : u32 ,
189+ flags : LocalApicFlags ,
179190 /// Processor Object ID.
180191 apic_proc_uid : u32 ,
181192 } ,
@@ -189,7 +200,9 @@ impl Ics {
189200 IcsType :: ProcessorLocalApic => Ok ( Ics :: LocalApic {
190201 apic_uid : bytes[ 0 ] ,
191202 apic_id : bytes[ 1 ] ,
192- flags : NativeEndian :: read_u32 ( & bytes[ 2 ..6 ] ) ,
203+ flags : LocalApicFlags :: from_bits_truncate (
204+ NativeEndian :: read_u32 ( & bytes[ 2 ..6 ] ) ,
205+ ) ,
193206 } ) ,
194207 IcsType :: IoApic => {
195208 let ioapic_addr = NativeEndian :: read_u32 ( & bytes[ 2 ..6 ] ) ;
@@ -203,21 +216,29 @@ impl Ics {
203216 Ok ( Ics :: InterruptSourceOverride {
204217 source : bytes[ 1 ] ,
205218 gsi : NativeEndian :: read_u32 ( & bytes[ 2 ..6 ] ) ,
206- flags : NativeEndian :: read_u16 ( & bytes[ 6 ..8 ] ) ,
219+ flags : MpsIntiFlags :: from_bits_truncate (
220+ NativeEndian :: read_u16 ( & bytes[ 6 ..8 ] ) ,
221+ ) ,
207222 } )
208223 }
209224 IcsType :: NmiSource => Ok ( Ics :: NmiSource {
210- flags : NativeEndian :: read_u16 ( & bytes[ 0 ..2 ] ) ,
225+ flags : MpsIntiFlags :: from_bits_truncate (
226+ NativeEndian :: read_u16 ( & bytes[ 0 ..2 ] ) ,
227+ ) ,
211228 gsi : NativeEndian :: read_u32 ( & bytes[ 2 ..6 ] ) ,
212229 } ) ,
213230 IcsType :: LocalApicNmi => Ok ( Ics :: LocalApicNmi {
214231 acpi_proc_uid : bytes[ 0 ] ,
215- flags : NativeEndian :: read_u16 ( & bytes[ 1 ..3 ] ) ,
232+ flags : MpsIntiFlags :: from_bits_truncate (
233+ NativeEndian :: read_u16 ( & bytes[ 1 ..3 ] ) ,
234+ ) ,
216235 local_apic_lint : bytes[ 3 ] ,
217236 } ) ,
218237 IcsType :: ProcessorLocalX2Apic => Ok ( Ics :: LocalX2Apic {
219238 x2apic_id : NativeEndian :: read_u32 ( & bytes[ 2 ..6 ] ) ,
220- flags : NativeEndian :: read_u32 ( & bytes[ 6 ..10 ] ) ,
239+ flags : LocalApicFlags :: from_bits_truncate (
240+ NativeEndian :: read_u32 ( & bytes[ 6 ..10 ] ) ,
241+ ) ,
221242 apic_proc_uid : NativeEndian :: read_u32 ( & bytes[ 10 ..14 ] ) ,
222243 } ) ,
223244 _ => Err ( Error :: NotImplemented ( format ! (
@@ -253,7 +274,7 @@ pub struct MADT<'a> {
253274 pub ica : * const u8 ,
254275 /// Multiple APIC Flags. See `ACPI § 5.2.12` Table 5-44
255276 /// for the flag values and their meaning.
256- pub flags : u32 ,
277+ pub flags : MultipleApicFlags ,
257278 /// A TLV buffer of MADT specific structures.
258279 ///
259280 /// From `ACPI § 5.2.12`:
@@ -273,7 +294,9 @@ impl<'a> MADT<'a> {
273294 pub fn new ( sdt : & ' a SDT < ' a > ) -> MADT < ' a > {
274295 let ica =
275296 NativeEndian :: read_u32 ( & sdt. table [ offsets:: LOCAL_INT_CTRL_ADDR ] ) ;
276- let flags = NativeEndian :: read_u32 ( & sdt. table [ offsets:: FLAGS ] ) ;
297+ let flags = MultipleApicFlags :: from_bits_truncate (
298+ NativeEndian :: read_u32 ( & sdt. table [ offsets:: FLAGS ] ) ,
299+ ) ;
277300 let ics = & sdt. table [ offsets:: INT_CTRL_STRUCTS ..] ;
278301 MADT {
279302 sdt,
0 commit comments