mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 04:26:38 +00:00
aarch64: deduplicate MMIO region calculations
The get_high_mmio_base_size() function duplicates and hard-codes the math from get_platform_mmio_base_size(). Since these are both only called in one location now, pull them into get_resource_allocator() so the plat_mmio variables can be used instead of duplicating the math. Also reorder the SystemAllocator::builder() calls so that they are in the same order as the layout of the regions in memory; this makes no functional difference, but it is less confusing to read. BUG=b:210727578 TEST=Boot crosvm on trogdor64 Change-Id: I1238e5b1d412e41d0b4b9be5b93b59fec6598734 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373451 Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
a475cd4754
commit
3c2abaf838
1 changed files with 7 additions and 15 deletions
|
@ -531,18 +531,6 @@ impl arch::LinuxArch for AArch64 {
|
|||
}
|
||||
|
||||
impl AArch64 {
|
||||
fn get_high_mmio_base_size(mem_size: u64) -> (u64, u64) {
|
||||
let base = AARCH64_PHYS_MEM_START + mem_size + AARCH64_PLATFORM_MMIO_SIZE;
|
||||
let size = u64::max_value() - base;
|
||||
(base, size)
|
||||
}
|
||||
|
||||
fn get_platform_mmio_base_size(mem_size: u64) -> (u64, u64) {
|
||||
let base = AARCH64_PHYS_MEM_START + mem_size;
|
||||
let size = AARCH64_PLATFORM_MMIO_SIZE;
|
||||
(base, size)
|
||||
}
|
||||
|
||||
/// This returns a base part of the kernel command for this architecture
|
||||
fn get_base_linux_cmdline() -> kernel_cmdline::Cmdline {
|
||||
let mut cmdline = kernel_cmdline::Cmdline::new(base::pagesize());
|
||||
|
@ -552,12 +540,16 @@ impl AArch64 {
|
|||
|
||||
/// Returns a system resource allocator.
|
||||
fn get_resource_allocator(mem_size: u64) -> SystemAllocator {
|
||||
let (high_mmio_base, high_mmio_size) = Self::get_high_mmio_base_size(mem_size);
|
||||
let (plat_mmio_base, plat_mmio_size) = Self::get_platform_mmio_base_size(mem_size);
|
||||
// The platform MMIO region is immediately past the end of RAM.
|
||||
let plat_mmio_base = AARCH64_PHYS_MEM_START + mem_size;
|
||||
let plat_mmio_size = AARCH64_PLATFORM_MMIO_SIZE;
|
||||
// The high MMIO region is the rest of the address space after the platform MMIO region.
|
||||
let high_mmio_base = plat_mmio_base + plat_mmio_size;
|
||||
let high_mmio_size = u64::max_value() - high_mmio_base;
|
||||
SystemAllocator::builder()
|
||||
.add_high_mmio_addresses(high_mmio_base, high_mmio_size)
|
||||
.add_low_mmio_addresses(AARCH64_MMIO_BASE, AARCH64_MMIO_SIZE)
|
||||
.add_platform_mmio_addresses(plat_mmio_base, plat_mmio_size)
|
||||
.add_high_mmio_addresses(high_mmio_base, high_mmio_size)
|
||||
.create_allocator(AARCH64_IRQ_BASE)
|
||||
.unwrap()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue