rialto: Initialize heap when entering main()
As the Rust environment is only fully ready once the global_allocator
has been initialized, call init_heap() as soon as we enter main() to
avoid calling functions (possibly from other crates) that use alloc.
Remove logging from init_heap() as the logger won't be up at that point.
Test: atest rialto_test
Change-Id: I096c502024e6a57a68027422994694d90b345a9e
diff --git a/rialto/src/main.rs b/rialto/src/main.rs
index 4163428..03fa107 100644
--- a/rialto/src/main.rs
+++ b/rialto/src/main.rs
@@ -74,7 +74,6 @@
unsafe {
HEAP_ALLOCATOR.lock().init(&mut HEAP as *mut u8 as usize, HEAP.len());
}
- info!("Initialized heap.");
}
fn init_kernel_pgt(pgt: &mut IdMap) -> Result<()> {
@@ -116,7 +115,6 @@
fn try_main() -> Result<()> {
info!("Welcome to Rialto!");
- init_heap();
let mut pgt = IdMap::new(PT_ASID, PT_ROOT_LEVEL);
init_kernel_pgt(&mut pgt)?;
@@ -125,6 +123,7 @@
/// Entry point for Rialto.
pub fn main(_a0: u64, _a1: u64, _a2: u64, _a3: u64) {
+ init_heap();
if try_init_logger().is_err() {
// Don't log anything if the logger initialization fails.
reboot();