@@ -9,7 +9,7 @@ use uefi::table::boot::{
99 Tpl ,
1010} ;
1111use uefi:: table:: { Boot , SystemTable } ;
12- use uefi:: { boot, guid, Event , Guid , Identify , Status } ;
12+ use uefi:: { boot, guid, system , Event , Guid , Identify , Status } ;
1313
1414pub fn test ( st : & SystemTable < Boot > ) {
1515 let bt = st. boot_services ( ) ;
@@ -30,6 +30,7 @@ pub fn test(st: &SystemTable<Boot>) {
3030 test_reinstall_protocol_interface ( bt) ;
3131 test_uninstall_protocol_interface ( bt) ;
3232 test_install_configuration_table ( st) ;
33+ test_install_configuration_table_freestanding ( ) ;
3334}
3435
3536fn test_tpl ( ) {
@@ -262,6 +263,35 @@ fn test_uninstall_protocol_interface(bt: &BootServices) {
262263 }
263264}
264265
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+
265295fn test_install_configuration_table ( st : & SystemTable < Boot > ) {
266296 let config = st
267297 . boot_services ( )
0 commit comments