• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023, The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //! Memory layout for crosvm for aarch64 architecture.
16 //!
17 //! https://crosvm.dev/book/appendix/memory_layout.html#common-layout
18 
19 use crate::memory::page_4kb_of;
20 use core::ops::Range;
21 use static_assertions::const_assert_eq;
22 
23 /// The start address of MMIO space.
24 pub const MMIO_START: usize = 0x0;
25 /// The end address of MMIO space.
26 pub const MMIO_END: usize = PVMFW_START;
27 /// MMIO range.
28 pub const MMIO_RANGE: Range<usize> = MMIO_START..MMIO_END;
29 
30 /// Start pvmfw region.
31 pub const PVMFW_START: usize = 0x7fc00000;
32 
33 /// The start of the system's contiguous "main" memory.
34 pub const MEM_START: usize = 0x8000_0000;
35 
36 /// Size of the FDT region as defined by crosvm, both in kernel and BIOS modes.
37 pub const FDT_MAX_SIZE: usize = 2 << 20;
38 
39 /// First address that can't be translated by a level 1 TTBR0_EL1.
40 pub const MAX_VIRT_ADDR: usize = 1 << 40;
41 
42 /// Base memory-mapped addresses of the UART devices.
43 ///
44 /// See SERIAL_ADDR in https://crosvm.dev/book/appendix/memory_layout.html#common-layout.
45 pub const UART_ADDRESSES: [usize; 4] = [0x3f8, 0x2f8, 0x3e8, 0x2e8];
46 
47 /// Address of the single page containing all the UART devices.
48 pub const UART_PAGE_ADDR: usize = 0;
49 const_assert_eq!(UART_PAGE_ADDR, page_4kb_of(UART_ADDRESSES[0]));
50 const_assert_eq!(UART_PAGE_ADDR, page_4kb_of(UART_ADDRESSES[1]));
51 const_assert_eq!(UART_PAGE_ADDR, page_4kb_of(UART_ADDRESSES[2]));
52 const_assert_eq!(UART_PAGE_ADDR, page_4kb_of(UART_ADDRESSES[3]));
53