@@ -4,91 +4,86 @@ use uefi::table::boot::BootServices;
4
4
5
5
pub fn test ( bt : & BootServices ) {
6
6
info ! ( "Running UEFI debug connection protocol test" ) ;
7
- if let Ok ( handles) = bt. find_handles :: < DebugSupport > ( ) {
8
- for handle in handles {
9
- if let Ok ( mut debug_support) = bt. open_protocol_exclusive :: < DebugSupport > ( handle) {
10
- // make sure that the max processor index is a sane value, i.e. it works
11
- let maximum_processor_index = debug_support. get_maximum_processor_index ( ) ;
12
- assert_ne ! (
7
+ let handles = bt
8
+ . find_handles :: < DebugSupport > ( )
9
+ . expect ( "missing DebugSupport protocol" ) ;
10
+ for handle in handles {
11
+ if let Ok ( mut debug_support) = bt. open_protocol_exclusive :: < DebugSupport > ( handle) {
12
+ // make sure that the max processor index is a sane value, i.e. it works
13
+ let maximum_processor_index = debug_support. get_maximum_processor_index ( ) ;
14
+ assert_ne ! (
13
15
maximum_processor_index,
14
16
usize :: MAX ,
15
17
"get_maximum_processor_index() returning garbage, unless you really have 18,446,744,073,709,551,615 processors"
16
18
) ;
17
19
18
- info ! ( "- Architecture: {:?}" , debug_support. arch( ) ) ;
19
- info ! ( "- Maximum Processor Index: {:?}" , maximum_processor_index) ;
20
+ info ! ( "- Architecture: {:?}" , debug_support. arch( ) ) ;
21
+ info ! ( "- Maximum Processor Index: {:?}" , maximum_processor_index) ;
20
22
21
- match debug_support. arch ( ) {
22
- // This arm is the only match when testing on QEMU w/ OVMF, regardless of the machine arch.
23
- // The released OVMF builds don't implement the Debug Support Protocol Interface for the
24
- // machine arch, only EBC.
25
- ProcessorArch :: EBC => unsafe {
26
- info ! ( "Registering periodic callback" ) ;
27
- debug_support
28
- . register_periodic_callback ( 0 , Some ( periodic_callback) )
29
- . expect ( "Error while registering periodic callback" ) ;
30
- info ! ( "Deregistering periodic callback" ) ;
31
- debug_support
32
- . register_periodic_callback ( 0 , None )
33
- . expect ( "Error while deregistering periodic callback" ) ;
34
- // for the EBC virtual CPU, there are already exception callbacks registered
35
- info ! ( "Deregistering exception callback" ) ;
36
- debug_support
37
- . register_exception_callback ( 0 , None , ExceptionType :: EXCEPT_EBC_DEBUG )
38
- . expect ( "Error while deregistering exception callback" ) ;
39
- info ! ( "Registering exception callback" ) ;
40
- debug_support
41
- . register_exception_callback (
42
- 0 ,
43
- Some ( exception_callback) ,
44
- ExceptionType :: EXCEPT_EBC_DEBUG ,
45
- )
46
- . expect ( "Error while registering exception callback" ) ;
47
- } ,
48
- #[ cfg( target_arch = "x86_64" ) ]
49
- ProcessorArch :: X86_64 => unsafe {
50
- info ! ( "Registering exception callback" ) ;
51
- debug_support
52
- . register_exception_callback (
53
- 0 ,
54
- Some ( exception_callback) ,
55
- ExceptionType :: EXCEPT_X64_DEBUG ,
56
- )
57
- . expect ( "Error while registering exception callback" ) ;
58
- info ! ( "Deregistering exception callback" ) ;
59
- debug_support
60
- . register_exception_callback ( 0 , None , ExceptionType :: EXCEPT_X64_DEBUG )
61
- . expect ( "Error while deregistering exception callback" ) ;
62
- } ,
63
- #[ cfg( target_arch = "aarch64" ) ]
64
- ProcessorArch :: AARCH_64 => unsafe {
65
- info ! ( "Registering exception callback" ) ;
66
- debug_support
67
- . register_exception_callback (
68
- 0 ,
69
- Some ( exception_callback) ,
70
- ExceptionType :: EXCEPT_AARCH64_SERROR ,
71
- )
72
- . expect ( "Error while registering exception callback" ) ;
73
- info ! ( "Deregistering exception callback" ) ;
74
- debug_support
75
- . register_exception_callback (
76
- 0 ,
77
- None ,
78
- ExceptionType :: EXCEPT_AARCH64_SERROR ,
79
- )
80
- . expect ( "Error while deregistering exception callback" ) ;
81
- } ,
82
- // if we reach this, we're running on an arch that `cargo xtask run` doesn't support
83
- // TODO: Add match arms as we support testing on more archs
84
- _ => unreachable ! ( ) ,
85
- }
86
-
87
- test_invalidate_instruction_cache ( & mut debug_support) ;
23
+ match debug_support. arch ( ) {
24
+ // This arm is the only match when testing on QEMU w/ OVMF, regardless of the machine arch.
25
+ // The released OVMF builds don't implement the Debug Support Protocol Interface for the
26
+ // machine arch, only EBC.
27
+ ProcessorArch :: EBC => unsafe {
28
+ info ! ( "Registering periodic callback" ) ;
29
+ debug_support
30
+ . register_periodic_callback ( 0 , Some ( periodic_callback) )
31
+ . expect ( "Error while registering periodic callback" ) ;
32
+ info ! ( "Deregistering periodic callback" ) ;
33
+ debug_support
34
+ . register_periodic_callback ( 0 , None )
35
+ . expect ( "Error while deregistering periodic callback" ) ;
36
+ // for the EBC virtual CPU, there are already exception callbacks registered
37
+ info ! ( "Deregistering exception callback" ) ;
38
+ debug_support
39
+ . register_exception_callback ( 0 , None , ExceptionType :: EXCEPT_EBC_DEBUG )
40
+ . expect ( "Error while deregistering exception callback" ) ;
41
+ info ! ( "Registering exception callback" ) ;
42
+ debug_support
43
+ . register_exception_callback (
44
+ 0 ,
45
+ Some ( exception_callback) ,
46
+ ExceptionType :: EXCEPT_EBC_DEBUG ,
47
+ )
48
+ . expect ( "Error while registering exception callback" ) ;
49
+ } ,
50
+ #[ cfg( target_arch = "x86_64" ) ]
51
+ ProcessorArch :: X86_64 => unsafe {
52
+ info ! ( "Registering exception callback" ) ;
53
+ debug_support
54
+ . register_exception_callback (
55
+ 0 ,
56
+ Some ( exception_callback) ,
57
+ ExceptionType :: EXCEPT_X64_DEBUG ,
58
+ )
59
+ . expect ( "Error while registering exception callback" ) ;
60
+ info ! ( "Deregistering exception callback" ) ;
61
+ debug_support
62
+ . register_exception_callback ( 0 , None , ExceptionType :: EXCEPT_X64_DEBUG )
63
+ . expect ( "Error while deregistering exception callback" ) ;
64
+ } ,
65
+ #[ cfg( target_arch = "aarch64" ) ]
66
+ ProcessorArch :: AARCH_64 => unsafe {
67
+ info ! ( "Registering exception callback" ) ;
68
+ debug_support
69
+ . register_exception_callback (
70
+ 0 ,
71
+ Some ( exception_callback) ,
72
+ ExceptionType :: EXCEPT_AARCH64_SERROR ,
73
+ )
74
+ . expect ( "Error while registering exception callback" ) ;
75
+ info ! ( "Deregistering exception callback" ) ;
76
+ debug_support
77
+ . register_exception_callback ( 0 , None , ExceptionType :: EXCEPT_AARCH64_SERROR )
78
+ . expect ( "Error while deregistering exception callback" ) ;
79
+ } ,
80
+ // if we reach this, we're running on an arch that `cargo xtask run` doesn't support
81
+ // TODO: Add match arms as we support testing on more archs
82
+ _ => unreachable ! ( ) ,
88
83
}
84
+
85
+ test_invalidate_instruction_cache ( & mut debug_support) ;
89
86
}
90
- } else {
91
- warn ! ( "Debug protocol is not supported" ) ;
92
87
}
93
88
}
94
89
0 commit comments