1 // Copyright 2022, 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.
16
17 use aarch64_paging::paging::{MemoryRegion, VirtualAddress};
18 use core::ops::Range;
19 use log::info;
20 use vmbase::layout;
21
22 /// The first 1 GiB of memory are used for MMIO.
23 pub const DEVICE_REGION: MemoryRegion = MemoryRegion::new(0, 0x40000000);
24
25 /// Writable data region for the stack.
boot_stack_range() -> Range<VirtualAddress>26 pub fn boot_stack_range() -> Range<VirtualAddress> {
27 const PAGE_SIZE: usize = 4 << 10;
28 layout::stack_range(40 * PAGE_SIZE)
29 }
30
print_addresses()31 pub fn print_addresses() {
32 let dtb = layout::dtb_range();
33 info!("dtb: {}..{} ({} bytes)", dtb.start, dtb.end, dtb.end - dtb.start);
34 let text = layout::text_range();
35 info!("text: {}..{} ({} bytes)", text.start, text.end, text.end - text.start);
36 let rodata = layout::rodata_range();
37 info!("rodata: {}..{} ({} bytes)", rodata.start, rodata.end, rodata.end - rodata.start);
38 info!("binary end: {}", layout::binary_end());
39 let data = layout::data_range();
40 info!(
41 "data: {}..{} ({} bytes, loaded at {})",
42 data.start,
43 data.end,
44 data.end - data.start,
45 layout::data_load_address(),
46 );
47 let bss = layout::bss_range();
48 info!("bss: {}..{} ({} bytes)", bss.start, bss.end, bss.end - bss.start);
49 let boot_stack = boot_stack_range();
50 info!(
51 "boot_stack: {}..{} ({} bytes)",
52 boot_stack.start,
53 boot_stack.end,
54 boot_stack.end - boot_stack.start
55 );
56 }
57