From a35b0b9706617fa696df88fdd8320b9e79695198 Mon Sep 17 00:00:00 2001 From: ami-chuu Date: Tue, 31 Mar 2026 00:47:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20src/interrupts.rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interrupts.rs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/interrupts.rs b/src/interrupts.rs index 5348439..0070e25 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -4,12 +4,11 @@ use pic8259::ChainedPics; use spin; use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode}; -#[derive(Debug, Clone, Copy)] -#[repr(u8)] -pub enum InterruptIndex { - Timer = PIC_1_OFFSET, - Keyboard, -} +pub const PIC_1_OFFSET: u8 = 32; +pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8; + +pub static PICS: spin::Mutex = + spin::Mutex::new(unsafe { ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET) }); lazy_static! { static ref IDT: InterruptDescriptorTable = { @@ -28,6 +27,23 @@ lazy_static! { }; } +#[derive(Debug, Clone, Copy)] +#[repr(u8)] +pub enum InterruptIndex { + Timer = PIC_1_OFFSET, + Keyboard, +} + +impl InterruptIndex { + fn as_u8(self) -> u8 { + self as u8 + } + + fn as_usize(self) -> usize { + usize::from(self.as_u8()) + } +} + pub fn init_idt() { IDT.load(); } @@ -109,20 +125,4 @@ extern "x86-interrupt" fn page_fault_handler( fn test_breakpoint_exception() { // invoke a breakpoint exception 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 = - spin::Mutex::new(unsafe { ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET) }); - -impl InterruptIndex { - fn as_u8(self) -> u8 { - self as u8 - } - - fn as_usize(self) -> usize { - usize::from(self.as_u8()) - } -} +} \ No newline at end of file