File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 7
7
- Added ` proto::hii::config::ConfigKeywordHandler ` .
8
8
- Added ` proto::hii::config::HiiConfigAccess ` .
9
9
- Added ` proto::hii::config_str::ConfigurationString ` .
10
+ - Added ` proto::hii::database::HiiDatabase ` .
10
11
11
12
## Changed
12
13
- ** Breaking:** ` boot::stall ` now take ` core::time::Duration ` instead of ` usize ` .
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: MIT OR Apache-2.0
2
+
3
+ //! HII Database protocol.
4
+
5
+ use alloc:: vec:: Vec ;
6
+ use uefi_macros:: unsafe_protocol;
7
+ use uefi_raw:: Status ;
8
+ use uefi_raw:: protocol:: hii:: database:: HiiDatabaseProtocol ;
9
+
10
+ use crate :: StatusExt ;
11
+
12
+ /// The HII Configuration Access Protocol.
13
+ ///
14
+ /// # UEFI Spec Description
15
+ ///
16
+ /// Database manager for HII-related data structures.
17
+ #[ derive( Debug ) ]
18
+ #[ repr( transparent) ]
19
+ #[ unsafe_protocol( HiiDatabaseProtocol :: GUID ) ]
20
+ pub struct HiiDatabase ( HiiDatabaseProtocol ) ;
21
+
22
+ impl HiiDatabase {
23
+ /// Export all package lists as raw byte buffer.
24
+ #[ must_use]
25
+ pub fn export_all_raw ( & self ) -> crate :: Result < Vec < u8 > > {
26
+ // call the function with a buffer_size of 0 first, so it will fail with
27
+ // BUFFER_TOO_SMALL to tell us what size is required.
28
+ let mut buffer_size = 0 ;
29
+ unsafe {
30
+ let result = ( self . 0 . export_package_lists ) (
31
+ & self . 0 ,
32
+ core:: ptr:: null_mut ( ) ,
33
+ & mut buffer_size,
34
+ core:: ptr:: null_mut ( ) ,
35
+ ) ;
36
+ assert_eq ! ( result, Status :: BUFFER_TOO_SMALL ) ;
37
+ }
38
+
39
+ // allocate buffer with the requested size and call the method again
40
+ let mut buffer = Vec :: with_capacity ( buffer_size) ;
41
+ buffer. resize ( buffer_size, 0u8 ) ;
42
+ unsafe {
43
+ ( self . 0 . export_package_lists ) (
44
+ & self . 0 ,
45
+ core:: ptr:: null_mut ( ) ,
46
+ & mut buffer_size,
47
+ buffer. as_mut_ptr ( ) . cast ( ) ,
48
+ )
49
+ . to_result_with_val ( || buffer)
50
+ }
51
+ }
52
+ }
Original file line number Diff line number Diff line change 5
5
pub mod config;
6
6
#[ cfg( feature = "alloc" ) ]
7
7
pub mod config_str;
8
+ #[ cfg( feature = "alloc" ) ]
9
+ pub mod database;
You can’t perform that action at this time.
0 commit comments