tock_tbf::types

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

Source§

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

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.