Enum tock_tbf::types::TbfHeader

source ·
pub enum TbfHeader {
    TbfHeaderV2(TbfHeaderV2),
    Padding(TbfHeaderV2Base),
}
Expand description

Type that represents the fields of the Tock Binary Format header.

This specifies the locations of the different code and memory sections in the tock binary, as well as other information about the application. The kernel can also use this header to keep persistent state about the application.

Variants§

§

TbfHeaderV2(TbfHeaderV2)

§

Padding(TbfHeaderV2Base)

Implementations§

source§

impl TbfHeader

source

pub fn length(&self) -> u16

Return the length of the header.

source

pub fn is_app(&self) -> bool

Return whether this is an app or just padding between apps.

source

pub fn enabled(&self) -> bool

Return whether the application is enabled or not. Disabled applications are not started by the kernel.

source

pub fn get_minimum_app_ram_size(&self) -> u32

Add up all of the relevant fields in header version 1, or just used the app provided value in version 2 to get the total amount of RAM that is needed for this app.

source

pub fn get_protected_size(&self) -> u32

Get the number of bytes from the start of the app’s region in flash that is for kernel use only. The app cannot write this region.

source

pub fn get_app_start_offset(&self) -> u32

Get the start offset of the application binary from the beginning of the process binary (start of the TBF header). Only valid if this is an app.

source

pub fn get_init_function_offset(&self) -> u32

Get the offset from the beginning of the app’s flash region where the app should start executing.

source

pub fn get_package_name(&self) -> Option<&'static str>

Get the name of the app.

source

pub fn number_writeable_flash_regions(&self) -> usize

Get the number of flash regions this app has specified in its header.

source

pub fn get_writeable_flash_region(&self, index: usize) -> (usize, usize)

Get the offset and size of a given flash region.

source

pub fn get_fixed_address_ram(&self) -> Option<u32>

Get the address in RAM this process was specifically compiled for. If the process is position independent, return None.

source

pub fn get_fixed_address_flash(&self) -> Option<u32>

Get the address in flash this process was specifically compiled for. If the process is position independent, return None.

source

pub fn get_command_permissions( &self, driver_num: usize, offset: usize, ) -> CommandPermissions

Get the permissions for a specified driver and offset.

  • driver_num: The driver to lookup.
  • offset: The offset for the driver to find. An offset value of 1 will find a header with offset 1, so the allowed_commands will cover command numbers 64 to 127.

If permissions are found for the driver number, this function will return CommandPermissions::Mask. If there are permissions in the header but not for this driver the function will return CommandPermissions::NoPermsThisDriver. If the process does not have any permissions specified, return CommandPermissions::NoPermsAtAll.

source

pub fn get_storage_write_id(&self) -> Option<NonZeroU32>

Get the process write_id.

Returns None if a write_id is not included. This indicates the TBF does not have the ability to store new items.

source

pub fn get_storage_read_ids(&self) -> Option<(usize, [u32; 8])>

Get the number of valid read_ids and the read_ids. Returns None if a read_ids is not included.

source

pub fn get_storage_modify_ids(&self) -> Option<(usize, [u32; 8])>

Get the number of valid access_ids and the access_ids. Returns None if a access_ids is not included.

source

pub fn get_kernel_version(&self) -> Option<(u16, u16)>

Get the minimum compatible kernel version this process requires. Returns None if the kernel compatibility header is not included.

source

pub fn get_binary_end(&self) -> u32

Return the offset where the binary ends in the TBF or 0 if there is no binary. If there is a Main header the end offset is the size of the TBF, while if there is a Program header it can be smaller.

source

pub fn get_binary_version(&self) -> u32

Return the version number of the Userspace Binary in this TBF Object, or 0 if there is no binary or no version number.

source

pub fn get_fixed_short_id(&self) -> Option<NonZeroU32>

Return the fixed ShortId of the application if it was specified in the TBF header.

Trait Implementations§

source§

impl Debug for TbfHeader

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.