Skip to content

Commit 66b1f57

Browse files
authored
Merge pull request #1753 from seijikun/mr-hii-configrouting
uefi: Add bindings for the HII_CONFIG_ROUTING protocol
2 parents 2ff2b6e + ea5b01d commit 66b1f57

File tree

6 files changed

+290
-19
lines changed

6 files changed

+290
-19
lines changed

uefi-raw/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- `[u8; 32]` --> `MacAddress`
2121
- `[u8; 4]` --> `Ipv4Address`, `IpAddress`
2222
- `[u8; 16]` --> `Ipv6Address`, `IpAddress`
23+
- Added `HiiConfigRoutingProtocol`.
2324

2425
## Changed
2526
- **Breaking:** The MSRV is now 1.85.1 and the crate uses the Rust 2024 edition.

uefi-raw/src/protocol/hii/config.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
use core::fmt::Debug;
66

7+
use crate::protocol::device_path::DevicePathProtocol;
78
use crate::{Char16, Guid, Status, guid, newtype_enum};
89

910
/// EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL
@@ -172,3 +173,50 @@ pub struct HiiConfigAccessProtocol {
172173
impl HiiConfigAccessProtocol {
173174
pub const GUID: Guid = guid!("330d4706-f2a0-4e4f-a369-b66fa8d54385");
174175
}
176+
177+
/// EFI_HII_CONFIG_ROUTING_PROTOCOL
178+
#[derive(Debug)]
179+
#[repr(C)]
180+
pub struct HiiConfigRoutingProtocol {
181+
pub extract_config: unsafe extern "efiapi" fn(
182+
this: *const Self,
183+
config_request: *const Char16,
184+
progress: *mut *const Char16,
185+
results: *mut *const Char16,
186+
) -> Status,
187+
pub export_config:
188+
unsafe extern "efiapi" fn(this: *const Self, results: *mut *const Char16) -> Status,
189+
pub route_config: unsafe extern "efiapi" fn(
190+
this: *const Self,
191+
configuration: *const Char16,
192+
progress: *mut *const Char16,
193+
) -> Status,
194+
pub block_to_config: unsafe extern "efiapi" fn(
195+
this: *const Self,
196+
config_request: *const Char16,
197+
block: *const u8,
198+
block_size: usize,
199+
config: *mut *const Char16,
200+
progress: *mut *const Char16,
201+
) -> Status,
202+
pub config_to_block: unsafe extern "efiapi" fn(
203+
this: *const Self,
204+
config_resp: *const Char16,
205+
block: *mut *const u8,
206+
block_size: *mut usize,
207+
progress: *mut *const Char16,
208+
) -> Status,
209+
pub get_alt_cfg: unsafe extern "efiapi" fn(
210+
this: *const Self,
211+
config_resp: *const Char16,
212+
guid: *const Guid,
213+
name: *const Char16,
214+
device_path: *const DevicePathProtocol,
215+
alt_cfg_id: *const Char16,
216+
alt_cfg_resp: *mut *const Char16,
217+
) -> Status,
218+
}
219+
220+
impl HiiConfigRoutingProtocol {
221+
pub const GUID: Guid = guid!("587e72d7-cc50-4f79-8209-ca291fc1a10f");
222+
}

uefi/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- Added `proto::hii::config_str::ConfigurationString`.
1010
- Added `proto::acpi::AcpiTable`.
1111
- Added `proto::hii::database::HiiDatabase`.
12+
- Added `proto::hii::config_str::MultiConfigurationStringIter`.
13+
- Added `proto::hii::config_routing::HiiConfigRouting`.
1214

1315
## Changed
1416
- **Breaking:** `boot::stall` now take `core::time::Duration` instead of `usize`.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
//! HII Configuration protocols.
4+
5+
use core::ptr;
6+
7+
use alloc::string::{String, ToString};
8+
use uefi_macros::unsafe_protocol;
9+
use uefi_raw::Char16;
10+
use uefi_raw::protocol::hii::config::HiiConfigRoutingProtocol;
11+
12+
use crate::{CStr16, StatusExt};
13+
14+
/// The HII Configuration Routing Protocol.
15+
///
16+
/// # UEFI Spec Description
17+
///
18+
/// The EFI HII Configuration Routing Protocol manages the movement of configuration
19+
/// data from drivers to configuration applications. It then serves as the single point
20+
/// to receive configuration information from configuration applications, routing the results
21+
/// to the appropriate drivers.
22+
#[derive(Debug)]
23+
#[repr(transparent)]
24+
#[unsafe_protocol(HiiConfigRoutingProtocol::GUID)]
25+
pub struct HiiConfigRouting(HiiConfigRoutingProtocol);
26+
impl HiiConfigRouting {
27+
/// Request the current configuration for the entirety of the current HII database and
28+
/// return the data as string in multi configuration string format.
29+
///
30+
/// Use `super::config_str::MultiConfigurationStringIter` to parse the returned `String`.
31+
pub fn export(&self) -> uefi::Result<String> {
32+
unsafe {
33+
let mut results: *const Char16 = ptr::null();
34+
(self.0.export_config)(&self.0, &mut results)
35+
.to_result_with_val(|| CStr16::from_ptr(results.cast()).to_string())
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)