hvlite_core/worker/vm_loaders/
pcat.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use guestmem::GuestMemory;
use loader::importer::X86Register;
use thiserror::Error;
use vm_loader::Loader;
use vm_topology::memory::MemoryLayout;

#[derive(Debug, Error)]
pub enum Error {
    #[error("pcat loader error")]
    Loader(#[source] loader::pcat::Error),
}

/// Load the PCAT BIOS.
///
/// Since the BIOS is in ROM, this actually just returns the PCAT initial
/// registers.
#[cfg_attr(not(guest_arch = "x86_64"), expect(dead_code))]
pub fn load_pcat(gm: &GuestMemory, mem_layout: &MemoryLayout) -> Result<Vec<X86Register>, Error> {
    let mut loader = Loader::new(gm.clone(), mem_layout, hvdef::Vtl::Vtl0);
    loader::pcat::load(&mut loader, None, mem_layout.max_ram_below_4gb()).map_err(Error::Loader)?;
    Ok(loader.initial_regs())
}