Create a new GDT module and a static TSS

This commit is contained in:
Philipp Oppermann
2019-01-25 13:56:40 +01:00
parent 7fd29c9cbe
commit db4e879c34
2 changed files with 21 additions and 0 deletions

20
src/gdt.rs Normal file
View File

@@ -0,0 +1,20 @@
use lazy_static::lazy_static;
use x86_64::structures::tss::TaskStateSegment;
use x86_64::VirtAddr;
pub const DOUBLE_FAULT_IST_INDEX: u16 = 0;
lazy_static! {
static ref TSS: TaskStateSegment = {
let mut tss = TaskStateSegment::new();
tss.interrupt_stack_table[DOUBLE_FAULT_IST_INDEX as usize] = {
const STACK_SIZE: usize = 4096;
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
let stack_start = VirtAddr::from_ptr(unsafe { &STACK });
let stack_end = stack_start + STACK_SIZE;
stack_end
};
tss
};
}

View File

@@ -1,6 +1,7 @@
#![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_std)]
#![feature(abi_x86_interrupt)] #![feature(abi_x86_interrupt)]
pub mod gdt;
pub mod interrupts; pub mod interrupts;
pub mod serial; pub mod serial;
pub mod vga_buffer; pub mod vga_buffer;