diff options
| author | Tianhao Wang <shrik3@mailbox.org> | 2024-04-17 20:34:29 +0200 |
|---|---|---|
| committer | Tianhao Wang <shrik3@mailbox.org> | 2024-06-11 15:16:33 +0200 |
| commit | 5299d4ba95f5e6c3d8faa0cd7141cce9f710a24c (patch) | |
| tree | 64e1546911dbfacf26844f4373b3293ddf67a4d3 /src/arch | |
| parent | 74ac24a8225c9e3c5b907cbf5cea0c7fc66f6c0a (diff) | |
pic: initialize with rust code
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/x86_64/interrupt/pic_8259.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/arch/x86_64/interrupt/pic_8259.rs b/src/arch/x86_64/interrupt/pic_8259.rs index 894697c..969e8d1 100644 --- a/src/arch/x86_64/interrupt/pic_8259.rs +++ b/src/arch/x86_64/interrupt/pic_8259.rs @@ -1,7 +1,7 @@ // For now, the PIC is stateless, i.e. we don'e need a struct for it. // Perhaps I need a Mutex handle later... use crate::arch::x86_64::io_port::*; - +use crate::arch::x86_64::misc::*; const IMR1: u16 = 0x21; const IMR2: u16 = 0xa1; const CTRL1: u16 = 0x20; @@ -13,6 +13,21 @@ impl PicDeviceInt { pub const KEYBOARD: u8 = 1; } +// init must be called before interrupt is enabled. +// TODO: turn pic into a singleton struct +pub fn init() { + outb(0x20, 0x11); + outb(0xa0, 0x11); + outb(0x21, 0x20); + outb(0xa1, 0x28); + outb(0x21, 0x04); + outb(0xa1, 0x02); + outb(0x21, 0x03); + outb(0xa1, 0x03); + outb(0xa1, 0xff); + outb(0x21, 0xfb); +} + // 8-bit registers IMR1 and IMR2 registers hold interrupt masking bit 0~7 and // 8~15; if an interrupt is masked(set 1) on the respective bit, it's disabled pub fn allow(interrupt: u8) { |
