|
| 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