-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example app for ShellParams protocol
Signed-off-by: Daniel Schaefer <[email protected]>
- Loading branch information
1 parent
571a045
commit 031fefb
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// ANCHOR: all | ||
// ANCHOR: features | ||
#![no_main] | ||
#![no_std] | ||
// ANCHOR_END: features | ||
|
||
// ANCHOR: use | ||
use log::info; | ||
use uefi::{ | ||
prelude::*, | ||
proto::shell_params::ShellParameters, | ||
table::boot::{OpenProtocolAttributes, OpenProtocolParams, SearchType}, | ||
Identify, | ||
}; | ||
// ANCHOR_END: use | ||
|
||
// ANCHOR: entry | ||
#[entry] | ||
fn main(_image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status { | ||
// ANCHOR_END: entry | ||
// ANCHOR: services | ||
uefi_services::init(&mut system_table).unwrap(); | ||
let boot_services = system_table.boot_services(); | ||
// ANCHOR_END: services | ||
|
||
// ANCHOR: params | ||
let shell_params_h = boot_services | ||
.locate_handle_buffer(SearchType::ByProtocol(&ShellParameters::GUID)) | ||
.unwrap(); | ||
info!("Found {} ShellParams handles", (*shell_params_h).len()); | ||
for handle in &*shell_params_h { | ||
let params_handle = unsafe { | ||
boot_services | ||
.open_protocol::<ShellParameters>( | ||
OpenProtocolParams { | ||
handle: *handle, | ||
agent: boot_services.image_handle(), | ||
controller: None, | ||
}, | ||
OpenProtocolAttributes::GetProtocol, | ||
) | ||
.expect("Failed to open ShellParams handle") | ||
}; | ||
|
||
// TODO: Ehm why are there two and one has no args? | ||
// Maybe one is the shell itself? | ||
if params_handle.argc == 0 { | ||
continue; | ||
} | ||
|
||
let args = params_handle.get_args(); | ||
info!("Args: {:?}", args); | ||
} | ||
// ANCHOR_END: params | ||
|
||
// ANCHOR: return | ||
Status::SUCCESS | ||
} | ||
// ANCHOR_END: return | ||
// ANCHOR_END: all |