From 05bb497fe495f0bac6c43f82f5b1ab6dc669b404 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Thu, 16 Mar 2017 22:50:09 -0600
Subject: [PATCH] Use normal EOI mode

---
 arch/x86_64/src/device/pic.rs    | 6 +++---
 arch/x86_64/src/interrupt/irq.rs | 5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86_64/src/device/pic.rs b/arch/x86_64/src/device/pic.rs
index d2ae4b03..8156ad21 100644
--- a/arch/x86_64/src/device/pic.rs
+++ b/arch/x86_64/src/device/pic.rs
@@ -16,9 +16,9 @@ pub unsafe fn init() {
     MASTER.data.write(4);
     SLAVE.data.write(2);
 
-    // Set up interrupt mode (1 is manual, 2 is auto EOI)
-    MASTER.data.write(2);
-    SLAVE.data.write(2);
+    // Set up interrupt mode (1 is 8086/88 mode, 2 is auto EOI)
+    MASTER.data.write(1);
+    SLAVE.data.write(1);
 
     // Unmask interrupts
     MASTER.data.write(0);
diff --git a/arch/x86_64/src/interrupt/irq.rs b/arch/x86_64/src/interrupt/irq.rs
index 8e2aa033..f6f38621 100644
--- a/arch/x86_64/src/interrupt/irq.rs
+++ b/arch/x86_64/src/interrupt/irq.rs
@@ -10,8 +10,11 @@ unsafe fn trigger(irq: u8) {
     if irq < 16 {
         if irq >= 8 {
             pic::SLAVE.mask_set(irq - 8);
+            pic::MASTER.ack();
+            pic::SLAVE.ack();
         } else {
             pic::MASTER.mask_set(irq);
+            pic::MASTER.ack();
         }
     }
 
@@ -37,6 +40,8 @@ interrupt!(pit, {
     let sum = offset.1 + PIT_RATE;
     offset.1 = sum % 1000000000;
     offset.0 += sum / 1000000000;
+
+    pic::MASTER.ack();
 });
 
 interrupt!(keyboard, {
-- 
GitLab