From ffdcd4524f6940bb1d6d40b45eb7bf8c6f756223 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Thu, 18 Aug 2022 21:11:17 -0700 Subject: Include fixed allocation scheme TODO: Upgrade to queue scheme --- src/kernel.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/kernel.rs') diff --git a/src/kernel.rs b/src/kernel.rs index 56f53c1..9377eb5 100644 --- a/src/kernel.rs +++ b/src/kernel.rs @@ -9,6 +9,7 @@ #![no_main] #![no_std] +mod alloc; mod console; mod cpu; mod panic_wait; @@ -16,15 +17,26 @@ mod print; mod sync; mod uart; use crate::console::console; +use crate::alloc::CHAR_ALLOCATOR; /// Initialization Code unsafe fn kernel_init() -> ! { console().init().unwrap(); + CHAR_ALLOCATOR.init(); kernel_main() } /// Post init fn kernel_main() -> ! { + for idx in 0..30 { + if let Some(cell) = CHAR_ALLOCATOR.alloc() { + cell.data = ('0' as u8 + idx as u8) as char; + println!("SUCCESS: Allocated a char! {:?} {:?}", cell, CHAR_ALLOCATOR); + CHAR_ALLOCATOR.free(cell); + } else { + println!("ERROR: No more chars remaining! {:?}", CHAR_ALLOCATOR); + } + } println!("I should be able to print {} here!", 5); loop { } } -- cgit v1.2.1