-
-
Notifications
You must be signed in to change notification settings - Fork 170
[Misc] Add ResetNotification protocol. Add Misc to uefi-test-runner. #1116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
04be50f
[Misc] Add ResetNotification protocol. Add Misc to uefi-test-runner.
sky5454 d94e1b1
[Fixed] nits and only readonly hook called.
sky5454 2c03778
[Fixed] move `test_timestamp` from ovmf test to example. fixed other …
sky5454 b8f2129
[Fixed] nits and docs.
sky5454 a067526
[test] test timestamp in vmware UEFI 2.7 and got the result ok.
sky5454 aa6d4b2
[test] expect test. Drop the Option so that the caller is forced to p…
sky5454 ced31d7
Merge branch 'main' into main
sky5454 fc01d48
[test] example timestamp `uefi_services` change to `uefi::helpers`
sky5454 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,64 @@ | ||
// ANCHOR: all | ||
// ANCHOR: features | ||
#![no_main] | ||
#![no_std] | ||
// ANCHOR_END: features | ||
|
||
extern crate alloc; | ||
|
||
use log::{info, warn}; | ||
|
||
// ANCHOR: use | ||
use uefi::prelude::*; | ||
use uefi::proto::misc::Timestamp; | ||
|
||
// ANCHOR_END: use | ||
|
||
// ANCHOR: entry | ||
#[entry] | ||
fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status { | ||
// ANCHOR_END: entry | ||
// ANCHOR: services | ||
uefi::helpers::init(&mut system_table).unwrap(); | ||
let boot_services = system_table.boot_services(); | ||
// ANCHOR_END: services | ||
|
||
// ANCHOR: params | ||
test_timestamp(boot_services); | ||
// ANCHOR_END: params | ||
|
||
// ANCHOR: stall | ||
boot_services.stall(10_000_000); | ||
// ANCHOR_END: stall | ||
|
||
// ANCHOR: return | ||
Status::SUCCESS | ||
} | ||
// ANCHOR_END: return | ||
|
||
// ANCHOR: test_timestamp | ||
pub fn test_timestamp(bt: &BootServices) { | ||
// ANCHOR_END: test_timestamp | ||
info!("Running loaded Timestamp Protocol test"); | ||
|
||
let handle = bt.get_handle_for_protocol::<Timestamp>(); | ||
|
||
match handle { | ||
Ok(handle) => { | ||
let timestamp_proto = bt | ||
.open_protocol_exclusive::<Timestamp>(handle) | ||
.expect("Founded Timestamp Protocol but open failed"); | ||
// ANCHOR: text | ||
let timestamp = timestamp_proto.get_timestamp(); | ||
info!("Timestamp Protocol's timestamp: {:?}", timestamp); | ||
|
||
let properties = timestamp_proto.get_properties(); | ||
info!("Timestamp Protocol's properties: {:?}", properties); | ||
// ANCHOR_END: text | ||
} | ||
Err(err) => { | ||
warn!("Failed to found Timestamp Protocol: {:?}", err); | ||
} | ||
} | ||
} | ||
// ANCHOR_END: all |
This file contains hidden or 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,44 @@ | ||
use uefi::prelude::*; | ||
use uefi::proto::misc::ResetNotification; | ||
use uefi::table::runtime; | ||
|
||
pub fn test(bt: &BootServices) { | ||
test_reset_notification(bt); | ||
} | ||
|
||
pub fn test_reset_notification(bt: &BootServices) { | ||
info!("Running loaded ResetNotification protocol test"); | ||
|
||
let handle = bt | ||
.get_handle_for_protocol::<ResetNotification>() | ||
.expect("Failed to get handles for `ResetNotification` protocol"); | ||
|
||
let mut reset_notif_proto = bt | ||
.open_protocol_exclusive::<ResetNotification>(handle) | ||
.expect("Founded ResetNotification Protocol but open failed"); | ||
|
||
// value efi_reset_fn is the type of ResetSystemFn, a function pointer | ||
unsafe extern "efiapi" fn efi_reset_fn( | ||
rt: runtime::ResetType, | ||
status: Status, | ||
data_size: usize, | ||
data: *const u8, | ||
) { | ||
info!("Inside the event callback, hi, efi_reset_fn"); | ||
info!("rt: {:?} status: {:?}", rt, status); | ||
info!("size: {:?} data: {:?}", data_size, data); | ||
// do what you want | ||
} | ||
|
||
let result = reset_notif_proto.register_reset_notify(efi_reset_fn); | ||
info!( | ||
"ResetNotification Protocol register efi_reset_fn test: {:?}", | ||
result | ||
); | ||
|
||
let result = reset_notif_proto.unregister_reset_notify(efi_reset_fn); | ||
info!( | ||
"ResetNotification Protocol unregister efi_reset_fn test: {:?}", | ||
result | ||
); | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.