From 4951d2c50918c5f12474d7ac92addef462ed7314 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Mon, 8 Jul 2024 14:28:04 +0200 Subject: [PATCH] Disable PIC --- kernel/src/main.rs | 3 +++ kernel/src/sys/mod.rs | 1 + kernel/src/sys/pic.rs | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 kernel/src/sys/mod.rs create mode 100644 kernel/src/sys/pic.rs diff --git a/kernel/src/main.rs b/kernel/src/main.rs index e70992b..4653ed4 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -14,8 +14,10 @@ use kernel_common::{ }; use linked_list_allocator::LockedHeap; use log::{error, info}; +use sys::pic::disable_pic; mod cpu; +mod sys; #[global_allocator] static ALLOC: LockedHeap = LockedHeap::empty(); @@ -53,6 +55,7 @@ extern "C" fn main(temp_loader_struct: *const LoaderStruct) -> ! { setup_gdt(); setup_idt(); setup_paging(&loader_struct, loader_struct.phys_kernel_start, loader_struct.phys_heap_start); + disable_pic(); loop { hlt(); } diff --git a/kernel/src/sys/mod.rs b/kernel/src/sys/mod.rs new file mode 100644 index 0000000..31534aa --- /dev/null +++ b/kernel/src/sys/mod.rs @@ -0,0 +1 @@ +pub mod pic; diff --git a/kernel/src/sys/pic.rs b/kernel/src/sys/pic.rs new file mode 100644 index 0000000..9ddfe8c --- /dev/null +++ b/kernel/src/sys/pic.rs @@ -0,0 +1,21 @@ +use kernel_common::ioports::outb; + +const PIC1_CMD: u16 = 0x20; +const PIC1_DATA: u16 = 0x21; +const PIC2_CMD: u16 = 0xa0; +const PIC2_DATA: u16 = 0xa1; + +pub fn disable_pic() { + unsafe { + outb(PIC1_CMD, 0x11); + outb(PIC2_CMD, 0x11); + outb(PIC1_DATA, 0x20); + outb(PIC2_DATA, 0x28); + outb(PIC1_DATA, 4); + outb(PIC2_DATA, 2); + outb(PIC1_DATA, 1); + outb(PIC2_DATA, 1); + outb(PIC1_DATA, 0xff); + outb(PIC2_DATA, 0xff); + } +}