devices, vmm: Add legacy CMOS device

Based off of crosvm revision b5237bbcf074eb30cf368a138c0835081e747d71
add a CMOS device. This environments that can't use KVM clock to get the
current time (e.g. Windows and EFI.)

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2019-10-02 15:21:54 +01:00
parent 47367eb61b
commit 8ea4145f98
6 changed files with 139 additions and 2 deletions

View File

@@ -370,7 +370,22 @@ impl DeviceManager {
.io
.insert(i8042.clone(), 0x61, 0x4)
.map_err(DeviceManagerError::BusError)?;
#[cfg(feature = "cmos")]
{
use vm_memory::GuestMemory;
let mem_size = vm_info.memory.as_ref().read().unwrap().end_addr().0 + 1;
let mem_below_4g = std::cmp::min(arch::layout::MEM_32BIT_RESERVED_START.0, mem_size);
let mem_above_4g = mem_size.saturating_sub(arch::layout::RAM_64BIT_START.0);
let cmos = Arc::new(Mutex::new(devices::legacy::Cmos::new(
mem_below_4g,
mem_above_4g,
)));
buses
.io
.insert(cmos.clone(), 0x70, 0x2)
.map_err(DeviceManagerError::BusError)?;
}
#[cfg(feature = "acpi")]
{
let acpi_device = Arc::new(Mutex::new(devices::AcpiShutdownDevice::new(