MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / add_uefi_flash

Method add_uefi_flash

vmm/src/memory_manager.rs:1471–1501  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

1469
1470 #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
1471 pub fn add_uefi_flash(&mut self) -> Result<(), Error> {
1472 // The UEFI binary requires a flash device at address 0.
1473 // 4 MiB memory is mapped to simulate the flash.
1474 let uefi_mem_slot = self.allocate_memory_slot();
1475 let uefi_region = GuestRegionMmap::new(
1476 MmapRegion::new(arch::layout::UEFI_SIZE as usize).unwrap(),
1477 arch::layout::UEFI_START,
1478 )
1479 .unwrap();
1480 const _: () = assert!(core::mem::size_of::<usize>() == core::mem::size_of::<u64>());
1481
1482 // SAFETY: guaranteed by GuestRegionMmap
1483 unsafe {
1484 self.vm
1485 .create_user_memory_region(
1486 uefi_mem_slot,
1487 uefi_region.start_addr().raw_value(),
1488 uefi_region.len() as usize,
1489 uefi_region.as_ptr(),
1490 false,
1491 false,
1492 )
1493 .map_err(Error::CreateUefiFlash)?;
1494 }
1495 let uefi_flash =
1496 GuestMemoryAtomic::new(GuestMemoryMmap::from_regions(vec![uefi_region]).unwrap());
1497
1498 self.uefi_flash = Some(uefi_flash);
1499
1500 Ok(())
1501 }
1502
1503 #[allow(clippy::too_many_arguments)]
1504 pub fn new(

Callers 1

load_firmwareMethod · 0.80

Calls 5

newFunction · 0.85
allocate_memory_slotMethod · 0.80
start_addrMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected