Browse Source

Future proof processor UIDs in MADT parsing

The later x2APIC extended the processor UID to a 4-byte field. We want to
use the same representation for that, so simply use `u32` and cast for the
old single-byte entries.
Isaac Woods 5 years ago
parent
commit
a2af8a64a8
2 changed files with 26 additions and 16 deletions
  1. 3 1
      acpi/src/interrupt.rs
  2. 23 15
      acpi/src/madt.rs

+ 3 - 1
acpi/src/interrupt.rs

@@ -22,7 +22,9 @@ pub enum LocalInterruptLine {
 #[derive(Debug)]
 pub enum NmiProcessor {
     All,
-    ProcessorUid(u8),
+    /// Refers to a processor with the given UID. This is stored as a `u32`, but should be casted to `u8` when the
+    /// DSDT uses the deprecated `DefProcessor` operator to define processor UIDs.
+    ProcessorUid(u32),
 }
 
 #[derive(Debug)]

+ 23 - 15
acpi/src/madt.rs

@@ -1,5 +1,15 @@
 use crate::{
-    interrupt::{Apic, InterruptModel, InterruptSourceOverride, IoApic, NmiLine, NmiProcessor, NmiSource, Polarity, TriggerMode},
+    interrupt::{
+        Apic,
+        InterruptModel,
+        InterruptSourceOverride,
+        IoApic,
+        NmiLine,
+        NmiProcessor,
+        NmiSource,
+        Polarity,
+        TriggerMode,
+    },
     sdt::SdtHeader,
     Acpi,
     AcpiError,
@@ -476,20 +486,18 @@ fn parse_apic_model(acpi: &mut Acpi, mapping: &PhysicalMapping<Madt>) -> Result<
                 });
             }
 
-            MadtEntry::LocalApicNmi(ref entry) => {
-                local_apic_nmi_lines.push(NmiLine {
-                    processor: if entry.processor_id == 0xff {
-                        NmiProcessor::All
-                    } else {
-                        NmiProcessor::ProcessorUid(entry.processor_id)
-                    },
-                    line: match entry.nmi_line {
-                        0 => LocalInterruptLine::Lint0,
-                        1 => LocalInterruptLine::Lint1,
-                        _ => return Err(AcpiError::InvalidMadt(MadtError::InvalidLocalNmiLine)),
-                    },
-                })
-            }
+            MadtEntry::LocalApicNmi(ref entry) => local_apic_nmi_lines.push(NmiLine {
+                processor: if entry.processor_id == 0xff {
+                    NmiProcessor::All
+                } else {
+                    NmiProcessor::ProcessorUid(entry.processor_id as u32)
+                },
+                line: match entry.nmi_line {
+                    0 => LocalInterruptLine::Lint0,
+                    1 => LocalInterruptLine::Lint1,
+                    _ => return Err(AcpiError::InvalidMadt(MadtError::InvalidLocalNmiLine)),
+                },
+            }),
 
             MadtEntry::LocalApicAddressOverride(ref entry) => {
                 local_apic_address = entry.local_apic_address;