Skip to content

Commit

Permalink
Add example app for ShellParams protocol
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Apr 28, 2023
1 parent 571a045 commit 031fefb
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions uefi-test-runner/examples/shell_params.rs
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

0 comments on commit 031fefb

Please sign in to comment.