Skip to content

Move EventType to uefi-raw #833

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 1 commit into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions uefi-raw/src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@
use crate::{PhysicalAddress, VirtualAddress};
use bitflags::bitflags;

bitflags! {
/// Flags describing the type of an UEFI event and its attributes.
#[repr(transparent)]
pub struct EventType: u32 {
/// The event is a timer event and may be passed to `BootServices::set_timer()`
/// Note that timers only function during boot services time.
const TIMER = 0x8000_0000;

/// The event is allocated from runtime memory.
/// This must be done if the event is to be signaled after ExitBootServices.
const RUNTIME = 0x4000_0000;

/// Calling wait_for_event or check_event will enqueue the notification
/// function if the event is not already in the signaled state.
/// Mutually exclusive with `NOTIFY_SIGNAL`.
const NOTIFY_WAIT = 0x0000_0100;

/// The notification function will be enqueued when the event is signaled
/// Mutually exclusive with `NOTIFY_WAIT`.
const NOTIFY_SIGNAL = 0x0000_0200;

/// The event will be signaled at ExitBootServices time.
/// This event type should not be combined with any other.
/// Its notification function must follow some special rules:
/// - Cannot use memory allocation services, directly or indirectly
/// - Cannot depend on timer events, since those will be deactivated
const SIGNAL_EXIT_BOOT_SERVICES = 0x0000_0201;

/// The event will be notified when SetVirtualAddressMap is performed.
/// This event type should not be combined with any other.
const SIGNAL_VIRTUAL_ADDRESS_CHANGE = 0x6000_0202;
}
}

newtype_enum! {
/// Interface type of a protocol interface.
pub enum InterfaceType: u32 => {
Expand Down
38 changes: 1 addition & 37 deletions uefi/src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::data_types::{Align, PhysicalAddress};
use crate::proto::device_path::{DevicePath, FfiDevicePath};
use crate::proto::{Protocol, ProtocolPointer};
use crate::{Char16, Event, Guid, Handle, Result, Status, StatusExt};
use bitflags::bitflags;
use core::cell::UnsafeCell;
use core::ffi::c_void;
use core::fmt::{Debug, Formatter};
Expand All @@ -21,7 +20,7 @@ use {
};

pub use uefi_raw::table::boot::{
InterfaceType, MemoryAttribute, MemoryDescriptor, MemoryType, Tpl,
EventType, InterfaceType, MemoryAttribute, MemoryDescriptor, MemoryType, Tpl,
};

// TODO: this similar to `SyncUnsafeCell`. Once that is stabilized we
Expand Down Expand Up @@ -2039,41 +2038,6 @@ impl<'guid> SearchType<'guid> {
}
}

bitflags! {
/// Flags describing the type of an UEFI event and its attributes.
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
pub struct EventType: u32 {
/// The event is a timer event and may be passed to `BootServices::set_timer()`
/// Note that timers only function during boot services time.
const TIMER = 0x8000_0000;

/// The event is allocated from runtime memory.
/// This must be done if the event is to be signaled after ExitBootServices.
const RUNTIME = 0x4000_0000;

/// Calling wait_for_event or check_event will enqueue the notification
/// function if the event is not already in the signaled state.
/// Mutually exclusive with `NOTIFY_SIGNAL`.
const NOTIFY_WAIT = 0x0000_0100;

/// The notification function will be enqueued when the event is signaled
/// Mutually exclusive with `NOTIFY_WAIT`.
const NOTIFY_SIGNAL = 0x0000_0200;

/// The event will be signaled at ExitBootServices time.
/// This event type should not be combined with any other.
/// Its notification function must follow some special rules:
/// - Cannot use memory allocation services, directly or indirectly
/// - Cannot depend on timer events, since those will be deactivated
const SIGNAL_EXIT_BOOT_SERVICES = 0x0000_0201;

/// The event will be notified when SetVirtualAddressMap is performed.
/// This event type should not be combined with any other.
const SIGNAL_VIRTUAL_ADDRESS_CHANGE = 0x6000_0202;
}
}

/// Raw event notification function
type EventNotifyFn = unsafe extern "efiapi" fn(event: Event, context: Option<NonNull<c_void>>);

Expand Down