blob: 7903e94bd625ce148f43417a51a3f8dc6294c105 [file] [log] [blame]
Andrew Walbraneef98202022-04-27 16:23:06 +00001// 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//! VM bootloader example.
16
17#![no_main]
18#![no_std]
19
20mod exceptions;
21
22use vmbase::{main, println};
23
24main!(main);
25
26/// Entry point for VM bootloader.
27pub fn main() {
28 println!("Hello world");
Andrew Walbran6261cf42022-04-12 13:26:52 +000029 print_addresses();
30}
31
32fn print_addresses() {
33 unsafe {
34 println!(
35 "dtb: {:#010x}-{:#010x} ({} bytes)",
36 &dtb_begin as *const u8 as usize,
37 &dtb_end as *const u8 as usize,
38 &dtb_end as *const u8 as usize - &dtb_begin as *const u8 as usize,
39 );
40 println!(
41 "text: {:#010x}-{:#010x} ({} bytes)",
42 &text_begin as *const u8 as usize,
43 &text_end as *const u8 as usize,
44 &text_end as *const u8 as usize - &text_begin as *const u8 as usize,
45 );
46 println!(
47 "rodata: {:#010x}-{:#010x} ({} bytes)",
48 &rodata_begin as *const u8 as usize,
49 &rodata_end as *const u8 as usize,
50 &rodata_end as *const u8 as usize - &rodata_begin as *const u8 as usize,
51 );
52 println!(
53 "data: {:#010x}-{:#010x} ({} bytes, loaded at {:#010x})",
54 &data_begin as *const u8 as usize,
55 &data_end as *const u8 as usize,
56 &data_end as *const u8 as usize - &data_begin as *const u8 as usize,
57 &data_lma as *const u8 as usize,
58 );
59 println!(
60 "bss: {:#010x}-{:#010x} ({} bytes)",
61 &bss_begin as *const u8 as usize,
62 &bss_end as *const u8 as usize,
63 &bss_end as *const u8 as usize - &bss_begin as *const u8 as usize,
64 );
65 println!(
66 "boot_stack: {:#010x}-{:#010x} ({} bytes)",
67 &boot_stack_begin as *const u8 as usize,
68 &boot_stack_end as *const u8 as usize,
69 &boot_stack_end as *const u8 as usize - &boot_stack_begin as *const u8 as usize,
70 );
71 }
72}
73
74extern "C" {
75 static dtb_begin: u8;
76 static dtb_end: u8;
77 static text_begin: u8;
78 static text_end: u8;
79 static rodata_begin: u8;
80 static rodata_end: u8;
81 static data_begin: u8;
82 static data_end: u8;
83 static data_lma: u8;
84 static bss_begin: u8;
85 static bss_end: u8;
86 static boot_stack_begin: u8;
87 static boot_stack_end: u8;
Andrew Walbraneef98202022-04-27 16:23:06 +000088}