@@ -9,7 +9,7 @@ use uefi::table::boot::{
9
9
Tpl ,
10
10
} ;
11
11
use uefi:: table:: { Boot , SystemTable } ;
12
- use uefi:: { boot, guid, Event , Guid , Identify , Status } ;
12
+ use uefi:: { boot, guid, system , Event , Guid , Identify , Status } ;
13
13
14
14
pub fn test ( st : & SystemTable < Boot > ) {
15
15
let bt = st. boot_services ( ) ;
@@ -30,6 +30,7 @@ pub fn test(st: &SystemTable<Boot>) {
30
30
test_reinstall_protocol_interface ( bt) ;
31
31
test_uninstall_protocol_interface ( bt) ;
32
32
test_install_configuration_table ( st) ;
33
+ test_install_configuration_table_freestanding ( ) ;
33
34
}
34
35
35
36
fn test_tpl ( ) {
@@ -262,6 +263,35 @@ fn test_uninstall_protocol_interface(bt: &BootServices) {
262
263
}
263
264
}
264
265
266
+ fn test_install_configuration_table_freestanding ( ) {
267
+ // Get the current number of entries.
268
+ let count = system:: with_config_table ( |t| t. len ( ) ) ;
269
+
270
+ // Create the entry data.
271
+ let config = boot:: allocate_pool ( MemoryType :: RUNTIME_SERVICES_DATA , 1 )
272
+ . unwrap ( )
273
+ . as_ptr ( ) ;
274
+ unsafe { config. write ( 42 ) } ;
275
+
276
+ // Install the table.
277
+ const ID : Guid = guid ! ( "4bec53c4-5fc1-48a1-ab12-df214907d29f" ) ;
278
+ unsafe {
279
+ boot:: install_configuration_table ( & ID , config. cast ( ) ) . unwrap ( ) ;
280
+ }
281
+
282
+ // Verify the installation.
283
+ assert_eq ! ( count + 1 , system:: with_config_table( |t| t. len( ) ) ) ;
284
+ system:: with_config_table ( |t| {
285
+ let config_entry = t. iter ( ) . find ( |ct| ct. guid == ID ) . unwrap ( ) ;
286
+ assert_eq ! ( unsafe { * ( config_entry. address as * const u8 ) } , 42 ) ;
287
+ } ) ;
288
+
289
+ // Uninstall the table.
290
+ unsafe {
291
+ boot:: install_configuration_table ( & ID , ptr:: null ( ) ) . unwrap ( ) ;
292
+ }
293
+ }
294
+
265
295
fn test_install_configuration_table ( st : & SystemTable < Boot > ) {
266
296
let config = st
267
297
. boot_services ( )
0 commit comments