amebazii::types::image::pt

Struct PartTab

Source
pub struct PartTab {
    pub rma_w_state: u8,
    pub rma_ov_state: u8,
    pub eFWV: u8,
    pub fw1_idx: u8,
    pub fw2_idx: u8,
    pub ota_trap: TrapConfig,
    pub mp_trap: TrapConfig,
    pub key_exp_op: KeyExportOp,
    /* private fields */
}
Expand description

§===================================================================================== Partition Table (PartTab)

The PartTab struct represents a partition table for the flash, containing various metadata and configuration related to the partitioning, as well as firmware-specific data such as the state of firmware updates, trap configurations, and key export operations.

§Layout:

         +-----------------+------------------+---+----------+---------+-------------+-------------+---+---+---+-------+-------+-------+------+----+----------------+
         | 0               | 1                | 2 | 3        | 4       | 5           | 6           | 7 | 8 | 9 | 10    | 11    | 12    | 13   | 14 | 15             |
+========+=================+==================+===+==========+=========+=============+=============+===+===+===+=======+=======+=======+======+====+================+
| 0x00   | rma_w_state: u8 | rma_ov_state: u8 |   | eFWV: u8 | num: u8 | fw1_idx: u8 | fw2_idx: u8 |           | ota_trap: u16 | mp_trap: u16 |    | key_exp_op: u8 |
+--------+-----------------+------------------+---+----------+---------+-------------+-------------+-----------+---------------+--------------+----+----------------+
| 0x10   |                   user_len: u32                   |                                         user_ext: bytes[12]                                          |
+--------+---------------------------------------------------+------------------------------------------------------------------------------------------------------+
| 0x20   |                                                                  records: Record * num                                                                   |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x30   |                                                                                                                                                          |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x40   |                                                                                                                                                          |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x50   |                                                                                                                                                          |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x60   |                                                                user_bin: bytes[user_len]                                                                 |
+--------+----------------------------------------------------------------------------------------------------------------------------------------------------------+

Fields§

§rma_w_state: u8§rma_ov_state: u8§eFWV: u8§fw1_idx: u8§fw2_idx: u8§ota_trap: TrapConfig§mp_trap: TrapConfig§key_exp_op: KeyExportOp

Implementations§

Source§

impl PartTab

Source

pub fn get_records(&self) -> &[Record]

Returns the records in the partition table.

§Returns:
  • A slice of Record structs.
Source

pub fn get_user_bin(&self) -> &[u8]

Returns the user binary data.

This method provides access to the raw user binary data in the partition table.

§Returns:
  • A slice of bytes representing the user binary data.
Source

pub fn get_user_ext(&self) -> &[u8]

Returns the user extension data (12 bytes).

This method provides access to the 12-byte user extension field, which can be used for storing additional metadata related to the partition table.

§Returns:
  • A reference to the 12-byte array representing the user extension data.
Source

pub fn set_user_bin(&mut self, user_bin: &[u8])

Sets the user binary data in the partition table.

§Arguments:
  • user_bin: A slice of bytes representing the new user binary data to store.
Source

pub fn set_user_ext(&mut self, user_ext: &[u8])

Sets the user extension data in the partition table.

§Arguments:
  • user_ext: A slice of bytes representing the new user extension data (12 bytes).
Source

pub fn add_record(&mut self, record: Record)

Adds a new partition record to the partition table.

§Arguments:
  • record: The Record struct that defines the new partition entry to add.
Source

pub fn new_record(&mut self, part_type: PartitionType) -> &mut Record

Creates and returns a new record for a specific partition type.

§Arguments:
  • part_type: The PartitionType enum value representing the type of the new record.
§Returns:
  • A mutable reference to the newly created record.
Source

pub fn get_record(&self, part_type: PartitionType) -> Option<&Record>

Returns the record for a specific partition type.

§Arguments:
  • part_type: The PartitionType enum value representing the partition type.
§Returns:
  • Some(&Record) if the record for the given partition type is found.
  • None if the record for the given partition type is not found.
Source

pub fn get_record_mut( &mut self, part_type: PartitionType, ) -> Option<&mut Record>

Returns the record for a specific partition type.

§Arguments:
  • part_type: The PartitionType enum value representing the partition type.
§Returns:
  • Some(&mut Record) if the record for the given partition type is found.
  • None if the record for the given partition type is not found.
Source

pub fn rem_record(&mut self, part_type: PartitionType)

Removes a partition record from the partition table.

§Arguments:
  • part_type: The PartitionType enum value representing the partition type to remove.
Source

pub fn has_record(&self, part_type: PartitionType) -> bool

Checks if a record exists for a specific partition type.

§Arguments:
  • part_type: The PartitionType enum value representing the partition type to check.
§Returns:
  • true if a record exists for the given partition type.
  • false if no record exists for the given partition type.

Trait Implementations§

Source§

impl Debug for PartTab

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PartTab

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl FromStream for PartTab

Source§

fn read_from<R>(&mut self, reader: &mut R) -> Result<(), Error>
where R: Read + Seek,

Parses a PartTab from a binary stream.

§Returns:
  • Ok(()) if the PartTab was successfully parsed.
  • Err(Error) if there was an issue reading from the stream.
Source§

impl ToStream for PartTab

Source§

fn write_to<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + Seek,

Writes a PartTab to a binary stream.

§Arguments:
  • writer: A mutable reference to a writer that implements std::io::Write.
Source§

impl TryInto<PartTab> for PartitionTableCfg

Source§

fn try_into(self) -> Result<PartTab, Self::Error>

Converts a PartitionTableCfg instance into a PartTab instance.

§Returns:
  • Ok(PartTab): A PartTab instance with the appropriate values set.
  • Err(Error): An error if something goes wrong, such as if the user extension file does not exist or cannot be read.
Source§

type Error = Error

The type returned in the event of a conversion error.

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.