Enable base PICS (3h53m)

This commit is contained in:
Conzer 2024-12-03 19:55:09 -05:00
parent beb2227d7e
commit 59a7f07012
5 changed files with 23 additions and 3 deletions

10
Cargo.lock generated
View file

@ -32,6 +32,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"bootloader", "bootloader",
"lazy_static", "lazy_static",
"pic8259",
"spin 0.5.2", "spin 0.5.2",
"uart_16550", "uart_16550",
"volatile 0.2.7", "volatile 0.2.7",
@ -47,6 +48,15 @@ dependencies = [
"spin 0.9.8", "spin 0.9.8",
] ]
[[package]]
name = "pic8259"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb844b5b01db1e0b17938685738f113bfc903846f18932b378bc0eabfa40e194"
dependencies = [
"x86_64",
]
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.18" version = "1.0.18"

View file

@ -18,6 +18,7 @@ volatile = "0.2.6"
spin = "0.5.2" spin = "0.5.2"
x86_64 = "0.14.2" x86_64 = "0.14.2"
uart_16550 = "0.2.0" uart_16550 = "0.2.0"
pic8259 = "0.10.1"
[dependencies.lazy_static] [dependencies.lazy_static]
version = "1.0" version = "1.0"

View file

@ -2,6 +2,8 @@ use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
use crate::println; use crate::println;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use crate::gdt; use crate::gdt;
use pic8259::ChainedPics;
use spin;
lazy_static! { lazy_static! {
static ref IDT: InterruptDescriptorTable = { static ref IDT: InterruptDescriptorTable = {
@ -37,3 +39,9 @@ fn test_breakpoint_exception() {
// invoke a breakpoint exception // invoke a breakpoint exception
x86_64::instructions::interrupts::int3(); x86_64::instructions::interrupts::int3();
} }
pub const PIC_1_OFFSET: u8 = 32;
pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
pub static PICS: spin::Mutex<ChainedPics> =
spin::Mutex::new(unsafe {ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET) });

View file

@ -15,6 +15,8 @@ pub mod gdt;
pub fn init() { pub fn init() {
gdt::init(); gdt::init();
interrupts::init_idt(); interrupts::init_idt();
unsafe { interrupts::PICS.lock().initialize() };
x86_64::instructions::interrupts::enable();
} }
use core::panic::PanicInfo; use core::panic::PanicInfo;

View file

@ -10,7 +10,7 @@ use donald::println;
#[no_mangle] #[no_mangle]
pub extern "C" fn _start() -> ! { pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!"); println!("Hello World{}", "!");
println!("It did not crash!");
donald::init(); donald::init();
fn stack_overflow() { fn stack_overflow() {
@ -22,7 +22,6 @@ pub extern "C" fn _start() -> ! {
#[cfg(test)] #[cfg(test)]
test_main(); test_main();
println!("It did not crash!");
loop {} loop {}
} }