|
@@ -13,6 +13,7 @@ mod uart8250;
|
|
#[cfg(platform = "crosvm")]
|
|
#[cfg(platform = "crosvm")]
|
|
use uart8250 as uart;
|
|
use uart8250 as uart;
|
|
|
|
|
|
|
|
+use buddy_system_allocator::LockedHeap;
|
|
use core::{
|
|
use core::{
|
|
mem::size_of,
|
|
mem::size_of,
|
|
panic::PanicInfo,
|
|
panic::PanicInfo,
|
|
@@ -47,6 +48,11 @@ pub const UART_BASE_ADDRESS: usize = 0x900_0000;
|
|
#[cfg(platform = "crosvm")]
|
|
#[cfg(platform = "crosvm")]
|
|
pub const UART_BASE_ADDRESS: usize = 0x3f8;
|
|
pub const UART_BASE_ADDRESS: usize = 0x3f8;
|
|
|
|
|
|
|
|
+#[global_allocator]
|
|
|
|
+static HEAP_ALLOCATOR: LockedHeap<32> = LockedHeap::new();
|
|
|
|
+
|
|
|
|
+static mut HEAP: [u8; 65536] = [0; 65536];
|
|
|
|
+
|
|
#[no_mangle]
|
|
#[no_mangle]
|
|
extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
|
extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
|
logger::init(LevelFilter::Debug).unwrap();
|
|
logger::init(LevelFilter::Debug).unwrap();
|
|
@@ -56,6 +62,14 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
|
x0, x1, x2, x3
|
|
x0, x1, x2, x3
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+ // Safe because `HEAP` is only used here and `entry` is only called once.
|
|
|
|
+ unsafe {
|
|
|
|
+ // Give the allocator some memory to allocate.
|
|
|
|
+ HEAP_ALLOCATOR
|
|
|
|
+ .lock()
|
|
|
|
+ .init(HEAP.as_mut_ptr() as usize, HEAP.len());
|
|
|
|
+ }
|
|
|
|
+
|
|
info!("Loading FDT from {:#018x}", x0);
|
|
info!("Loading FDT from {:#018x}", x0);
|
|
// Safe because the pointer is a valid pointer to unaliased memory.
|
|
// Safe because the pointer is a valid pointer to unaliased memory.
|
|
let fdt = unsafe { Fdt::from_ptr(x0 as *const u8).unwrap() };
|
|
let fdt = unsafe { Fdt::from_ptr(x0 as *const u8).unwrap() };
|