Explorar el Código

Make some of the fields on SdtHeader public

There isn't really any reason that they needed getters, as far as I could
see
Isaac Woods hace 5 años
padre
commit
cd6c3aa80f
Se han modificado 5 ficheros con 17 adiciones y 34 borrados
  1. 2 2
      acpi/src/fadt.rs
  2. 3 3
      acpi/src/lib.rs
  3. 1 1
      acpi/src/madt.rs
  4. 1 1
      acpi/src/mcfg.rs
  5. 10 27
      acpi/src/sdt.rs

+ 2 - 2
acpi/src/fadt.rs

@@ -92,7 +92,7 @@ where
 
     let dsdt_address = unsafe {
         fadt.x_dsdt_address
-            .access(fadt.header.revision())
+            .access(fadt.header.revision)
             .filter(|&p| p != 0)
             .or(Some(fadt.dsdt_address as u64))
             .filter(|p| *p != 0)
@@ -101,7 +101,7 @@ where
 
     acpi.dsdt = dsdt_address.map(|address| {
         let dsdt_header = crate::sdt::peek_at_sdt_header(handler, address);
-        AmlTable::new(address, dsdt_header.length())
+        AmlTable::new(address, dsdt_header.length)
     });
 
     Ok(())

+ 3 - 3
acpi/src/lib.rs

@@ -210,7 +210,7 @@ where
     };
 
     let header = sdt::peek_at_sdt_header(handler, physical_address);
-    let mapping = handler.map_physical_region::<SdtHeader>(physical_address, header.length() as usize);
+    let mapping = handler.map_physical_region::<SdtHeader>(physical_address, header.length as usize);
 
     if revision == 0 {
         /*
@@ -218,7 +218,7 @@ where
          */
         (*mapping).validate(b"RSDT")?;
 
-        let num_tables = ((*mapping).length() as usize - mem::size_of::<SdtHeader>()) / mem::size_of::<u32>();
+        let num_tables = ((*mapping).length as usize - mem::size_of::<SdtHeader>()) / mem::size_of::<u32>();
         let tables_base = ((mapping.virtual_start.as_ptr() as usize) + mem::size_of::<SdtHeader>()) as *const u32;
 
         for i in 0..num_tables {
@@ -230,7 +230,7 @@ where
          */
         (*mapping).validate(b"XSDT")?;
 
-        let num_tables = ((*mapping).length() as usize - mem::size_of::<SdtHeader>()) / mem::size_of::<u64>();
+        let num_tables = ((*mapping).length as usize - mem::size_of::<SdtHeader>()) / mem::size_of::<u64>();
         let tables_base = ((mapping.virtual_start.as_ptr() as usize) + mem::size_of::<SdtHeader>()) as *const u64;
 
         for i in 0..num_tables {

+ 1 - 1
acpi/src/madt.rs

@@ -41,7 +41,7 @@ impl Madt {
     fn entries(&self) -> MadtEntryIter {
         MadtEntryIter {
             pointer: unsafe { (self as *const Madt as *const u8).offset(mem::size_of::<Madt>() as isize) },
-            remaining_length: self.header.length() - mem::size_of::<Madt>() as u32,
+            remaining_length: self.header.length - mem::size_of::<Madt>() as u32,
             _phantom: PhantomData,
         }
     }

+ 1 - 1
acpi/src/mcfg.rs

@@ -42,7 +42,7 @@ pub(crate) struct Mcfg {
 
 impl Mcfg {
     fn entries(&self) -> &[McfgEntry] {
-        let length = self.header.length() as usize - mem::size_of::<Mcfg>();
+        let length = self.header.length as usize - mem::size_of::<Mcfg>();
 
         // intentionally round down in case length isn't an exact multiple of McfgEntry size
         let num_entries = length / mem::size_of::<McfgEntry>();

+ 10 - 27
acpi/src/sdt.rs

@@ -61,14 +61,14 @@ impl<T: Copy, const MIN_VERSION: u8> ExtendedField<T, MIN_VERSION> {
 #[repr(C, packed)]
 pub struct SdtHeader {
     signature: [u8; 4],
-    length: u32,
-    revision: u8,
-    checksum: u8,
-    oem_id: [u8; 6],
-    oem_table_id: [u8; 8],
-    oem_revision: u32,
-    creator_id: u32,
-    creator_revision: u32,
+    pub length: u32,
+    pub revision: u8,
+    pub checksum: u8,
+    pub oem_id: [u8; 6],
+    pub oem_table_id: [u8; 8],
+    pub oem_revision: u32,
+    pub creator_id: u32,
+    pub creator_revision: u32,
 }
 
 impl SdtHeader {
@@ -107,23 +107,6 @@ impl SdtHeader {
         Ok(())
     }
 
-    pub fn raw_signature(&self) -> [u8; 4] {
-        self.signature
-    }
-
-    pub fn signature<'a>(&'a self) -> &'a str {
-        // Safe to unwrap because we check signature is valid UTF8 in `validate`
-        str::from_utf8(&self.signature).unwrap()
-    }
-
-    pub fn length(&self) -> u32 {
-        self.length
-    }
-
-    pub fn revision(&self) -> u8 {
-        self.revision
-    }
-
     pub fn oem_id<'a>(&'a self) -> &'a str {
         // Safe to unwrap because checked in `validate`
         str::from_utf8(&self.oem_id).unwrap()
@@ -155,14 +138,14 @@ where
     H: AcpiHandler,
 {
     let header = peek_at_sdt_header(handler, physical_address);
-    trace!("Found ACPI table with signature {:?} and length {:?}", header.signature(), header.length());
+    trace!("Found ACPI table with signature {:?} and length {:?}", header.signature, header.length);
 
     /*
      * For a recognised signature, a new physical mapping should be created with the correct type
      * and length, and then the dispatched to the correct function to actually parse the table.
      */
-    match header.signature() {
         "FACP" => {
+    match header.signature {
             let fadt_mapping = handler.map_physical_region::<Fadt>(physical_address, mem::size_of::<Fadt>());
             crate::fadt::parse_fadt(acpi, handler, &fadt_mapping)?;
             handler.unmap_physical_region(fadt_mapping);