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
impl BootServices
Sourcepub fn signature(&self) -> Signature
pub fn signature(&self) -> Signature
Returns the table signature. Must match Signature::BOOT_SERVICES.
Sourcepub fn allocate_pool(
&self,
memory_type: MemoryType,
size: usize,
) -> Result<*mut c_void>
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())
Sourcepub unsafe fn free_pool(&self, buffer: *const c_void) -> Result
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
Sourcepub unsafe fn free_pages(&self, memory: PhysicalAddress, pages: usize) -> Result
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.
Sourcepub fn allocate_max_address_pages(
&self,
memory_type: MemoryType,
pages: usize,
max_address: PhysicalAddress,
) -> Result<PhysicalAddress>
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.
Sourcepub fn allocate_pages_at_address(
&self,
memory_type: MemoryType,
pages: usize,
address: PhysicalAddress,
) -> Result
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.)
Sourcepub fn allocate_any_pages(
&self,
memory_type: MemoryType,
pages: usize,
) -> Result<PhysicalAddress>
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.)
Sourcepub fn open_protocol<P: HasProtocol>(
&self,
handle: &Handle,
agent: &Handle,
) -> Result<Protocol<P>>
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())
Sourcepub fn locate_protocol<P: HasProtocol>(&self) -> Result<Protocol<P>>
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())
Sourcepub fn close_protocol<P: HasProtocol>(
&self,
handle: &Handle,
agent: &Handle,
) -> Result
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())
Sourcepub fn load_image(
&self,
parent_image_handle: Handle,
image: &[u8],
) -> Result<Handle>
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.
Sourcepub fn start_image(&self, image_handle: Handle) -> Result
pub fn start_image(&self, image_handle: Handle) -> Result
Transfers control to a loaded image. (UEFI specification §7.4.2: EFI_BOOT_SERVICES.StartImage())
Sourcepub fn get_memory_map(&self) -> Result<MemoryMap>
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())
Sourcepub unsafe fn exit_boot_services(
&self,
image_handle: Handle,
map_key: usize,
) -> Result
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_handlemust be the handle passed toefi_main.map_keymust have been obtained fromget_memory_mapwith no intervening boot-services calls (including allocations) between that call and this one. Any such call invalidates the key and this function will returnEFI_INVALID_PARAMETER; retry the wholeget_memory_map+exit_boot_servicessequence in that case.- On success, all boot services (including the global allocator) are permanently
unavailable. The caller must not use any
BootServicesreference,Box,Vec, or other heap-backed type after a successful call.
Sourcepub fn wait_for_event(&self, events: &[Event]) -> Result<usize>
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())