Skip to content

Commit bdaa870

Browse files
committed
acpi: fix safety docs
Place safety documentation in a separate section so that clippy does not emit a warning for them. Add any missing safety documentation as well.
1 parent e158098 commit bdaa870

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

acpi/src/handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ where
5151
/// than `region_length`, due to requirements of the paging system or other reasoning.
5252
/// - `handler` should be the same `AcpiHandler` that created the mapping. When the `PhysicalMapping` is
5353
/// dropped, it will be used to unmap the structure.
54+
///
55+
/// ### Safety
56+
///
57+
/// The caller must ensure that the physical memory can be safely mapped.
5458
pub unsafe fn new(
5559
physical_start: usize,
5660
virtual_start: NonNull<T>,

acpi/src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ where
200200
{
201201
/// Create an `AcpiTables` if you have the physical address of the RSDP.
202202
///
203-
/// ### Safety: Caller must ensure the provided address is valid to read as an RSDP.
203+
/// ### Safety
204+
///
205+
/// Caller must ensure the provided address is valid to read as an RSDP.
204206
pub unsafe fn from_rsdp(handler: H, address: usize) -> AcpiResult<Self> {
205207
let rsdp_mapping = unsafe { handler.map_physical_region::<Rsdp>(address, mem::size_of::<Rsdp>()) };
206208
rsdp_mapping.validate()?;
@@ -212,6 +214,10 @@ where
212214
/// Search for the RSDP on a BIOS platform. This accesses BIOS-specific memory locations and will probably not
213215
/// work on UEFI platforms. See [Rsdp::search_for_rsdp_bios](rsdp_search::Rsdp::search_for_rsdp_bios) for
214216
/// details.
217+
///
218+
/// ### Safety
219+
///
220+
/// The caller must ensure that this function is called on BIOS platforms.
215221
pub unsafe fn search_for_rsdp_bios(handler: H) -> AcpiResult<Self> {
216222
let rsdp_mapping = unsafe { Rsdp::search_for_on_bios(handler.clone())? };
217223
// Safety: RSDP has been validated from `Rsdp::search_for_on_bios`
@@ -222,7 +228,9 @@ where
222228
/// from `from_rsdp` after validation, but can also be used if you've searched for the RSDP manually on a BIOS
223229
/// system.
224230
///
225-
/// ### Safety: Caller must ensure that the provided mapping is a fully validated RSDP.
231+
/// ### Safety
232+
///
233+
/// Caller must ensure that the provided mapping is a fully validated RSDP.
226234
pub unsafe fn from_validated_rsdp(handler: H, rsdp_mapping: PhysicalMapping<H, Rsdp>) -> AcpiResult<Self> {
227235
let revision = rsdp_mapping.revision();
228236
let root_table_mapping = if revision == 0 {
@@ -247,7 +255,9 @@ where
247255

248256
/// Create an `AcpiTables` if you have the physical address of the RSDT/XSDT.
249257
///
250-
/// ### Safety: Caller must ensure the provided address is valid RSDT/XSDT address.
258+
/// ### Safety
259+
///
260+
/// Caller must ensure the provided address is valid RSDT/XSDT address.
251261
pub unsafe fn from_rsdt(handler: H, revision: u8, address: usize) -> AcpiResult<Self> {
252262
let root_table_mapping = if revision == 0 {
253263
/*
@@ -408,7 +418,9 @@ impl AmlTable {
408418
}
409419
}
410420

411-
/// ### Safety: Caller must ensure the provided address is valid for being read as an `SdtHeader`.
421+
/// ### Safety
422+
///
423+
/// Caller must ensure the provided address is valid for being read as an `SdtHeader`.
412424
unsafe fn read_table<H: AcpiHandler, T: AcpiTable>(
413425
handler: H,
414426
address: usize,

0 commit comments

Comments
 (0)