Parcourir la source

Change SDT validation to take the signature

Isaac Woods il y a 7 ans
Parent
commit
f578070927
2 fichiers modifiés avec 6 ajouts et 5 suppressions
  1. 2 1
      src/lib.rs
  2. 4 4
      src/sdt.rs

+ 2 - 1
src/lib.rs

@@ -116,7 +116,8 @@ pub fn parse_rsdt<H>(handler            : &mut H,
     let mapping = handler.map_physical_region::<SdtHeader>(physical_address);
 
     // TODO: extend the mapping to header.length
-    // TODO: validate the signature and checksum
+    // TODO: validate the signature and checksum (XXX: if it's a RSDT, the signature will be
+    // "RSDT", whereas a XSDT will have a signature of "XSDT"
 
     if revision == 0
     {

+ 4 - 4
src/sdt.rs

@@ -20,14 +20,14 @@ pub struct SdtHeader
 impl SdtHeader
 {
     /// Check that:
-    ///     a) The signature is valid UTF8
-    ///     b) The checksum of the SDT.
+    ///     a) The signature matches the one given
+    ///     b) The checksum of the SDT
     ///
     /// This assumes that the whole SDT is mapped.
-    fn validate(&self) -> Result<(), AcpiError>
+    fn validate(&self, signature : &[u8; 4]) -> Result<(), AcpiError>
     {
         // Check the signature
-        if str::from_utf8(&self.signature).is_err()
+        if &self.signature == signature
         {
             return Err(AcpiError::SdtInvalidSignature);
         }