[][src]Struct linux_loader::configurator::BootParams

pub struct BootParams {
    pub header: Vec<u8>,
    pub header_start: GuestAddress,
    pub sections: Option<Vec<u8>>,
    pub sections_start: Option<GuestAddress>,
    pub modules: Option<Vec<u8>>,
    pub modules_start: Option<GuestAddress>,
}

Boot parameters to be written in guest memory.

Fields

header: Vec<u8>

"Header section", always written in guest memory irrespective of boot protocol.

header_start: GuestAddress

Header section address.

sections: Option<Vec<u8>>

Optional sections containing boot configurations (e.g. E820 map).

sections_start: Option<GuestAddress>

Sections starting address.

modules: Option<Vec<u8>>

Optional modules specified at boot configuration time.

modules_start: Option<GuestAddress>

Modules starting address.

Implementations

impl BootParams[src]

pub fn new<T: ByteValued>(header: &T, header_addr: GuestAddress) -> Self[src]

Creates a new BootParams struct with the specified header.

Arguments

  • header - ByteValued representation of mandatory boot parameters.
  • header_addr - address in guest memory where header will be written.

Examples

let boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));

pub fn set_sections<T: ByteValued>(
    &mut self,
    sections: &[T],
    sections_addr: GuestAddress
)
[src]

Sets or overwrites the boot sections and associated memory address.

Unused on aarch64 and for the Linux boot protocol. For the PVH boot protocol, the sections specify the memory map table in hvm_memmap_table_entry structs.

Arguments

  • sections - vector of ByteValued boot configurations.
  • sections_addr - address where the sections will be written in guest memory.

Examples

let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let mut sections: Vec<Section> = vec![Section::default()];
boot_params.set_sections(sections.as_slice(), GuestAddress(0x2000));
// Another call overwrites the sections.
sections.clear();
boot_params.set_sections(sections.as_slice(), GuestAddress(0x3000));
assert_eq!(boot_params.sections.unwrap().len(), 0);
assert_eq!(boot_params.sections_start.unwrap(), GuestAddress(0x3000));

pub fn add_section<T: ByteValued>(
    &mut self,
    section: &T,
    section_addr: Option<GuestAddress>
) -> Result<GuestAddress>
[src]

Adds a boot section at the specified address (if specified and valid), or appends it.

It's up to the caller to ensure that the section will not overlap with existing content or leave a gap past the current sections in the list.

Arguments

  • section - ByteValued boot section element.
  • section_addr - optional address for the section in guest memory.

Returns

Starting address of the section in guest memory, or an error.

Examples

let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let section = Section::default();
// Sections start address needs to be configured first.
assert!(boot_params.add_section::<Section>(&section, None).is_err());
let sections_start = GuestAddress(0x2000);
assert!(boot_params.add_section::<Section>(
    &section, Some(sections_start)
).is_ok());
// It can be overwritten...
assert_eq!(boot_params.add_section::<Section>(
    &section,
    Some(sections_start)
).unwrap(), sections_start);
// But only if the address is valid.
assert!(boot_params.add_section::<Section>(
    &section,
    Some(sections_start.unchecked_sub(0x100))
).is_err());
// Or appended...
assert_eq!(
    boot_params.add_section::<Section>(&section, None).unwrap(),
    sections_start.unchecked_add(size_of::<Section>() as u64)
);

pub fn set_modules<T: ByteValued>(
    &mut self,
    modules: &[T],
    modules_addr: GuestAddress
)
[src]

Sets or overwrites the boot modules and associated memory address.

Unused on aarch64 and for the Linux boot protocol. For the PVH boot protocol, the modules are specified in hvm_modlist_entry structs.

Arguments

  • modules - vector of ByteValued boot configurations.
  • modules_addr - address where the modules will be written in guest memory.

Examples

let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let mut modules: Vec<Module> = vec![Module::default()];
boot_params.set_modules(modules.as_slice(), GuestAddress(0x2000));
// Another call overwrites the sections.
modules.clear();
boot_params.set_modules(modules.as_slice(), GuestAddress(0x3000));
assert_eq!(boot_params.modules.unwrap().len(), 0);
assert_eq!(boot_params.modules_start.unwrap(), GuestAddress(0x3000));

pub fn add_module<T: ByteValued>(
    &mut self,
    module: &T,
    module_addr: Option<GuestAddress>
) -> Result<GuestAddress>
[src]

Adds a boot module at the specified address (if specified and valid), or appends it.

It's up to the caller to ensure that the module will not overlap with existing content or leave a gap past the current modules in the list.

Arguments

  • module - ByteValued boot module element.
  • module_addr - optional address for the module in guest memory.

Returns

Starting address of the module in guest memory, or an error.

Examples

let mut boot_params = BootParams::new(&Header::default(), GuestAddress(0x1000));
let module = Module::default();
// Modules start address needs to be configured first.
assert!(boot_params.add_module::<Module>(&module, None).is_err());
let modules_start = GuestAddress(0x2000);
assert!(boot_params.add_module::<Module>(
    &module, Some(modules_start)
).is_ok());
// It can be overwritten...
assert_eq!(boot_params.add_module::<Module>(
    &module,
    Some(modules_start)
).unwrap(), modules_start);
// But only if the address is valid.
assert!(boot_params.add_module::<Module>(
    &module,
    Some(modules_start.unchecked_sub(0x100))
).is_err());
// Or appended...
assert_eq!(
    boot_params.add_module::<Module>(&module, None).unwrap(),
    modules_start.unchecked_add(size_of::<Module>() as u64)
);

Trait Implementations

impl Clone for BootParams[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.