diff options
author | Christian Cunningham <cc@localhost> | 2022-08-18 21:11:17 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-08-18 21:11:17 -0700 |
commit | ffdcd4524f6940bb1d6d40b45eb7bf8c6f756223 (patch) | |
tree | fd8c23988285281065e47f75ac5ad889e5472477 /src/kernel.rs | |
parent | 66ee8a34f3bcde31f9d5919f2e0e363ac11f4aca (diff) |
Include fixed allocation scheme
TODO: Upgrade to queue scheme
Diffstat (limited to 'src/kernel.rs')
-rw-r--r-- | src/kernel.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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 { } } |