Update post and code

This commit is contained in:
Philipp Oppermann
2016-12-20 16:50:10 +01:00
parent 038fd097b6
commit ef786e1fe8
7 changed files with 360 additions and 64 deletions

View File

@@ -8,7 +8,7 @@
// except according to those terms.
use spin::Once;
use memory::StackPointer;
use memory::MemoryController;
mod idt;
mod tss;
@@ -95,7 +95,10 @@ static IDT: Once<idt::Idt> = Once::new();
static TSS: Once<tss::TaskStateSegment> = Once::new();
static GDT: Once<gdt::Gdt> = Once::new();
pub fn init(double_fault_stack: StackPointer) {
pub fn init(memory_controller: &mut MemoryController) {
let double_fault_stack = memory_controller.alloc_stack(1)
.expect("could not allocate double fault stack");
let mut double_fault_ist_index = 0;
let tss = TSS.call_once(|| {

View File

@@ -1,4 +1,4 @@
use memory::StackPointer;
use memory::{Stack, StackPointer};
#[derive(Debug)]
#[repr(C, packed)]
@@ -16,7 +16,7 @@ impl TaskStateSegment {
pub fn new() -> TaskStateSegment {
TaskStateSegment {
privilege_stacks: PrivilegeStackTable([None, None, None]),
interrupt_stacks: InterruptStackTable::new(),
interrupt_stacks: InterruptStackTable([None, None, None, None, None, None, None]),
iomap_base: 0,
reserved_0: 0,
reserved_1: 0,
@@ -33,18 +33,14 @@ pub struct PrivilegeStackTable([Option<StackPointer>; 3]);
pub struct InterruptStackTable([Option<StackPointer>; 7]);
impl InterruptStackTable {
pub fn new() -> InterruptStackTable {
InterruptStackTable([None, None, None, None, None, None, None])
}
pub fn insert_stack(&mut self, stack_pointer: StackPointer) -> Result<u8, StackPointer> {
pub fn insert_stack(&mut self, stack: Stack) -> Result<u8, Stack> {
// TSS index starts at 1
for (entry, i) in self.0.iter_mut().zip(1..) {
if entry.is_none() {
*entry = Some(stack_pointer);
*entry = Some(stack.top());
return Ok(i);
}
}
Err(stack_pointer)
Err(stack)
}
}