Skip to content

Commit 5f75bed

Browse files
timrobertsdevRenTrieu
authored andcommitted
uefi: Begin implementing the EFI Shell Protocol
1 parent dab0752 commit 5f75bed

File tree

4 files changed

+437
-0
lines changed

4 files changed

+437
-0
lines changed

uefi-test-runner/src/proto/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub fn test() {
4242
target_arch = "aarch64"
4343
))]
4444
shim::test();
45+
shell::test();
4546
tcg::test();
4647
}
4748

@@ -96,6 +97,7 @@ mod shell_params;
9697
target_arch = "arm",
9798
target_arch = "aarch64"
9899
))]
100+
mod shell;
99101
mod shim;
100102
mod string;
101103
mod tcg;

uefi-test-runner/src/proto/shell.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use uefi::CStr16;
2+
use uefi::prelude::BootServices;
3+
use uefi::proto::shell::Shell;
4+
5+
pub fn test(bt: &BootServices) {
6+
info!("Running shell protocol tests");
7+
8+
let handle = bt.get_handle_for_protocol::<Shell>().expect("No Shell handles");
9+
10+
let mut shell = bt
11+
.open_protocol_exclusive::<Shell>(handle)
12+
.expect("Failed to open Shell protocol");
13+
14+
// create some files
15+
let mut test_buf = [0u16; 12];
16+
let test_str = CStr16::from_str_with_buf("test", &mut test_buf).unwrap();
17+
shell.create_file(test_str, 0);
18+
19+
// get file tree
20+
let mut str_buf = [0u16; 12];
21+
let str_str = CStr16::from_str_with_buf(r"fs0:\*", &mut str_buf).unwrap();
22+
let res = shell.find_files(str_str);
23+
let list = res.unwrap();
24+
let list = list.unwrap();
25+
let first = list.first();
26+
27+
info!("filetree test successful")
28+
}

uefi/src/proto/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ where
101101
ptr.cast::<Self>()
102102
}
103103
}
104+

0 commit comments

Comments
 (0)