浏览代码

[Closes #25] Make parse_rsdp and parse_rsdt unsafe

These take potentially-incorrect physical addresses and dereference them,
so should definitely be unsafe. This creates warnings about nested unsafe
blocks but there are imminent plans to make that accepted so I'm leaving
it to reduce churn.
Isaac Woods 5 年之前
父节点
当前提交
8dca2c9cb4
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      acpi/src/lib.rs

+ 4 - 4
acpi/src/lib.rs

@@ -158,7 +158,7 @@ pub struct Acpi {
 /// This is the entry point of `acpi` if you have the **physical** address of the RSDP. It maps
 /// This is the entry point of `acpi` if you have the **physical** address of the RSDP. It maps
 /// the RSDP, works out what version of ACPI the hardware supports, and passes the physical
 /// the RSDP, works out what version of ACPI the hardware supports, and passes the physical
 /// address of the RSDT/XSDT to `parse_rsdt`.
 /// address of the RSDT/XSDT to `parse_rsdt`.
-pub fn parse_rsdp<H>(handler: &mut H, rsdp_address: usize) -> Result<Acpi, AcpiError>
+pub unsafe fn parse_rsdp<H>(handler: &mut H, rsdp_address: usize) -> Result<Acpi, AcpiError>
 where
 where
     H: AcpiHandler,
     H: AcpiHandler,
 {
 {
@@ -180,7 +180,7 @@ where
          */
          */
         let rsdt_address = (*rsdp_mapping).rsdt_address();
         let rsdt_address = (*rsdp_mapping).rsdt_address();
         handler.unmap_physical_region(rsdp_mapping);
         handler.unmap_physical_region(rsdp_mapping);
-        parse_rsdt(handler, revision, rsdt_address as usize)
+        unsafe { parse_rsdt(handler, revision, rsdt_address as usize) }
     } else {
     } else {
         /*
         /*
          * We're running on ACPI Version 2.0+. We should use the 64-bit XSDT address, truncated
          * We're running on ACPI Version 2.0+. We should use the 64-bit XSDT address, truncated
@@ -188,7 +188,7 @@ where
          */
          */
         let xsdt_address = (*rsdp_mapping).xsdt_address();
         let xsdt_address = (*rsdp_mapping).xsdt_address();
         handler.unmap_physical_region(rsdp_mapping);
         handler.unmap_physical_region(rsdp_mapping);
-        parse_rsdt(handler, revision, xsdt_address as usize)
+        unsafe { parse_rsdt(handler, revision, xsdt_address as usize) }
     }
     }
 }
 }
 
 
@@ -198,7 +198,7 @@ where
 ///
 ///
 /// If the given revision is 0, an address to the RSDT is expected. Otherwise, an address to
 /// If the given revision is 0, an address to the RSDT is expected. Otherwise, an address to
 /// the XSDT is expected.
 /// the XSDT is expected.
-pub fn parse_rsdt<H>(handler: &mut H, revision: u8, physical_address: usize) -> Result<Acpi, AcpiError>
+pub unsafe fn parse_rsdt<H>(handler: &mut H, revision: u8, physical_address: usize) -> Result<Acpi, AcpiError>
 where
 where
     H: AcpiHandler,
     H: AcpiHandler,
 {
 {