@@ -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 } ;
12
+ use uefi:: { boot, guid, Event , Guid , Identify , Status } ;
13
13
14
14
pub fn test ( st : & SystemTable < Boot > ) {
15
15
let bt = st. boot_services ( ) ;
@@ -24,6 +24,7 @@ pub fn test(st: &SystemTable<Boot>) {
24
24
test_watchdog ( bt) ;
25
25
info ! ( "Testing protocol handler services..." ) ;
26
26
test_register_protocol_notify ( bt) ;
27
+ test_protocol_interface_management ( ) ;
27
28
test_install_protocol_interface ( bt) ;
28
29
test_reinstall_protocol_interface ( bt) ;
29
30
test_uninstall_protocol_interface ( bt) ;
@@ -133,6 +134,48 @@ fn test_register_protocol_notify(bt: &BootServices) {
133
134
. expect ( "Failed to register protocol notify fn" ) ;
134
135
}
135
136
137
+ fn test_protocol_interface_management ( ) {
138
+ let mut interface = TestProtocol { data : 123 } ;
139
+ let interface_ptr: * mut _ = & mut interface;
140
+
141
+ // Install the protocol.
142
+ let handle = unsafe {
143
+ boot:: install_protocol_interface ( None , & TestProtocol :: GUID , interface_ptr. cast ( ) )
144
+ }
145
+ . unwrap ( ) ;
146
+
147
+ // Verify the handle was installed.
148
+ assert_eq ! (
149
+ & * boot:: locate_handle_buffer( SearchType :: from_proto:: <TestProtocol >( ) ) . unwrap( ) ,
150
+ [ handle]
151
+ ) ;
152
+
153
+ // Re-install the protocol.
154
+ unsafe {
155
+ boot:: reinstall_protocol_interface (
156
+ handle,
157
+ & TestProtocol :: GUID ,
158
+ interface_ptr. cast ( ) ,
159
+ interface_ptr. cast ( ) ,
160
+ )
161
+ }
162
+ . unwrap ( ) ;
163
+
164
+ // Uninstall the protocol.
165
+ unsafe {
166
+ boot:: uninstall_protocol_interface ( handle, & TestProtocol :: GUID , interface_ptr. cast ( ) )
167
+ }
168
+ . unwrap ( ) ;
169
+
170
+ // Verify the protocol was uninstalled.
171
+ assert_eq ! (
172
+ boot:: locate_handle_buffer( SearchType :: from_proto:: <TestProtocol >( ) )
173
+ . unwrap_err( )
174
+ . status( ) ,
175
+ Status :: NOT_FOUND
176
+ ) ;
177
+ }
178
+
136
179
fn test_install_protocol_interface ( bt : & BootServices ) {
137
180
info ! ( "Installing TestProtocol" ) ;
138
181
0 commit comments