|
| 1 | +use alloc::vec::Vec; |
1 | 2 | use core::ffi::c_void;
|
2 |
| -use uefi::proto::debug::{DebugSupport, ExceptionType, ProcessorArch, SystemContext}; |
| 3 | +use uefi::proto::debug::{DebugPort, DebugSupport, ExceptionType, ProcessorArch, SystemContext}; |
3 | 4 | use uefi::table::boot::BootServices;
|
4 | 5 |
|
5 | 6 | pub fn test(bt: &BootServices) {
|
| 7 | + test_debug_support(bt); |
| 8 | + test_debug_port(bt); |
| 9 | +} |
| 10 | + |
| 11 | +fn test_debug_port(bt: &BootServices) { |
| 12 | + info!("Running UEFI debug port protocol test"); |
| 13 | + if let Ok(handles) = bt.find_handles::<DebugPort>() { |
| 14 | + for handle in handles { |
| 15 | + if let Ok(debug_port) = bt.open_protocol_exclusive::<DebugPort>(handle) { |
| 16 | + let timeout = 1000; |
| 17 | + |
| 18 | + debug_port |
| 19 | + .reset() |
| 20 | + .expect("Error while resetting debug port"); |
| 21 | + let data: Vec<_> = r##" |
| 22 | + .. .=- . |
| 23 | + . :##+ .*##= -*#+ .. |
| 24 | + =#*=:.*####+#####**####-.-*## |
| 25 | + .=-. *############################: :-: |
| 26 | + -###**##############################*###* |
| 27 | + :. -#######################################* .:: |
| 28 | + =################################################## |
| 29 | + .#################################################= |
| 30 | + -====#################################################+====. |
| 31 | + =##########################################################. |
| 32 | + +########################################################. |
| 33 | + -==+#########################################################*+=-. |
| 34 | + +######################=:=@@%#########+:-%@%####################*: |
| 35 | + =####################+ +@@@%######%. -@@@##################*. |
| 36 | + :+#####################@-.:%@@@@#####%@*::#@@@%###################+: |
| 37 | + +#######################@@@@@@@@@######@@@@@@@@%#####################- |
| 38 | + -#########################@@@@@@@########@@@@@@%####################### |
| 39 | + -#######%%%##################%##############################%%%%######* |
| 40 | + +########%%%%############################################*%%%%#######: |
| 41 | + =######+=%%%#####***##%%#####################%#**++####=:%%%#######: |
| 42 | + :*#####:.*%#-####+==*########+-::::::=*#######*=+###*- *%*:-####*. |
| 43 | + -####* .+. -*###############= .*#############*- .*: *###+ |
| 44 | + =###: *##############+ .##############+ .###= |
| 45 | + .+#* -######*=+++**** =###***++######- :#*. |
| 46 | + .- -######- .*#####- .- |
| 47 | + =*####*. =####+- |
| 48 | + .:--: ::::. |
| 49 | +"## |
| 50 | + .bytes() |
| 51 | + .collect(); |
| 52 | + |
| 53 | + debug_port |
| 54 | + .write(timeout, &data) |
| 55 | + .expect("Error while writing to debug port"); |
| 56 | + |
| 57 | + debug_port.poll().expect("Error while polling debug port"); |
| 58 | + |
| 59 | + let mut data = Vec::with_capacity(4096); |
| 60 | + |
| 61 | + debug_port |
| 62 | + .read(timeout, &mut data) |
| 63 | + .expect("Error while reading from debug port"); |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +fn test_debug_support(bt: &BootServices) { |
6 | 70 | info!("Running UEFI debug connection protocol test");
|
7 | 71 | let handles = bt
|
8 | 72 | .find_handles::<DebugSupport>()
|
|
0 commit comments