pub struct StartInfoReader<'a, M> { /* private fields */ }Available on crate feature
reader only.Expand description
A start info reader.
This struct allows reading the data that is provided as physical addresses via the start info.
For this, a way of creating pointers from physical addresses is needed
(MemMap), for example IdentityMap.
§Examples
use pvh::start_info::reader::StartInfoReader;
let start_info = unsafe { StartInfoReader::from_paddr_identity(start_info_paddr).unwrap() };
println!("Start info:");
println!("{start_info:#?}");Implementations§
Source§impl StartInfoReader<'_, IdentityMap>
impl StartInfoReader<'_, IdentityMap>
Sourcepub unsafe fn from_paddr_identity(paddr: u32) -> Option<Self>
pub unsafe fn from_paddr_identity(paddr: u32) -> Option<Self>
Creates a start info reader from a physical address that relies on identity-mapping.
This is a convenience method for
from_paddr(IdentityMap).
§Safety
- The structure at
paddrmust be valid. Specifically, the physical addresses in the structure’s fields must be valid. IdentityMapmust be valid for the lifetime of the start info.
Examples found in repository?
examples/print/main.rs (line 32)
29unsafe extern "C" fn rust_start(start_info_paddr: u32) -> ! {
30 // SAFETY: The caller upholds that `start_info_paddr` is valid.
31 // We have configured the machine to use identity-mapping.
32 let start_info = unsafe { StartInfoReader::from_paddr_identity(start_info_paddr).unwrap() };
33
34 println!("Raw start info:\n\n{:#x?}\n", start_info.raw());
35
36 println!("Start info reader:\n\n{start_info:?}\n");
37 println!("Alternative start info reader:\n\n{start_info:#?}\n");
38
39 for module in start_info.modlist() {
40 let bytes = module.as_slice();
41 if let Ok(s) = str::from_utf8(bytes) {
42 println!("Module: {s:?}\n");
43 } else {
44 println!("Module: {bytes:?}\n");
45 }
46 }
47
48 println!("Done!");
49
50 loop {
51 hint::spin_loop();
52 }
53}Source§impl<'a, M: MemMap> StartInfoReader<'a, M>
impl<'a, M: MemMap> StartInfoReader<'a, M>
Sourcepub unsafe fn from_paddr(paddr: u32, mem_map: M) -> Option<Self>
pub unsafe fn from_paddr(paddr: u32, mem_map: M) -> Option<Self>
Creates a start info reader from a physical address and a memory map.
from_paddr_identity is convenience method for identity-mappings.
§Safety
- The structure at
paddrmust be valid. Specifically, the physical addresses in the structure’s fields must be valid. mem_mapmust be valid for the lifetime of the start info. For details, seeMemMap.
Sourcepub fn raw(&self) -> &'a StartInfo
pub fn raw(&self) -> &'a StartInfo
Returns the underlying raw start info.
Examples found in repository?
examples/print/main.rs (line 34)
29unsafe extern "C" fn rust_start(start_info_paddr: u32) -> ! {
30 // SAFETY: The caller upholds that `start_info_paddr` is valid.
31 // We have configured the machine to use identity-mapping.
32 let start_info = unsafe { StartInfoReader::from_paddr_identity(start_info_paddr).unwrap() };
33
34 println!("Raw start info:\n\n{:#x?}\n", start_info.raw());
35
36 println!("Start info reader:\n\n{start_info:?}\n");
37 println!("Alternative start info reader:\n\n{start_info:#?}\n");
38
39 for module in start_info.modlist() {
40 let bytes = module.as_slice();
41 if let Ok(s) = str::from_utf8(bytes) {
42 println!("Module: {s:?}\n");
43 } else {
44 println!("Module: {bytes:?}\n");
45 }
46 }
47
48 println!("Done!");
49
50 loop {
51 hint::spin_loop();
52 }
53}Sourcepub fn modlist(&self) -> impl Iterator<Item = ModlistEntryReader<'a, &M>>
pub fn modlist(&self) -> impl Iterator<Item = ModlistEntryReader<'a, &M>>
Returns an iterator of module list entry readers.
Examples found in repository?
examples/print/main.rs (line 39)
29unsafe extern "C" fn rust_start(start_info_paddr: u32) -> ! {
30 // SAFETY: The caller upholds that `start_info_paddr` is valid.
31 // We have configured the machine to use identity-mapping.
32 let start_info = unsafe { StartInfoReader::from_paddr_identity(start_info_paddr).unwrap() };
33
34 println!("Raw start info:\n\n{:#x?}\n", start_info.raw());
35
36 println!("Start info reader:\n\n{start_info:?}\n");
37 println!("Alternative start info reader:\n\n{start_info:#?}\n");
38
39 for module in start_info.modlist() {
40 let bytes = module.as_slice();
41 if let Ok(s) = str::from_utf8(bytes) {
42 println!("Module: {s:?}\n");
43 } else {
44 println!("Module: {bytes:?}\n");
45 }
46 }
47
48 println!("Done!");
49
50 loop {
51 hint::spin_loop();
52 }
53}Sourcepub fn memmap(&self) -> &'a [MemmapTableEntry]
pub fn memmap(&self) -> &'a [MemmapTableEntry]
Returns the memory map.
Trait Implementations§
Auto Trait Implementations§
impl<'a, M> Freeze for StartInfoReader<'a, M>where
M: Freeze,
impl<'a, M> RefUnwindSafe for StartInfoReader<'a, M>where
M: RefUnwindSafe,
impl<'a, M> Send for StartInfoReader<'a, M>where
M: Send,
impl<'a, M> Sync for StartInfoReader<'a, M>where
M: Sync,
impl<'a, M> Unpin for StartInfoReader<'a, M>where
M: Unpin,
impl<'a, M> UnsafeUnpin for StartInfoReader<'a, M>where
M: UnsafeUnpin,
impl<'a, M> UnwindSafe for StartInfoReader<'a, M>where
M: UnwindSafe,
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