Skip to main content

BootServices

Struct BootServices 

Source
pub struct BootServices { /* private fields */ }
Expand description

UEFI Boot Services Table. Contains function pointers for boot-time memory allocation, protocol management, image loading, and event services. (UEFI specification §4.4.1: EFI_BOOT_SERVICES)

Implementations§

Source§

impl BootServices

Source

pub fn signature(&self) -> Signature

Returns the table signature. Must match Signature::BOOT_SERVICES.

Source

pub fn allocate_pool( &self, memory_type: MemoryType, size: usize, ) -> Result<*mut c_void>

Allocates a pool of a particular type. Returns a pointer to the allocated buffer. (UEFI specification §7.2.4: EFI_BOOT_SERVICES.AllocatePool())

Source

pub unsafe fn free_pool(&self, buffer: *const c_void) -> Result

Frees allocated pool. (UEFI specification §7.2.5: EFI_BOOT_SERVICES.FreePool())

§Safety

The caller must ensure the pointer was allocated by allocate_pool

Source

pub unsafe fn free_pages(&self, memory: PhysicalAddress, pages: usize) -> Result

Frees allocated pages. (UEFI specification §7.2.2: EFI_BOOT_SERVICES.FreePages())

§Safety

memory must be a physical address obtained from allocate_any_pages or allocate_pages_at_address, and pages must match the count from that call.

Source

pub fn allocate_max_address_pages( &self, memory_type: MemoryType, pages: usize, max_address: PhysicalAddress, ) -> Result<PhysicalAddress>

Allocates pages at the highest available address at or below max_address. (UEFI specification §7.2.1: AllocatePages with AllocateMaxAddress.)

Use when a buffer must reside below a ceiling such as initrd_addr_max.

Source

pub fn allocate_pages_at_address( &self, memory_type: MemoryType, pages: usize, address: PhysicalAddress, ) -> Result

Allocates pages at a specific physical address. (UEFI specification §7.2.1: EFI_BOOT_SERVICES.AllocatePages() with AllocateAddress.)

Source

pub fn allocate_any_pages( &self, memory_type: MemoryType, pages: usize, ) -> Result<PhysicalAddress>

Allocates any available range of pages. Returns the physical address. (UEFI specification §7.2.1: EFI_BOOT_SERVICES.AllocatePages() with AllocateAnyPages.)

Source

pub fn open_protocol<P: HasProtocol>( &self, handle: &Handle, agent: &Handle, ) -> Result<Protocol<P>>

Opens a protocol interface on a handle. Returns a Protocol<P> that automatically closes on drop. (UEFI specification §7.3.9: EFI_BOOT_SERVICES.OpenProtocol())

Source

pub fn locate_protocol<P: HasProtocol>(&self) -> Result<Protocol<P>>

Finds the first handle that supports a protocol and returns its interface. (UEFI specification §7.3.16: EFI_BOOT_SERVICES.LocateProtocol())

Source

pub fn close_protocol<P: HasProtocol>( &self, handle: &Handle, agent: &Handle, ) -> Result

Closes a protocol interface previously opened via open_protocol. (UEFI specification §7.3.10: EFI_BOOT_SERVICES.CloseProtocol())

Source

pub fn load_image( &self, parent_image_handle: Handle, image: &[u8], ) -> Result<Handle>

Loads a UEFI image from a buffer and returns its handle. (UEFI specification §7.4.1: EFI_BOOT_SERVICES.LoadImage())

device_path is null; the firmware uses the memory-mapped device path. The firmware copies image, so the buffer may be dropped once this returns. Start the image with start_image.

Source

pub fn start_image(&self, image_handle: Handle) -> Result

Transfers control to a loaded image. (UEFI specification §7.4.2: EFI_BOOT_SERVICES.StartImage())

Source

pub fn get_memory_map(&self) -> Result<MemoryMap>

Returns the current boot services memory map and memory map key. (UEFI specification §7.2.3: EFI_BOOT_SERVICES.GetMemoryMap())

Source

pub unsafe fn exit_boot_services( &self, image_handle: Handle, map_key: usize, ) -> Result

Terminates all boot services. After this call, only runtime services and the memory map are available. (UEFI specification §7.4.6: EFI_BOOT_SERVICES.ExitBootServices())

§Safety
  • image_handle must be the handle passed to efi_main.
  • map_key must have been obtained from get_memory_map with no intervening boot-services calls (including allocations) between that call and this one. Any such call invalidates the key and this function will return EFI_INVALID_PARAMETER; retry the whole get_memory_map + exit_boot_services sequence in that case.
  • On success, all boot services (including the global allocator) are permanently unavailable. The caller must not use any BootServices reference, Box, Vec, or other heap-backed type after a successful call.
Source

pub fn wait_for_event(&self, events: &[Event]) -> Result<usize>

Blocks until one of the specified events is signaled. Returns the index of the signaled event. (UEFI specification §7.1.5: EFI_BOOT_SERVICES.WaitForEvent())

Source

pub fn stall(&self, microseconds: usize) -> Result

Stalls execution for the specified number of microseconds. (UEFI specification §7.5.2: EFI_BOOT_SERVICES.Stall())

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.