interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / uefi / src / proto / hii / config_routing.rs

49 lines · 1818 bytes Raw Blame History
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! HII Configuration protocols.
4
5use core::ptr;
6
7use alloc::string::{String, ToString};
8use uefi_macros::unsafe_protocol;
9use uefi_raw::Char16;
10use uefi_raw::protocol::hii::config::HiiConfigRoutingProtocol;
11
12use crate::data_types::PoolString;
13use crate::{Status, StatusExt};
14
15/// The HII Configuration Routing Protocol.
16///
17/// # UEFI Specification
18///
19/// The EFI HII Configuration Routing Protocol manages the movement of configuration
20/// data from drivers to configuration applications. It then serves as the single point
21/// to receive configuration information from configuration applications, routing the results
22/// to the appropriate drivers.
23#[derive(Debug)]
24#[repr(transparent)]
25#[unsafe_protocol(HiiConfigRoutingProtocol::GUID)]
26pub struct HiiConfigRouting(HiiConfigRoutingProtocol);
27impl HiiConfigRouting {
28 /// Request the current configuration for the entirety of the current HII database and
29 /// return the data as string in multi configuration string format.
30 ///
31 /// Use `super::config_str::MultiConfigurationStringIter` to parse the returned `String`.
32 ///
33 /// # Errors
34 ///
35 /// * [`Status::NOT_FOUND`] - The firmware reported success but did not
36 /// provide a result string.
37 pub fn export(&self) -> uefi::Result<String> {
38 let mut results: *mut Char16 = ptr::null_mut();
39 // SAFETY: The memory is valid.
40 unsafe { (self.0.export_config)(&self.0, &mut results) }.to_result()?;
41 if results.is_null() {
42 return Err(Status::NOT_FOUND.into());
43 }
44 // SAFETY: The firmware allocated the NUL-terminated string from the
45 // pool; `PoolString` frees it.
46 let results = unsafe { PoolString::new(results.cast()) }?;
47 Ok(results.to_string())
48 }
49}