mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
aarch64: Change RAM_START
type GuestAddress
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
ef9f37cd5f
commit
a3dbc3b415
@ -255,10 +255,10 @@ fn create_memory_node(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mem_size = guest_mem.last_addr().raw_value() - super::layout::RAM_START + 1;
|
let mem_size = guest_mem.last_addr().raw_value() - super::layout::RAM_START.raw_value() + 1;
|
||||||
// See https://github.com/torvalds/linux/blob/master/Documentation/devicetree/booting-without-of.txt#L960
|
// See https://github.com/torvalds/linux/blob/master/Documentation/devicetree/booting-without-of.txt#L960
|
||||||
// for an explanation of this.
|
// for an explanation of this.
|
||||||
let mem_reg_prop = [super::layout::RAM_START as u64, mem_size as u64];
|
let mem_reg_prop = [super::layout::RAM_START.raw_value() as u64, mem_size as u64];
|
||||||
let memory_node = fdt.begin_node("memory")?;
|
let memory_node = fdt.begin_node("memory")?;
|
||||||
|
|
||||||
fdt.property_string("device_type", "memory")?;
|
fdt.property_string("device_type", "memory")?;
|
||||||
|
@ -86,7 +86,7 @@ pub const PCI_MMCONFIG_SIZE: u64 = 256 << 20;
|
|||||||
pub const PCI_MMIO_CONFIG_SIZE_PER_SEGMENT: u64 = 4096 * 256;
|
pub const PCI_MMIO_CONFIG_SIZE_PER_SEGMENT: u64 = 4096 * 256;
|
||||||
|
|
||||||
/// Start of RAM.
|
/// Start of RAM.
|
||||||
pub const RAM_START: u64 = 0x4000_0000;
|
pub const RAM_START: GuestAddress = GuestAddress(0x4000_0000);
|
||||||
|
|
||||||
/// Kernel command line maximum size.
|
/// Kernel command line maximum size.
|
||||||
/// As per `arch/arm64/include/uapi/asm/setup.h`.
|
/// As per `arch/arm64/include/uapi/asm/setup.h`.
|
||||||
@ -94,11 +94,11 @@ pub const CMDLINE_MAX_SIZE: usize = 2048;
|
|||||||
|
|
||||||
/// FDT is at the beginning of RAM.
|
/// FDT is at the beginning of RAM.
|
||||||
/// Maximum size of the device tree blob as specified in https://www.kernel.org/doc/Documentation/arm64/booting.txt.
|
/// Maximum size of the device tree blob as specified in https://www.kernel.org/doc/Documentation/arm64/booting.txt.
|
||||||
pub const FDT_START: u64 = RAM_START;
|
pub const FDT_START: u64 = RAM_START.0;
|
||||||
pub const FDT_MAX_SIZE: usize = 0x20_0000;
|
pub const FDT_MAX_SIZE: usize = 0x20_0000;
|
||||||
|
|
||||||
/// Put ACPI table above dtb
|
/// Put ACPI table above dtb
|
||||||
pub const ACPI_START: u64 = RAM_START + FDT_MAX_SIZE as u64;
|
pub const ACPI_START: u64 = RAM_START.0 + FDT_MAX_SIZE as u64;
|
||||||
pub const ACPI_MAX_SIZE: usize = 0x20_0000;
|
pub const ACPI_MAX_SIZE: usize = 0x20_0000;
|
||||||
pub const RSDP_POINTER: GuestAddress = GuestAddress(ACPI_START);
|
pub const RSDP_POINTER: GuestAddress = GuestAddress(ACPI_START);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ pub fn arch_memory_regions(size: GuestUsize) -> Vec<(GuestAddress, usize, Region
|
|||||||
),
|
),
|
||||||
// 1 GiB ~ : Ram
|
// 1 GiB ~ : Ram
|
||||||
(
|
(
|
||||||
GuestAddress(layout::RAM_START),
|
layout::RAM_START,
|
||||||
(size - ram_deduction) as usize,
|
(size - ram_deduction) as usize,
|
||||||
RegionType::Ram,
|
RegionType::Ram,
|
||||||
),
|
),
|
||||||
@ -212,7 +212,7 @@ mod tests {
|
|||||||
fn test_arch_memory_regions_dram() {
|
fn test_arch_memory_regions_dram() {
|
||||||
let regions = arch_memory_regions((1usize << 32) as u64); //4GB
|
let regions = arch_memory_regions((1usize << 32) as u64); //4GB
|
||||||
assert_eq!(5, regions.len());
|
assert_eq!(5, regions.len());
|
||||||
assert_eq!(GuestAddress(layout::RAM_START), regions[4].0);
|
assert_eq!(layout::RAM_START, regions[4].0);
|
||||||
assert_eq!(((1 << 32) - layout::UEFI_SIZE) as usize, regions[4].1);
|
assert_eq!(((1 << 32) - layout::UEFI_SIZE) as usize, regions[4].1);
|
||||||
assert_eq!(RegionType::Ram, regions[4].2);
|
assert_eq!(RegionType::Ram, regions[4].2);
|
||||||
}
|
}
|
||||||
|
@ -2986,16 +2986,12 @@ mod tests {
|
|||||||
use arch::aarch64::gic::kvm::create_gic;
|
use arch::aarch64::gic::kvm::create_gic;
|
||||||
use arch::aarch64::layout;
|
use arch::aarch64::layout;
|
||||||
use arch::{DeviceType, MmioDeviceInfo};
|
use arch::{DeviceType, MmioDeviceInfo};
|
||||||
use vm_memory::GuestAddress;
|
|
||||||
|
|
||||||
const LEN: u64 = 4096;
|
const LEN: u64 = 4096;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_create_fdt_with_devices() {
|
fn test_create_fdt_with_devices() {
|
||||||
let regions = vec![(
|
let regions = vec![(layout::RAM_START, (layout::FDT_MAX_SIZE + 0x1000) as usize)];
|
||||||
GuestAddress(layout::RAM_START),
|
|
||||||
(layout::FDT_MAX_SIZE + 0x1000) as usize,
|
|
||||||
)];
|
|
||||||
let mem = GuestMemoryMmap::from_ranges(®ions).expect("Cannot initialize memory");
|
let mem = GuestMemoryMmap::from_ranges(®ions).expect("Cannot initialize memory");
|
||||||
|
|
||||||
let dev_info: HashMap<(DeviceType, std::string::String), MmioDeviceInfo> = [
|
let dev_info: HashMap<(DeviceType, std::string::String), MmioDeviceInfo> = [
|
||||||
|
Loading…
Reference in New Issue
Block a user