Struct MagicHeader

Source
pub struct MagicHeader {
Show 13 fields pub magic: [u8; 8], pub kernel_size: u32, pub kernel_load_address: u32, pub ramdisk_size: u32, pub ramdisk_load_address: u32, pub second_size: u32, pub second_load_address: u32, pub device_tree_size: u32, pub kernel_tags_address: u32, pub page_size: u32, pub product_name: [u8; 24], pub boot_arguments: [[u8; 32]; 16], pub unique_id: [u8; 32], /* private fields */
}
Expand description

Contains a magic header.

Fields§

§magic: [u8; 8]

Header magic. Used to make sure this is in fact a header.

§kernel_size: u32

Ramdisk size, in bytes.

§kernel_load_address: u32

Address the ramdisk should be loaded to.

§ramdisk_size: u32

Ramdisk size, in bytes.

§ramdisk_load_address: u32

Address the ramdisk should be loaded to.

§second_size: u32

Size of an optional second file.

§second_load_address: u32

Address the optional second file should be loaded to.

§device_tree_size: u32

The size of the device tree, in bytes.

§kernel_tags_address: u32

Physical address of the kernel tags.

§page_size: u32

The page size.

§product_name: [u8; 24]

Name of the product. This is a null-terminated ASCII string.

§boot_arguments: [[u8; 32]; 16]

Arguments to pass to the kernel during boot. This is a nested array, as rust does not allow us to have arrays larger than 32 in size.

§unique_id: [u8; 32]

Used to uniquely identify boot images.

Implementations§

Source§

impl MagicHeader

Source

pub fn read_from<R: ReadBytesExt>( source: &mut R, check_magic: bool, ) -> Result<Self, MagicHeaderParseError>

Reads a magic header from the supplied source.

Source

pub fn section_size(&self, section: Section) -> u64

Returns the size of a section, in bytes.

Source

pub fn section_start(&self, section: Section) -> Result<u64, LocateSectionError>

Returns the start location of a section, in bytes.

Do note that this function can fail because it cannot find a section other than the one that was requested. Sections depend on the other sections for their locations.

Source

pub fn section_location( &self, section: Section, ) -> Result<(u64, u64), LocateSectionError>

Returns the start and the end location of a section, in bytes.

Do note that this function can fail because it cannot find a section other than the one that was requested. Sections depend on the other sections for their locations.

Source

pub fn read_section_from<R: Read + Seek>( &self, source: &mut R, section: Section, ) -> Result<Vec<u8>, ReadSectionError>

Reads a section from the given readable resource.

Do note that this function can fail because it cannot find a section other than the one that was requested. Sections depend on the other sections for their locations.

Source

pub fn sections(&self) -> Vec<Section>

Returns the sections in this boot image, in order. Zero-size sections are omitted.

Trait Implementations§

Source§

impl Debug for MagicHeader

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.