aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kernel.rs11
-rw-r--r--src/mem/alloc.rs7
2 files changed, 9 insertions, 9 deletions
diff --git a/src/kernel.rs b/src/kernel.rs
index 2dde7ac..28d8f87 100644
--- a/src/kernel.rs
+++ b/src/kernel.rs
@@ -17,7 +17,6 @@
#![no_std]
extern crate alloc;
-use alloc::boxed::Box;
mod console;
mod cpu;
@@ -29,7 +28,7 @@ mod sync;
mod uart;
use crate::console::console;
use crate::console::interface::Statistics;
-use crate::mem::alloc::*;
+use crate::mem::alloc::alloc;
/// # Initialization Code
///
@@ -41,7 +40,7 @@ use crate::mem::alloc::*;
/// the regular main.
unsafe fn kernel_init() -> ! {
console().init().unwrap();
- ALLOCATOR.init();
+ alloc().init();
kernel_main()
}
@@ -56,12 +55,6 @@ fn kernel_main() -> ! {
println!("\x1b[91mInitialized\x1b[0m \x1b[92m{}\x1b[0m \x1b[93mv{}\x1b[0m", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
println!("\x1b[94mAuthors:\x1b[0m \x1b[95m{}\x1b[0m", env!("CARGO_PKG_AUTHORS"));
- println!("Testing out allocations!");
- {
- let a: Box<u8> = Box::new(u8::MAX);
- let b: Box<u8> = Box::new(5);
- println!("{:?} {:?}", a, b);
- }
println!("Characters written to UART: \x1b[91m{}\x1b[0m", console().chars_written());
loop { }
}
diff --git a/src/mem/alloc.rs b/src/mem/alloc.rs
index 4d02ddd..fcd33c2 100644
--- a/src/mem/alloc.rs
+++ b/src/mem/alloc.rs
@@ -478,3 +478,10 @@ unsafe impl GlobalAlloc for GrandAllocator {
/// The allocator of allocators. It hands out fixed sized memory chunks.
#[global_allocator]
pub static ALLOCATOR: GrandAllocator = GrandAllocator{};
+
+/// # Global Allocator
+///
+/// Returns a borrow for the Global Allocator
+pub fn alloc() -> &'static crate::mem::alloc::GrandAllocator {
+ &crate::mem::alloc::ALLOCATOR
+}