From 00bbd6fbc6c5cb3a32f13b742be73ad2491d6ea2 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 18 Apr 2017 18:20:15 +0200 Subject: [PATCH] Pass the memory controller to interrupts::init and use it to create a double fault stack --- src/interrupts.rs | 6 +++++- src/lib.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/interrupts.rs b/src/interrupts.rs index 095367b..0d8ad37 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -1,4 +1,5 @@ use x86_64::structures::idt::{Idt, ExceptionStackFrame}; +use memory::MemoryController; lazy_static! { static ref IDT: Idt = { @@ -9,7 +10,10 @@ lazy_static! { }; } -pub fn init() { +pub fn init(memory_controller: &mut MemoryController) { + let double_fault_stack = memory_controller.alloc_stack(1) + .expect("could not allocate double fault stack"); + IDT.load(); } diff --git a/src/lib.rs b/src/lib.rs index 403c9f4..5d65479 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,14 +42,14 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) { enable_write_protect_bit(); // set up guard page and map the heap pages - memory::init(boot_info); + let mut memory_controller = memory::init(boot_info); unsafe { HEAP_ALLOCATOR.lock().init(HEAP_START, HEAP_START + HEAP_SIZE); } // initialize our IDT - interrupts::init(); + interrupts::init(&mut memory_controller); for i in 0..10000 { format!("Some String");