-
-
Notifications
You must be signed in to change notification settings - Fork 169
[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 1 commit
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# uefi-raw - [Unreleased] | ||
|
||
## Added | ||
- Added `ResetNotification`. | ||
|
||
## Added | ||
- Added `TimestampProtocol`. | ||
|
||
|
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,80 @@ | ||
use uefi::prelude::*; | ||
use uefi::proto::misc::{ResetNotification, Timestamp}; | ||
use uefi::table::runtime; | ||
|
||
/// | ||
/// you may see those log, it's nothing just for your computer firmware does not support the new UEFI feature. | ||
/// | ||
/// ```sh | ||
/// [ INFO]: uefi-test-runner\src\proto\misc.rs@012: Running loaded Timestamp Protocol test | ||
/// [ WARN]: uefi-test-runner\src\proto\misc.rs@026: Failed to open Timestamp Protocol: Error { status: UNSUPPORTED, data: () } | ||
/// [ INFO]: uefi-test-runner\src\proto\misc.rs@033: Running loaded ResetNotification protocol test | ||
/// [ WARN]: uefi-test-runner\src\proto\misc.rs@068: Failed to open ResetNotification Protocol: Error { status: UNSUPPORTED, data: () } | ||
/// ``` | ||
pub fn test(image: Handle, bt: &BootServices) { | ||
test_timestamp(image, bt); | ||
test_reset_notification(image, bt); | ||
} | ||
|
||
pub fn test_timestamp(image: Handle, bt: &BootServices) { | ||
info!("Running loaded Timestamp Protocol test"); | ||
|
||
let result = bt | ||
.open_protocol_exclusive::<Timestamp>(image); | ||
|
||
match result { | ||
Ok(timestamp_proto) => { | ||
let timestamp = timestamp_proto.get_timestamp(); | ||
info!("Timestamp Protocol's timestamp: {:?}", timestamp); | ||
|
||
let properties = timestamp_proto.get_properties(); | ||
info!("Timestamp Protocol's properties: {:?}", properties); | ||
} | ||
Err(err) => { | ||
warn!("Failed to open Timestamp Protocol: {:?}", err); | ||
} | ||
} | ||
} | ||
|
||
|
||
pub fn test_reset_notification(image: Handle, bt: &BootServices) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This only tests to set hook but not that the hook is actually called. Can we fix/add that? |
||
info!("Running loaded ResetNotification protocol test"); | ||
|
||
let result = bt | ||
.open_protocol_exclusive::<ResetNotification>(image); | ||
|
||
match result { | ||
Ok(mut reset_notif_proto) => { | ||
let result = reset_notif_proto.register_reset_notify(None); | ||
info!("ResetNotification Protocol register null test: {:?}", result); | ||
|
||
let result = reset_notif_proto.unregister_reset_notify(None); | ||
info!("ResetNotification Protocol unregister null test: {:?}", result); | ||
|
||
|
||
|
||
// 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(Some(efi_reset_fn)); | ||
info!("ResetNotification Protocol register efi_reset_fn test: {:?}", result); | ||
|
||
let result = reset_notif_proto.unregister_reset_notify(Some(efi_reset_fn)); | ||
info!("ResetNotification Protocol unregister efi_reset_fn test: {:?}", result); | ||
} | ||
Err(err) => { | ||
warn!("Failed to open ResetNotification Protocol: {:?}", err); | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# uefi - [Unreleased] | ||
|
||
## Added | ||
- Added `ResetNotification` protocol. | ||
|
||
## Added | ||
- Added `Timestamp` protocol. | ||
|
||
|
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.