Programmable Interrupt Controller

This commit is contained in:
greg 2019-07-18 03:28:55 -07:00
parent 0264a5e4b6
commit 2627b216a1
3 changed files with 15 additions and 6 deletions

View File

@ -9,6 +9,7 @@ bootloader = "0.6.0"
volatile = "0.2.6" volatile = "0.2.6"
spin = "0.5.0" spin = "0.5.0"
x86_64 = "0.7.2" x86_64 = "0.7.2"
pic8259_simple = "0.1.1"
[dependencies.lazy_static] [dependencies.lazy_static]
version = "1.3.0" version = "1.3.0"

View File

@ -1,9 +1,15 @@
use lazy_static::lazy_static; use lazy_static::lazy_static;
use x86_64::structures::idt::{InterruptStackFrame, InterruptDescriptorTable}; use x86_64::structures::idt::{InterruptStackFrame, InterruptDescriptorTable};
use crate::println; use crate::println;
use pic8259_simple::ChainedPics;
use spin;
use crate::gdt; use crate::gdt;
const PIC_1_OFFSET: u8 = 32;
const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
static PICS: spin::Mutex<ChainedPics> =
spin::Mutex::new(unsafe { ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET) });
lazy_static! { lazy_static! {
static ref IDT: InterruptDescriptorTable = { static ref IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new(); let mut idt = InterruptDescriptorTable::new();
@ -20,6 +26,12 @@ pub fn init_idt() {
IDT.load(); IDT.load();
} }
pub fn initalize_pics() {
unsafe {
PICS.lock().initialize();
}
}
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) { extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
println!("EXCEPTION - BREAKPOINT\n{:#?}", stack_frame); println!("EXCEPTION - BREAKPOINT\n{:#?}", stack_frame);

View File

@ -16,6 +16,7 @@ fn panic(info: &PanicInfo) -> !{
} }
pub fn init() { pub fn init() {
interrupts::initalize_pics();
gdt::init(); gdt::init();
interrupts::init_idt(); interrupts::init_idt();
} }
@ -24,11 +25,6 @@ pub fn init() {
pub extern "C" fn _start() -> ! { pub extern "C" fn _start() -> ! {
init(); init();
fn yolo() {
yolo();
}
yolo();
for i in 1..10 { for i in 1..10 {