MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / get_shell_protocol

Function get_shell_protocol

framework_lib/src/fw_uefi/fs.rs:11–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9use uefi_raw::protocol::shell_params::ShellFileHandle;
10
11fn get_shell_protocol() -> &'static ShellProtocol {
12 let handle = boot::get_handle_for_protocol::<Shell>().expect("No Shell handles");
13
14 // Use GetProtocol instead of Exclusive since we're running inside the shell
15 let shell = unsafe {
16 boot::open_protocol::<Shell>(
17 OpenProtocolParams {
18 handle,
19 agent: boot::image_handle(),
20 controller: None,
21 },
22 OpenProtocolAttributes::GetProtocol,
23 )
24 .expect("Failed to open Shell protocol")
25 };
26
27 // SAFETY: The Shell wrapper contains the raw ShellProtocol
28 unsafe {
29 let proto: &ShellProtocol = core::mem::transmute(shell.get().unwrap());
30 // Leak to get 'static lifetime - protocol stays valid while shell is running
31 core::mem::forget(shell);
32 proto
33 }
34}
35
36pub fn shell_read_file(path: &str) -> Option<Vec<u8>> {
37 let shell = get_shell_protocol();

Callers 2

shell_read_fileFunction · 0.70
shell_write_fileFunction · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected