pub struct Rom<'a> { /* private fields */ }Implementations§
Source§impl<'a> Rom<'a>
impl<'a> Rom<'a>
Sourcepub fn new(data: &'a [u8]) -> Result<Rom<'_>, String>
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}pub fn data(&self) -> &'a [u8]
pub fn flash_descriptor(&self) -> &'a Descriptor
Sourcepub fn flash_region(&self) -> Result<&'a Region, String>
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}pub fn flash_pchstrap(&self) -> Result<&'a PchStrap, String>
pub fn high_assurance_platform(&self) -> Result<bool, String>
pub fn get_region_base_limit( &self, kind: RegionKind, ) -> Result<Option<(usize, usize)>, String>
pub fn get_region(&self, kind: RegionKind) -> Result<Option<&'a [u8]>, String>
pub fn bios(&self) -> Result<Option<Bios<'a>>, String>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more