Struct tartan_uefi::BootServices
source · #[repr(C)]pub struct BootServices {
pub header: TableHeader,
pub free_pages: unsafe extern "C" fn(physical_address: u64, page_count: usize) -> Status,
pub allocate_pool: unsafe extern "C" fn(pool_type: MemoryType, size: usize, buffer: *mut *mut c_void) -> Status,
pub free_pool: unsafe extern "C" fn(buffer: *mut c_void) -> Status,
pub handle_protocol: unsafe extern "C" fn(handle: Handle, protocol: &GUID, interface: *mut *const c_void) -> Status,
/* private fields */
}
Fields§
§header: TableHeader
§free_pages: unsafe extern "C" fn(physical_address: u64, page_count: usize) -> Status
§allocate_pool: unsafe extern "C" fn(pool_type: MemoryType, size: usize, buffer: *mut *mut c_void) -> Status
§free_pool: unsafe extern "C" fn(buffer: *mut c_void) -> Status
§handle_protocol: unsafe extern "C" fn(handle: Handle, protocol: &GUID, interface: *mut *const c_void) -> Status
Implementations§
source§impl BootServices
impl BootServices
sourcepub fn allocate_pages(
&self,
allocate_type: AllocateType,
memory_type: MemoryType,
page_count: usize,
reference_address: Option<u64>,
) -> Result<u64, Status>
pub fn allocate_pages( &self, allocate_type: AllocateType, memory_type: MemoryType, page_count: usize, reference_address: Option<u64>, ) -> Result<u64, Status>
Allocate a number of pages of a given type of memory, optionally constraining its location.
Pages are 4KB (PAGE_SIZE
) on all platforms.
The meaning of reference_address
depends on allocate_type
:
AnyAddress
: Search for a block of pages anywhere in memory.reference_address
is ignored, and should beNone
.MaxAddress
: Search for a block of pages below the given address.ExactAddress
: Reserve the block of pages starting atreference_address
.
§Errors
This function will return:
Status::OutOfResources
if there was not enough memory available with the specified constraints.Status::InvalidParameter
if the memory type is unsupported.Status::NotFound
if the requested memory location is out of bounds of physical memory.
sourcepub fn get_memory_map(&self) -> MemoryMap
pub fn get_memory_map(&self) -> MemoryMap
Get a map representing the status of all available memory.
§Panics
Panics if the firmware does not behave according to the spec.
sourcepub fn get_protocol<T: Protocol>(
&self,
handle: Handle,
agent_handle: Handle,
) -> Result<&T, Status>
pub fn get_protocol<T: Protocol>( &self, handle: Handle, agent_handle: Handle, ) -> Result<&T, Status>
Get the implementation of a protocol offered by the given handle
.
For UEFI applications, agent_handle
is the application’s image handle. This
method does not offer all the options required by UEFI drivers.
§Errors
Fails if handle
is not valid, or it does not implement the specified protocol.
§Panics
Panics if the firmware does not behave according to the spec.
sourcepub unsafe fn exit_boot_services(
&self,
image_handle: Handle,
memory_map_key: usize,
) -> Result
pub unsafe fn exit_boot_services( &self, image_handle: Handle, memory_map_key: usize, ) -> Result
Signal to UEFI that the OS is now taking over.
If this function exits successfully, the OS is now in charge of memory management,
and it is no longer safe to call any functions on BootServices
.
In order to ensure that the OS has an accurate picture of the system, the caller
must pass the key
from a prior call to
BootServices::get_memory_map
. If it does not match the latest value, this
function returns with an error and the caller will have to fetch a new map before
trying again.
§Safety
If this function exits successfully, then this object is no longer valid. The
pointer to this table should be removed from the SystemTable
and any other
copies should be deleted.
If the function exits with an error, then it is only safe to call memory services
like allocate_pages
and
get_memory_map
. Any other boot services may have been
unloaded already.
§Errors
Will fail with Status::InvalidParameter
if the memory_map_key
does not match
the latest value.