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

source

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 be None.
  • MaxAddress: Search for a block of pages below the given address.
  • ExactAddress: Reserve the block of pages starting at reference_address.
§Errors

This function will return:

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl Table for BootServices

source§

const SIGNATURE: u64 = 6_220_110_259_551_162_178u64

source§

const MIN_REVISION: Revision = Revision::V2_00

source§

fn header(&self) -> &TableHeader

source§

fn verify(&self)
where Self: Sized,

source§

fn verify_signature(&self)

source§

fn verify_revision(&self)

source§

fn verify_size(&self)
where Self: Sized,

source§

fn verify_crc32(&self)

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.