Movatterモバイル変換


[0]ホーム

URL:


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

Commitc62f6ac

Browse files
committed
Add (partial) safe protocol implementation for EFI_HII_DATABASE_PROTOCOL
This only grants access to the HII-database's raw buffer for now.
1 parenta4b852f commitc62f6ac

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

‎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::hii::database::HiiDatabase`.
1011

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

‎uefi/src/proto/hii/database.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
//! HII Database protocol.
4+
5+
use alloc::boxed::Box;
6+
use uefi_macros::unsafe_protocol;
7+
use uefi_raw::protocol::hii::database::HiiDatabaseProtocol;
8+
9+
usecrate::Error;
10+
usecrate::StatusExt;
11+
usecrate::mem::make_boxed;
12+
13+
/// The HII Configuration Access Protocol.
14+
///
15+
/// This protocol grants access to the HII database definition available in every UEFI firmware.
16+
/// This database contains internationalized strings, as well as a description of all
17+
/// supported BIOS settings, together with their logic (e.g.: option A blocks option B if value is `true`).
18+
///
19+
/// # UEFI Spec Description
20+
///
21+
/// Database manager for HII-related data structures.
22+
#[derive(Debug)]
23+
#[repr(transparent)]
24+
#[unsafe_protocol(HiiDatabaseProtocol::GUID)]
25+
pubstructHiiDatabase(HiiDatabaseProtocol);
26+
27+
implHiiDatabase{
28+
/// Export all package lists as raw byte buffer.
29+
pubfnexport_all_raw(&self) ->crate::Result<Box<[u8]>>{
30+
fnfetch_data_fn<'a>(
31+
proto:&HiiDatabase,
32+
buf:&'amut[u8],
33+
) ->Result<&'amut[u8],Error<Option<usize>>>{
34+
unsafe{
35+
letmut size = buf.len();
36+
let status ={
37+
(proto.0.export_package_lists)(
38+
&proto.0,
39+
core::ptr::null_mut(),
40+
&mut size,
41+
buf.as_mut_ptr().cast(),
42+
)
43+
};
44+
status.to_result_with_err(|_|Some(size)).map(|_| buf)
45+
}
46+
}
47+
48+
#[cfg(not(feature ="unstable"))]
49+
let buf =make_boxed::<[u8],_>(|buf|fetch_data_fn(self, buf))?;
50+
51+
#[cfg(feature ="unstable")]
52+
let buf =make_boxed::<[u8],_,_>(|buf|fetch_data_fn(self, buf), alloc::alloc::Global)?;
53+
54+
Ok(buf)
55+
}
56+
}

‎uefi/src/proto/hii/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
pubmod config;
66
#[cfg(feature ="alloc")]
77
pubmod config_str;
8+
#[cfg(feature ="alloc")]
9+
pubmod database;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp