1#![cfg_attr(target_os = "none", no_std)]
2#![cfg(target_os = "none")]
3
4#[cfg(target_arch = "aarch64")]
5#[path = "arch/aarch64/mod.rs"]
6mod arch;
7
8mod fdt;
9mod loader;
10mod staticcell;
11
12use heapless::Vec;
13use pie_boot_if::EarlyBootArgs;
14pub use pie_boot_if::{BootInfo, MemoryRegion, MemoryRegionKind, MemoryRegions};
15pub use pie_boot_macros::entry;
16#[allow(unused)]
17use pie_boot_macros::start_code;
18use staticcell::StaticCell;
19
20#[allow(unused)]
21static mut BOOT_ARGS: EarlyBootArgs = EarlyBootArgs::new();
22
23#[unsafe(link_section = ".data")]
24static BOOT_INFO: StaticCell<BootInfo> = StaticCell::new(BootInfo::new());
25#[unsafe(link_section = ".data")]
26static MEMORY_REGIONS: StaticCell<Vec<MemoryRegion, 128>> = StaticCell::new(Vec::new());
27
28unsafe extern "Rust" {
29 fn __pie_boot_main(args: &BootInfo);
30}
31
32fn virt_entry(args: &BootInfo) {
33 unsafe {
34 MEMORY_REGIONS.as_mut().clear();
35 let _ = MEMORY_REGIONS
36 .as_mut()
37 .extend_from_slice(&args.memory_regions);
38
39 *BOOT_INFO.as_mut() = args.clone();
40
41 if let Some(ptr) = BOOT_INFO.fdt {
42 fdt::setup(ptr);
43 }
44
45 let regions = core::slice::from_raw_parts_mut(
46 MEMORY_REGIONS.as_mut().as_mut_ptr(),
47 MEMORY_REGIONS.len(),
48 );
49
50 BOOT_INFO.as_mut().memory_regions = regions.into();
51
52 __pie_boot_main(&BOOT_INFO);
53 }
54}