aboutsummaryrefslogtreecommitdiff
path: root/src/kernel.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel.rs')
-rw-r--r--src/kernel.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/kernel.rs b/src/kernel.rs
index 3f10849..19c4e5f 100644
--- a/src/kernel.rs
+++ b/src/kernel.rs
@@ -12,10 +12,14 @@
#![feature(panic_info_message)]
#![feature(trait_alias)]
#![feature(exclusive_range_pattern)]
+#![feature(default_alloc_error_handler)]
#![no_main]
#![no_std]
-mod alloc;
+extern crate alloc;
+use alloc::boxed::Box;
+
+mod mem;
mod console;
mod cpu;
mod panic_wait;
@@ -23,7 +27,8 @@ mod print;
mod sync;
mod uart;
use crate::console::console;
-use crate::alloc::*;
+use crate::mem::alloc::*;
+//use crate::sync::interface::Mutex;
/// # Initialization Code
///
@@ -36,6 +41,10 @@ use crate::alloc::*;
unsafe fn kernel_init() -> ! {
console().init().unwrap();
U64_QUEUE_ALLOCATOR.init();
+ ALLOCATOR.init();
+ //ALLOCATOR.lock(|qa| {
+ // qa.init();
+ //});
kernel_main()
}
@@ -43,16 +52,28 @@ unsafe fn kernel_init() -> ! {
///
/// TODO: Figure out what to do here
fn kernel_main() -> ! {
- for idx in 0..30 {
+ for idx in 0..5 {
if let Some(cell) = U64_QUEUE_ALLOCATOR.alloc() {
let inner = cell.inner();
*inner = idx;
- println!("SUCCESS: Allocated a char! {:?}", cell);
+ println!("SUCCESS: Allocated a char! {:?} {:?}", cell, U64_QUEUE_ALLOCATOR);
U64_QUEUE_ALLOCATOR.free(cell);
} else {
- println!("ERROR: No more chars remaining!");
+ println!("ERROR: No more chars remaining! {:?}", U64_QUEUE_ALLOCATOR);
}
}
println!("I should be able to print {} here!", 5);
+ {
+ let a: Box<u8> = Box::new(5);
+ println!("{:?}", a);
+ let b: Box<u8> = Box::new(7);
+ println!("{:?}", b);
+ }
+ {
+ let a: Box<u8> = Box::new(8);
+ println!("{:?}", a);
+ let b: Box<u16> = Box::new(9);
+ println!("{:?}", b);
+ }
loop { }
}