@@ -9,52 +9,36 @@ pub fn test(bt: &BootServices) {
9
9
pub fn test_reset_notification ( bt : & BootServices ) {
10
10
info ! ( "Running loaded ResetNotification protocol test" ) ;
11
11
12
- let handle = bt. get_handle_for_protocol :: < ResetNotification > ( ) ;
13
-
14
- match handle {
15
- Ok ( handle) => {
16
- let mut reset_notif_proto = bt
17
- . open_protocol_exclusive :: < ResetNotification > ( handle)
18
- . expect ( "Founded ResetNotification Protocol but open failed" ) ;
19
- let result = reset_notif_proto. register_reset_notify ( None ) ;
20
- info ! (
21
- "ResetNotification Protocol register null test: {:?}" ,
22
- result
23
- ) ;
24
-
25
- let result = reset_notif_proto. unregister_reset_notify ( None ) ;
26
- info ! (
27
- "ResetNotification Protocol unregister null test: {:?}" ,
28
- result
29
- ) ;
30
-
31
- // value efi_reset_fn is the type of ResetSystemFn, a function pointer
32
- unsafe extern "efiapi" fn efi_reset_fn (
33
- rt : runtime:: ResetType ,
34
- status : Status ,
35
- data_size : usize ,
36
- data : * const u8 ,
37
- ) {
38
- info ! ( "Inside the event callback, hi, efi_reset_fn" ) ;
39
- info ! ( "rt: {:?} status: {:?}" , rt, status) ;
40
- info ! ( "size: {:?} data: {:?}" , data_size, data) ;
41
- // do what you want
42
- }
43
-
44
- let result = reset_notif_proto. register_reset_notify ( Some ( efi_reset_fn) ) ;
45
- info ! (
46
- "ResetNotification Protocol register efi_reset_fn test: {:?}" ,
47
- result
48
- ) ;
49
-
50
- let result = reset_notif_proto. unregister_reset_notify ( Some ( efi_reset_fn) ) ;
51
- info ! (
52
- "ResetNotification Protocol unregister efi_reset_fn test: {:?}" ,
53
- result
54
- ) ;
55
- }
56
- Err ( err) => {
57
- warn ! ( "Failed to found ResetNotification Protocol: {:?}" , err) ;
58
- }
12
+ let handle = bt
13
+ . get_handle_for_protocol :: < ResetNotification > ( )
14
+ . expect ( "Failed to get handles for `ResetNotification` protocol" ) ;
15
+
16
+ let mut reset_notif_proto = bt
17
+ . open_protocol_exclusive :: < ResetNotification > ( handle)
18
+ . expect ( "Founded ResetNotification Protocol but open failed" ) ;
19
+
20
+ // value efi_reset_fn is the type of ResetSystemFn, a function pointer
21
+ unsafe extern "efiapi" fn efi_reset_fn (
22
+ rt : runtime:: ResetType ,
23
+ status : Status ,
24
+ data_size : usize ,
25
+ data : * const u8 ,
26
+ ) {
27
+ info ! ( "Inside the event callback, hi, efi_reset_fn" ) ;
28
+ info ! ( "rt: {:?} status: {:?}" , rt, status) ;
29
+ info ! ( "size: {:?} data: {:?}" , data_size, data) ;
30
+ // do what you want
59
31
}
32
+
33
+ let result = reset_notif_proto. register_reset_notify ( efi_reset_fn) ;
34
+ info ! (
35
+ "ResetNotification Protocol register efi_reset_fn test: {:?}" ,
36
+ result
37
+ ) ;
38
+
39
+ let result = reset_notif_proto. unregister_reset_notify ( efi_reset_fn) ;
40
+ info ! (
41
+ "ResetNotification Protocol unregister efi_reset_fn test: {:?}" ,
42
+ result
43
+ ) ;
60
44
}
0 commit comments