Forráskód Böngészése

[Closes #29] Extract power profile from FADT

Isaac Woods 5 éve
szülő
commit
7f23405a95
2 módosított fájl, 30 hozzáadás és 0 törlés
  1. 27 0
      acpi/src/fadt.rs
  2. 3 0
      acpi/src/lib.rs

+ 27 - 0
acpi/src/fadt.rs

@@ -8,6 +8,20 @@ use crate::{
     PhysicalMapping,
 };
 
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub enum PowerProfile {
+    Unspecified,
+    Desktop,
+    Mobile,
+    Workstation,
+    EnterpriseServer,
+    SohoServer,
+    AppliancePc,
+    PerformanceServer,
+    Tablet,
+    Reserved(u8),
+}
+
 /// Represents the Fixed ACPI Description Table (FADT). This table contains various fixed hardware
 /// details, such as the addresses of the hardware register blocks. It also contains a pointer to
 /// the Differentiated Definition Block (DSDT).
@@ -90,6 +104,19 @@ where
     let fadt = &*mapping;
     fadt.header.validate(crate::sdt::Signature::FADT)?;
 
+    acpi.power_profile = match fadt.preferred_pm_profile {
+        0 => PowerProfile::Unspecified,
+        1 => PowerProfile::Desktop,
+        2 => PowerProfile::Mobile,
+        3 => PowerProfile::Workstation,
+        4 => PowerProfile::EnterpriseServer,
+        5 => PowerProfile::SohoServer,
+        6 => PowerProfile::AppliancePc,
+        7 => PowerProfile::PerformanceServer,
+        8 => PowerProfile::Tablet,
+        other => PowerProfile::Reserved(other),
+    };
+
     let dsdt_address = unsafe {
         fadt.x_dsdt_address
             .access(fadt.header.revision)

+ 3 - 0
acpi/src/lib.rs

@@ -40,6 +40,7 @@ mod rsdp_search;
 mod sdt;
 
 pub use crate::{
+    fadt::PowerProfile,
     handler::{AcpiHandler, PhysicalMapping},
     hpet::HpetInfo,
     interrupt::InterruptModel,
@@ -142,6 +143,7 @@ pub struct Acpi {
     /// just error in cases that the tables detail more than one.
     pub interrupt_model: Option<InterruptModel>,
     pub hpet: Option<HpetInfo>,
+    pub power_profile: PowerProfile,
 
     /// Info about the DSDT, if we find it.
     pub dsdt: Option<AmlTable>,
@@ -206,6 +208,7 @@ where
         application_processors: Vec::new(),
         interrupt_model: None,
         hpet: None,
+        power_profile: PowerProfile::Unspecified,
         dsdt: None,
         ssdts: Vec::new(),
         pci_config_regions: None,