Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7668ee

Browse files
authored
Merge pull request#1295 from rust-osdev/bishop-check-event
boot: Add freestanding check_event
2 parentsc52c71e +1cf3284 commitc7668ee

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

‎uefi-test-runner/src/boot/misc.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn test(st: &SystemTable<Boot>) {
1717
info!("Testing timer...");
1818
test_timer(bt);
1919
info!("Testing events...");
20+
test_check_event_freestanding();
2021
test_event_callback(bt);
2122
test_callback_with_ctx(bt);
2223
info!("Testing watchdog...");
@@ -35,6 +36,18 @@ fn test_tpl() {
3536
let _guard =unsafe{ boot::raise_tpl(Tpl::NOTIFY)};
3637
}
3738

39+
fntest_check_event_freestanding(){
40+
extern"efiapi"fncallback(_event:Event,_ctx:Option<NonNull<c_void>>){
41+
info!("Callback triggered by check_event");
42+
}
43+
44+
let event =
45+
unsafe{ boot::create_event(EventType::NOTIFY_WAIT,Tpl::CALLBACK,Some(callback),None)}
46+
.unwrap();
47+
let is_signaled = boot::check_event(event).unwrap();
48+
assert!(!is_signaled);
49+
}
50+
3851
fntest_timer(bt:&BootServices){
3952
let timer_event =unsafe{ bt.create_event(EventType::TIMER,Tpl::APPLICATION,None,None)}
4053
.expect("Failed to create TIMER event");

‎uefi/src/boot.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,31 @@ pub unsafe fn create_event(
208208
)
209209
}
210210

211+
/// Checks to see if an event is signaled, without blocking execution to wait for it.
212+
///
213+
/// Returns `Ok(true)` if the event is in the signaled state or `Ok(false)`
214+
/// if the event is not in the signaled state.
215+
///
216+
/// # Errors
217+
///
218+
/// Note: Instead of returning [`Status::NOT_READY`] as listed in the UEFI
219+
/// Specification, this function will return `Ok(false)`.
220+
///
221+
/// * [`Status::INVALID_PARAMETER`]: `event` is of type [`NOTIFY_SIGNAL`].
222+
///
223+
/// [`NOTIFY_SIGNAL`]: EventType::NOTIFY_SIGNAL
224+
pubfncheck_event(event:Event) ->Result<bool>{
225+
let bt =boot_services_raw_panicking();
226+
let bt =unsafe{ bt.as_ref()};
227+
228+
let status =unsafe{(bt.check_event)(event.as_ptr())};
229+
match status{
230+
Status::SUCCESS =>Ok(true),
231+
Status::NOT_READY =>Ok(false),
232+
_ =>Err(status.into()),
233+
}
234+
}
235+
211236
/// Connect one or more drivers to a controller.
212237
///
213238
/// Usually one disconnects and then reconnects certain drivers

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp