Update to use the new API for custom allocators (#348)

* Update to new allocator API

* Change linked_list_allocator dependency to link directly to git repository

* Add Cargo.lock to gitignore
This commit is contained in:
Will
2017-08-20 12:36:30 +00:00
committed by Philipp Oppermann
parent 2ebd4ed954
commit 0175e83387
5 changed files with 46 additions and 50 deletions

View File

@@ -28,7 +28,7 @@ extern crate bit_field;
#[macro_use]
extern crate lazy_static;
extern crate hole_list_allocator;
extern crate hole_list_allocator as allocator;
#[macro_use]
extern crate alloc;
@@ -53,7 +53,7 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) {
// initialize our IDT
interrupts::init(&mut memory_controller);
fn stack_overflow() {
stack_overflow(); // for each recursion, the return address is pushed
}

View File

@@ -12,6 +12,7 @@ pub use self::paging::remap_the_kernel;
pub use self::stack_allocator::Stack;
use self::paging::PhysicalAddress;
use multiboot2::BootInformation;
use allocator;
mod area_frame_allocator;
mod paging;
@@ -62,7 +63,7 @@ pub fn init(boot_info: &BootInformation) -> MemoryController {
let mut active_table = paging::remap_the_kernel(&mut frame_allocator, boot_info);
use self::paging::Page;
use hole_list_allocator::{HEAP_START, HEAP_SIZE};
use allocator::{HEAP_START, HEAP_SIZE};
let heap_start_page = Page::containing_address(HEAP_START);
let heap_end_page = Page::containing_address(HEAP_START + HEAP_SIZE - 1);
@@ -71,6 +72,11 @@ pub fn init(boot_info: &BootInformation) -> MemoryController {
active_table.map(page, paging::WRITABLE, &mut frame_allocator);
}
//Init the heap
unsafe {
allocator::init(HEAP_START, HEAP_SIZE);
}
let stack_allocator = {
let stack_alloc_start = heap_end_page + 1;
let stack_alloc_end = stack_alloc_start + 100;