浏览代码

Change the APIC interrupt model to support the X2APIC

Isaac Woods 3 年之前
父节点
当前提交
c0d5fbcf1a
共有 2 个文件被更改,包括 14 次插入21 次删除
  1. 5 5
      acpi/src/platform/interrupt.rs
  2. 9 16
      acpi/src/platform/mod.rs

+ 5 - 5
acpi/src/platform/interrupt.rs

@@ -3,7 +3,9 @@ use alloc::vec::Vec;
 #[derive(Debug)]
 pub struct IoApic {
     pub id: u8,
+    /// The physical address at which to access this I/O APIC.
     pub address: u32,
+    /// The global system interrupt number where this I/O APIC's inputs start.
     pub global_system_interrupt_base: u32,
 }
 
@@ -22,8 +24,6 @@ pub enum LocalInterruptLine {
 #[derive(Debug)]
 pub enum NmiProcessor {
     All,
-    /// 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),
 }
 
@@ -83,8 +83,8 @@ pub enum InterruptModel {
     /// this probably means only the legacy i8259 PIC is present.
     Unknown,
 
-    /// Describes an interrupt controller based around the Advanced Programmable Interrupt
-    /// Controllers. These are likely to be found on x86 and x86_64 systems and are made up of a
-    /// Local APIC for each core and one or more I/O APICs to handle external interrupts.
+    /// Describes an interrupt controller based around the Advanced Programmable Interrupt Controller (any of APIC,
+    /// XAPIC, or X2APIC). These are likely to be found on x86 and x86_64 systems and are made up of a Local APIC
+    /// for each core and one or more I/O APICs to handle external interrupts.
     Apic(Apic),
 }

+ 9 - 16
acpi/src/platform/mod.rs

@@ -1,14 +1,7 @@
 pub mod address;
 pub mod interrupt;
 
-use crate::{
-    fadt::Fadt,
-    madt::Madt,
-    AcpiError,
-    AcpiHandler,
-    AcpiTables,
-    PowerProfile,
-};
+use crate::{fadt::Fadt, madt::Madt, AcpiError, AcpiHandler, AcpiTables, PowerProfile};
 use address::GenericAddress;
 use alloc::vec::Vec;
 use interrupt::InterruptModel;
@@ -28,11 +21,14 @@ pub enum ProcessorState {
 
 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
 pub struct Processor {
-    pub processor_uid: u8,
-    pub local_apic_id: u8,
+    /// Corresponds to the `_UID` object of the processor's `Device`, or the `ProcessorId` field of the `Processor`
+    /// object, in AML.
+    pub processor_uid: u32,
+    /// The ID of the local APIC of the processor. Will be less than `256` if the APIC is being used, but can be
+    /// greater than this if the X2APIC is being used.
+    pub local_apic_id: u32,
 
-    /// The state of this processor. Always check that the processor is not `Disabled` before
-    /// attempting to bring it up!
+    /// The state of this processor. Check that the processor is not `Disabled` before attempting to bring it up!
     pub state: ProcessorState,
 
     /// Whether this processor is the Bootstrap Processor (BSP), or an Application Processor (AP).
@@ -58,10 +54,7 @@ pub struct PmTimer {
 impl PmTimer {
     pub fn new(fadt: &Fadt) -> Result<Option<PmTimer>, AcpiError> {
         match fadt.pm_timer_block()? {
-            Some(base) => Ok(Some(PmTimer {
-                base,
-                supports_32bit: {fadt.flags}.pm_timer_is_32_bit(),
-            })),
+            Some(base) => Ok(Some(PmTimer { base, supports_32bit: { fadt.flags }.pm_timer_is_32_bit() })),
             None => Ok(None),
         }
     }