|
|
|
@ -20,6 +20,7 @@ extern crate bitflags;
|
|
|
|
|
extern crate x86_64;
|
|
|
|
|
#[macro_use]
|
|
|
|
|
extern crate once;
|
|
|
|
|
extern crate linked_list_allocator;
|
|
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
|
mod vga_buffer;
|
|
|
|
@ -40,8 +41,13 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) {
|
|
|
|
|
// set up guard page and map the heap pages
|
|
|
|
|
memory::init(boot_info);
|
|
|
|
|
|
|
|
|
|
use alloc::boxed::Box;
|
|
|
|
|
let heap_test = Box::new(42);
|
|
|
|
|
unsafe {
|
|
|
|
|
HEAP_ALLOCATOR.lock().init(HEAP_START, HEAP_START + HEAP_SIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for i in 0..10000 {
|
|
|
|
|
format!("Some String");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println!("It did not crash!");
|
|
|
|
|
|
|
|
|
@ -74,11 +80,10 @@ pub extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32
|
|
|
|
|
loop{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
use memory::heap_allocator::BumpAllocator;
|
|
|
|
|
use linked_list_allocator::LockedHeap;
|
|
|
|
|
|
|
|
|
|
pub const HEAP_START: usize = 0o_000_001_000_000_0000;
|
|
|
|
|
pub const HEAP_SIZE: usize = 100 * 1024; // 100 KiB
|
|
|
|
|
|
|
|
|
|
#[global_allocator]
|
|
|
|
|
static HEAP_ALLOCATOR: BumpAllocator = BumpAllocator::new(HEAP_START,
|
|
|
|
|
HEAP_START + HEAP_SIZE);
|
|
|
|
|
static HEAP_ALLOCATOR: LockedHeap = LockedHeap::empty();
|
|
|
|
|