Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 13142ee

Browse files
protocols: Add ACPI Table protocol
1 parent 4ada0f6 commit 13142ee

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed

‎uefi-raw/src/protocol/acpi.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
use crate::{Guid, Status, guid};
4+
use core::ffi::c_void;
5+
6+
#[derive(Clone, Copy, Debug)]
7+
#[repr(C)]
8+
pub struct AcpiTableProtocol {
9+
pub install_acpi_table: unsafe extern "efiapi" fn(
10+
this: *const Self,
11+
acpi_table_buffer: *const c_void,
12+
acpi_table_size: usize,
13+
table_key: *mut usize,
14+
) -> Status,
15+
pub uninstall_acpi_table:
16+
unsafe extern "efiapi" fn(this: *const Self, table_key: usize) -> Status,
17+
}
18+
19+
impl AcpiTableProtocol {
20+
pub const GUID: Guid = guid!("ffe06bdd-6107-46a6-7bb2-5a9c7ec5275c");
21+
}

‎uefi-raw/src/protocol/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//!
2424
//! [`GUID`]: crate::Guid
2525
26+
pub mod acpi;
2627
pub mod ata;
2728
pub mod block;
2829
pub mod console;

‎uefi/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Added `proto::hii::config::ConfigKeywordHandler`.
88
- Added `proto::hii::config::HiiConfigAccess`.
99
- Added `proto::hii::config_str::ConfigurationString`.
10+
- Added `proto::acpi::AcpiTable`.
1011

1112
## Changed
1213
- **Breaking:** `boot::stall` now take `core::time::Duration` instead of `usize`.

‎uefi/src/proto/acpi.rs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
//! `AcpiTable` protocol.
4+
5+
use crate::proto::unsafe_protocol;
6+
use crate::{Result, StatusExt};
7+
use core::ffi::c_void;
8+
use uefi_raw::protocol::acpi::AcpiTableProtocol;
9+
10+
/// The AcpiTable protocol.
11+
#[derive(Debug)]
12+
#[repr(transparent)]
13+
#[unsafe_protocol(AcpiTableProtocol::GUID)]
14+
pub struct AcpiTable(AcpiTableProtocol);
15+
16+
impl AcpiTable {
17+
/// Installs an ACPI table into the RSDT/XSDT. Returns a index
18+
/// that may be used by `uninstall_acpi_table` to remove the ACPI
19+
/// table.
20+
///
21+
/// # Safety
22+
///
23+
/// When installing ACPI table, the data pointed to by
24+
/// `acpi_table_ptr` must be a pool allocation of type
25+
/// [`ACPI_RECLAIM`] or other type suitable for data handed off to
26+
/// the OS.
27+
///
28+
/// [`ACPI_RECLAIM`]: crate::boot::MemoryType::ACPI_RECLAIM
29+
///
30+
/// # Errors
31+
///
32+
/// * [`Status::INVALID_PARAMETER`]: `acpi_table_ptr` is null; the
33+
/// `acpi_table_size`, and the size field embedded in the ACPI
34+
/// table are not in sync.
35+
///
36+
/// * [`Status::OUT_OF_RESOURCES`]: Insufficient resources
37+
/// exist to complete the request.
38+
///
39+
/// * [`Status::ACCESS_DENIED`]: The table signature matches a
40+
/// table already present in the system and platform policy does
41+
/// not allow duplicate tables of this type.
42+
///
43+
/// [`Status::INVALID_PARAMETER`]: crate::Status::INVALID_PARAMETER
44+
/// [`Status::OUT_OF_RESOURCES`]: crate::Status::OUT_OF_RESOURCES
45+
/// [`Status::ACCESS_DENIED`]: crate::Status::ACCESS_DENIED
46+
pub unsafe fn install_acpi_table(
47+
&self,
48+
acpi_table_ptr: *const c_void,
49+
acpi_table_size: usize,
50+
) -> Result<usize> {
51+
let mut table_key = 0usize;
52+
let status = unsafe {
53+
(self.0.install_acpi_table)(&self.0, acpi_table_ptr, acpi_table_size, &mut table_key)
54+
};
55+
status.to_result_with_val(|| table_key)
56+
}
57+
58+
/// Removes an ACPI table from the RSDT/XSDT.
59+
///
60+
/// # Errors
61+
///
62+
/// * [`Status::NOT_FOUND`]: `table_key` does not refer to a
63+
/// valid key for a table entry.
64+
///
65+
/// * [`Status::OUT_OF_RESOURCES`]: Insufficient resources exist
66+
/// to complete the request.
67+
///
68+
/// [`Status::NOT_FOUND`]: crate::Status::NOT_FOUND
69+
/// [`Status::OUT_OF_RESOURCES`]: crate::Status::OUT_OF_RESOURCES
70+
pub fn uninstall_acpi_table(&self, table_key: usize) -> Result {
71+
unsafe { (self.0.uninstall_acpi_table)(&self.0, table_key) }.to_result()
72+
}
73+
}

‎uefi/src/proto/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
//! [`boot`]: crate::boot#accessing-protocols
3232
//! [UEFI protocols]: uefi_raw::protocol
3333
34+
pub mod acpi;
3435
#[cfg(feature = "alloc")]
3536
pub mod ata;
3637
pub mod console;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /