diff --git a/include/kernel/iomisc.h b/include/kernel/iomisc.h index eca4867..5c9da8e 100644 --- a/include/kernel/iomisc.h +++ b/include/kernel/iomisc.h @@ -61,6 +61,11 @@ static inline ulong KePauseIRQs(void) { return flags; } +extern void IoSendEOItoPIC(uchar isr); +extern void IoEnableNMI(void); +extern void IoDisableNMI(void); +extern void IdtRegisterIrq(void (*isr)(void), uchar irq, uchar flags); + // // Restore IRQ flag to its state before KePauseIRQs // diff --git a/kaleid/kernel/cpu/idt.c b/kaleid/kernel/cpu/idt.c index 082d60a..5dfb88b 100644 --- a/kaleid/kernel/cpu/idt.c +++ b/kaleid/kernel/cpu/idt.c @@ -166,7 +166,7 @@ static void EnablePIC(void) // // Ends the current interrupt handling // -void SendEOItoPIC(uchar isr) +void IoSendEOItoPIC(uchar isr) { if(isr >= 8) IoWriteByteOnPort(0xa0,0x20); @@ -174,6 +174,16 @@ void SendEOItoPIC(uchar isr) IoWriteByteOnPort(0x20,0x20); } +void IoEnableNMI(void) +{ + IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) & 0x7F); +} + +void IoDisableNMI(void) +{ + IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) | 0x80); +} + // // The main exception handler // @@ -190,6 +200,6 @@ void IdtHandler(ulong intNo) KeStartPanic("[ISR 0x%x] Irrecoverable %s\n", intNo, exceptionMsg); } else { bprintf(BStdOut, "[ISR 0x%x] %s\n", intNo, exceptionMsg); - SendEOItoPIC(intNo); + IoSendEOItoPIC(intNo); } } diff --git a/kaleid/kernel/io/keyb.c b/kaleid/kernel/io/keyb.c index b41ddf9..cbb2aaf 100644 --- a/kaleid/kernel/io/keyb.c +++ b/kaleid/kernel/io/keyb.c @@ -27,8 +27,6 @@ #include extern void KeybIsr(void); -extern void IdtRegisterIrq(void (*isr)(void), uchar irq, uchar flags); -extern void SendEOItoPIC(void); char ScanCodes[100] = { 0 }; void IoSetupKeyb(void) @@ -96,7 +94,7 @@ void IoEnableKeyb(void) char readedInterruptConfig = IoReadByteFromPort(0x21); IoWriteByteOnPort(0x21, 0xFD & readedInterruptConfig); KeRestoreIRQs(flags); - + IoEnableNMI(); ScanCodesInit(); } @@ -116,4 +114,5 @@ void KeybHandler(void) if(code < 0) code = 0; } KeybPrint((int)code); + IoSendEOItoPIC(0x21); } diff --git a/kaleid/kernel/io/rtc.c b/kaleid/kernel/io/rtc.c index f7d7548..984a465 100644 --- a/kaleid/kernel/io/rtc.c +++ b/kaleid/kernel/io/rtc.c @@ -27,8 +27,6 @@ #include extern void RtcIsr(void); -extern void SendEOItoPIC(void); -extern void IdtRegisterIrq(void (*isr)(void), uchar irq, uchar flags); ulong IoRtcTicks = 0; @@ -70,6 +68,7 @@ void IoEnableRtc(void) IoWriteByteOnPort(0x70, 0x0C); // Select status reg C IoReadByteFromPort(0x71); // Flush KeRestoreIRQs(flags); + IoEnableNMI(); } void RtcHandler(void) @@ -78,6 +77,6 @@ void RtcHandler(void) IoWriteByteOnPort(0x70, 0x0C); // Selects status reg C IoReadByteFromPort(0x71); // Flush IoRtcTicks++; - SendEOItoPIC(); + IoSendEOItoPIC(0x28); //bprintf(BStdOut, " - EOI* "); }