#[repr(packed(1))]pub struct Fmap {
pub signature: [u8; 8],
pub ver_major: u8,
pub ver_minor: u8,
pub base: u64,
pub size: u32,
pub name: [u8; 32],
pub nareas: u16,
}Fields§
§signature: [u8; 8]§ver_major: u8§ver_minor: u8§base: u64§size: u32§name: [u8; 32]§nareas: u16Implementations§
Source§impl Fmap
impl Fmap
Sourcepub fn area(&self, i: u16) -> &FmapArea
pub fn area(&self, i: u16) -> &FmapArea
Examples found in repository?
examples/file.rs (line 20)
4fn inner(path: &str) -> io::Result<()> {
5 let data = fs::read(path)?;
6 let rom = Rom::new(&data);
7
8 if let Some(fmap) = rom.fmap() {
9 let mut name = String::new();
10 for &b in fmap.name.iter() {
11 if b == 0 {
12 break;
13 }
14 name.push(b as char);
15 }
16
17 eprintln!(" {}", name);
18
19 for i in 0..fmap.nareas {
20 let area = fmap.area(i);
21
22 let mut name = String::new();
23 for &b in area.name.iter() {
24 if b == 0 {
25 break;
26 }
27 name.push(b as char);
28 }
29
30 eprintln!(" {}: {}", i, name);
31 }
32 }
33
34 if let Some(header) = rom.header() {
35 eprintln!(" CBFS");
36
37 let align = u32::from(header.align) as usize;
38 let mut offset = u32::from(header.offset) as usize;
39 while let Some(file) = rom.file(offset) {
40 let name_bytes = file.name();
41
42 let mut name = String::new();
43 for &b in name_bytes.iter() {
44 if b == 0 {
45 break;
46 }
47 name.push(b as char);
48 }
49
50 eprintln!(" {:#X}: {}", offset, name);
51
52 let file_offset = u32::from(file.offset) as usize;
53 let file_len = u32::from(file.len) as usize;
54 offset = ((offset + file_offset + file_len + align - 1) / align) * align;
55 }
56 } else {
57 eprintln!("coreboot header not found");
58 }
59
60 Ok(())
61}Trait Implementations§
Source§impl Plain for Fmap
impl Plain for Fmap
fn from_bytes(bytes: &[u8]) -> Result<&Self, Error>where
Self: Sized,
fn slice_from_bytes(bytes: &[u8]) -> Result<&[Self], Error>where
Self: Sized,
fn slice_from_bytes_len(bytes: &[u8], len: usize) -> Result<&[Self], Error>where
Self: Sized,
fn from_mut_bytes(bytes: &mut [u8]) -> Result<&mut Self, Error>where
Self: Sized,
fn slice_from_mut_bytes(bytes: &mut [u8]) -> Result<&mut [Self], Error>where
Self: Sized,
fn slice_from_mut_bytes_len(
bytes: &mut [u8],
len: usize,
) -> Result<&mut [Self], Error>where
Self: Sized,
fn copy_from_bytes(&mut self, bytes: &[u8]) -> Result<(), Error>
impl Copy for Fmap
Auto Trait Implementations§
impl Freeze for Fmap
impl RefUnwindSafe for Fmap
impl Send for Fmap
impl Sync for Fmap
impl Unpin for Fmap
impl UnwindSafe for Fmap
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