@@ -3,55 +3,66 @@ use uefi::proto::misc::{ResetNotification, Timestamp};
3
3
use uefi:: table:: runtime;
4
4
5
5
///
6
- /// you may see those log, it's nothing just for your computer firmware does not support the new UEFI feature.
6
+ /// you may see those log, it's nothing just for your computer firmware does not support the new UEFI feature of Timestamp Protocol .
7
7
///
8
8
/// ```sh
9
- /// [ INFO]: uefi-test-runner\src\proto\misc.rs@012: Running loaded Timestamp Protocol test
10
- /// [ WARN]: uefi-test-runner\src\proto\misc.rs@026: Failed to open Timestamp Protocol: Error { status: UNSUPPORTED, data: () }
11
- /// [ INFO]: uefi-test-runner\src\proto\misc.rs@033: Running loaded ResetNotification protocol test
12
- /// [ WARN]: uefi-test-runner\src\proto\misc.rs@068: Failed to open ResetNotification Protocol: Error { status: UNSUPPORTED, data: () }
9
+ /// [ INFO]: uefi-test-runner\src\proto\misc.rs@020: Running loaded Timestamp Protocol test
10
+ /// [ WARN]: uefi-test-runner\src\proto\misc.rs@037: Failed to found Timestamp Protocol: Error { status: NOT_FOUND, data: () }
11
+ /// [ INFO]: uefi-test-runner\src\proto\misc.rs@043: Running loaded ResetNotification protocol test
12
+ /// [ INFO]: uefi-test-runner\src\proto\misc.rs@053: ResetNotification Protocol register null test: Err(Error { status: INVALID_PARAMETER, data: () })
13
+ /// [ INFO]: uefi-test-runner\src\proto\misc.rs@059: ResetNotification Protocol unregister null test: Err(Error { status: INVALID_PARAMETER, data: () })
14
+ /// [ INFO]: uefi-test-runner\src\proto\misc.rs@078: ResetNotification Protocol register efi_reset_fn test: Ok(())
15
+ /// [ INFO]: uefi-test-runner\src\proto\misc.rs@084: ResetNotification Protocol unregister efi_reset_fn test: Ok(())
13
16
/// ```
14
- pub fn test ( image : Handle , bt : & BootServices ) {
15
- test_timestamp ( image , bt) ;
16
- test_reset_notification ( image , bt) ;
17
+ pub fn test ( bt : & BootServices ) {
18
+ test_timestamp ( bt) ;
19
+ test_reset_notification ( bt) ;
17
20
}
18
21
19
- pub fn test_timestamp ( image : Handle , bt : & BootServices ) {
22
+ pub fn test_timestamp ( bt : & BootServices ) {
20
23
info ! ( "Running loaded Timestamp Protocol test" ) ;
21
24
22
- let result = bt
23
- . open_protocol_exclusive :: < Timestamp > ( image) ;
25
+ let handle = bt. get_handle_for_protocol :: < Timestamp > ( ) ;
26
+
27
+ match handle {
28
+ Ok ( handle) => {
29
+ let timestamp_proto = bt
30
+ . open_protocol_exclusive :: < Timestamp > ( handle)
31
+ . expect ( "Founded Timestamp Protocol but open failed" ) ;
24
32
25
- match result {
26
- Ok ( timestamp_proto) => {
27
33
let timestamp = timestamp_proto. get_timestamp ( ) ;
28
34
info ! ( "Timestamp Protocol's timestamp: {:?}" , timestamp) ;
29
35
30
36
let properties = timestamp_proto. get_properties ( ) ;
31
37
info ! ( "Timestamp Protocol's properties: {:?}" , properties) ;
32
38
}
33
39
Err ( err) => {
34
- warn ! ( "Failed to open Timestamp Protocol: {:?}" , err) ;
40
+ warn ! ( "Failed to found Timestamp Protocol: {:?}" , err) ;
35
41
}
36
42
}
37
43
}
38
44
39
-
40
- pub fn test_reset_notification ( image : Handle , bt : & BootServices ) {
45
+ pub fn test_reset_notification ( bt : & BootServices ) {
41
46
info ! ( "Running loaded ResetNotification protocol test" ) ;
42
47
43
- let result = bt
44
- . open_protocol_exclusive :: < ResetNotification > ( image) ;
48
+ let handle = bt. get_handle_for_protocol :: < ResetNotification > ( ) ;
45
49
46
- match result {
47
- Ok ( mut reset_notif_proto) => {
50
+ match handle {
51
+ Ok ( handle) => {
52
+ let mut reset_notif_proto = bt
53
+ . open_protocol_exclusive :: < ResetNotification > ( handle)
54
+ . expect ( "Founded ResetNotification Protocol but open failed" ) ;
48
55
let result = reset_notif_proto. register_reset_notify ( None ) ;
49
- info ! ( "ResetNotification Protocol register null test: {:?}" , result) ;
56
+ info ! (
57
+ "ResetNotification Protocol register null test: {:?}" ,
58
+ result
59
+ ) ;
50
60
51
61
let result = reset_notif_proto. unregister_reset_notify ( None ) ;
52
- info ! ( "ResetNotification Protocol unregister null test: {:?}" , result) ;
53
-
54
-
62
+ info ! (
63
+ "ResetNotification Protocol unregister null test: {:?}" ,
64
+ result
65
+ ) ;
55
66
56
67
// value efi_reset_fn is the type of ResetSystemFn, a function pointer
57
68
unsafe extern "efiapi" fn efi_reset_fn (
@@ -67,14 +78,19 @@ pub fn test_reset_notification(image: Handle, bt: &BootServices) {
67
78
}
68
79
69
80
let result = reset_notif_proto. register_reset_notify ( Some ( efi_reset_fn) ) ;
70
- info ! ( "ResetNotification Protocol register efi_reset_fn test: {:?}" , result) ;
81
+ info ! (
82
+ "ResetNotification Protocol register efi_reset_fn test: {:?}" ,
83
+ result
84
+ ) ;
71
85
72
86
let result = reset_notif_proto. unregister_reset_notify ( Some ( efi_reset_fn) ) ;
73
- info ! ( "ResetNotification Protocol unregister efi_reset_fn test: {:?}" , result) ;
87
+ info ! (
88
+ "ResetNotification Protocol unregister efi_reset_fn test: {:?}" ,
89
+ result
90
+ ) ;
74
91
}
75
92
Err ( err) => {
76
- warn ! ( "Failed to open ResetNotification Protocol: {:?}" , err) ;
93
+ warn ! ( "Failed to found ResetNotification Protocol: {:?}" , err) ;
77
94
}
78
95
}
79
96
}
80
-
0 commit comments