Skip to main content

Rom

Struct Rom 

Source
pub struct Rom<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Rom<'a>

Source

pub fn new(data: &'a [u8]) -> Result<Rom<'_>, String>

Examples found in repository?
examples/report_regions.rs (line 18)
7fn main() {
8    let file = if let Some(file) = env::args().nth(1) {
9        file
10    } else {
11        eprintln!("used_regions <file>");
12        process::exit(1);
13    };
14
15    let data = fs::read(file).unwrap();
16
17    // Get the Flash Descriptor Region Section
18    let flash_region = Rom::new(&data).unwrap().flash_region().unwrap();
19
20    // Determine a regions base and limit addresses from the Flash
21    // Region Record that corresponds to it.
22    let region_area = |flreg: u32| -> (u32, u32) {
23        let base = (flreg & 0x7FFF) << 12;
24        let limit = ((flreg & (0x7FFF << 16)) >> 4) | 0xFFF;
25        (base, limit)
26    };
27
28    // Print a regions index and name, along with it's base and limit
29    // addresses. Explicitly mark unused regions as such.
30    let print_region_info = |region: RegionKind| {
31        let reg = flash_region.data[region as usize];
32        let (base, limit) = region_area(reg);
33        let unused = if (base == 0x07FF_F000) && (limit == 0xFFF) {
34            " (unused)"
35        } else {
36            ""
37        };
38        println!("  {}: {}", region as usize, region);
39        println!("      ({:#010X} - {:#010X}){}", base, limit, unused);
40    };
41
42    println!("Flash Regions");
43    print_region_info(RegionKind::Descriptor);
44    print_region_info(RegionKind::Bios);
45    print_region_info(RegionKind::ManagementEngine);
46    print_region_info(RegionKind::Ethernet);
47    print_region_info(RegionKind::PlatformData);
48    print_region_info(RegionKind::EmbeddedController);
49}
Source

pub fn data(&self) -> &'a [u8]

Source

pub fn flash_descriptor(&self) -> &'a Descriptor

Source

pub fn flash_region(&self) -> Result<&'a Region, String>

Examples found in repository?
examples/report_regions.rs (line 18)
7fn main() {
8    let file = if let Some(file) = env::args().nth(1) {
9        file
10    } else {
11        eprintln!("used_regions <file>");
12        process::exit(1);
13    };
14
15    let data = fs::read(file).unwrap();
16
17    // Get the Flash Descriptor Region Section
18    let flash_region = Rom::new(&data).unwrap().flash_region().unwrap();
19
20    // Determine a regions base and limit addresses from the Flash
21    // Region Record that corresponds to it.
22    let region_area = |flreg: u32| -> (u32, u32) {
23        let base = (flreg & 0x7FFF) << 12;
24        let limit = ((flreg & (0x7FFF << 16)) >> 4) | 0xFFF;
25        (base, limit)
26    };
27
28    // Print a regions index and name, along with it's base and limit
29    // addresses. Explicitly mark unused regions as such.
30    let print_region_info = |region: RegionKind| {
31        let reg = flash_region.data[region as usize];
32        let (base, limit) = region_area(reg);
33        let unused = if (base == 0x07FF_F000) && (limit == 0xFFF) {
34            " (unused)"
35        } else {
36            ""
37        };
38        println!("  {}: {}", region as usize, region);
39        println!("      ({:#010X} - {:#010X}){}", base, limit, unused);
40    };
41
42    println!("Flash Regions");
43    print_region_info(RegionKind::Descriptor);
44    print_region_info(RegionKind::Bios);
45    print_region_info(RegionKind::ManagementEngine);
46    print_region_info(RegionKind::Ethernet);
47    print_region_info(RegionKind::PlatformData);
48    print_region_info(RegionKind::EmbeddedController);
49}
Source

pub fn flash_pchstrap(&self) -> Result<&'a PchStrap, String>

Source

pub fn high_assurance_platform(&self) -> Result<bool, String>

Source

pub fn get_region_base_limit( &self, kind: RegionKind, ) -> Result<Option<(usize, usize)>, String>

Source

pub fn get_region(&self, kind: RegionKind) -> Result<Option<&'a [u8]>, String>

Source

pub fn bios(&self) -> Result<Option<Bios<'a>>, String>

Source

pub fn me(&self) -> Result<Option<Me<'a>>, String>

Auto Trait Implementations§

§

impl<'a> Freeze for Rom<'a>

§

impl<'a> RefUnwindSafe for Rom<'a>

§

impl<'a> Send for Rom<'a>

§

impl<'a> Sync for Rom<'a>

§

impl<'a> Unpin for Rom<'a>

§

impl<'a> UnsafeUnpin for Rom<'a>

§

impl<'a> UnwindSafe for Rom<'a>

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.