1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
This commit is contained in:
Adrien Bourmault 2019-04-24 23:00:12 +02:00
parent 8e6cc9a564
commit 9b4e563000
4 changed files with 21 additions and 8 deletions

View File

@ -61,6 +61,11 @@ static inline ulong KePauseIRQs(void) {
return flags; 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 // Restore IRQ flag to its state before KePauseIRQs
// //

View File

@ -166,7 +166,7 @@ static void EnablePIC(void)
// //
// Ends the current interrupt handling // Ends the current interrupt handling
// //
void SendEOItoPIC(uchar isr) void IoSendEOItoPIC(uchar isr)
{ {
if(isr >= 8) if(isr >= 8)
IoWriteByteOnPort(0xa0,0x20); IoWriteByteOnPort(0xa0,0x20);
@ -174,6 +174,16 @@ void SendEOItoPIC(uchar isr)
IoWriteByteOnPort(0x20,0x20); IoWriteByteOnPort(0x20,0x20);
} }
void IoEnableNMI(void)
{
IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) & 0x7F);
}
void IoDisableNMI(void)
{
IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) | 0x80);
}
// //
// The main exception handler // The main exception handler
// //
@ -190,6 +200,6 @@ void IdtHandler(ulong intNo)
KeStartPanic("[ISR 0x%x] Irrecoverable %s\n", intNo, exceptionMsg); KeStartPanic("[ISR 0x%x] Irrecoverable %s\n", intNo, exceptionMsg);
} else { } else {
bprintf(BStdOut, "[ISR 0x%x] %s\n", intNo, exceptionMsg); bprintf(BStdOut, "[ISR 0x%x] %s\n", intNo, exceptionMsg);
SendEOItoPIC(intNo); IoSendEOItoPIC(intNo);
} }
} }

View File

@ -27,8 +27,6 @@
#include <extras/buf.h> #include <extras/buf.h>
extern void KeybIsr(void); extern void KeybIsr(void);
extern void IdtRegisterIrq(void (*isr)(void), uchar irq, uchar flags);
extern void SendEOItoPIC(void);
char ScanCodes[100] = { 0 }; char ScanCodes[100] = { 0 };
void IoSetupKeyb(void) void IoSetupKeyb(void)
@ -96,7 +94,7 @@ void IoEnableKeyb(void)
char readedInterruptConfig = IoReadByteFromPort(0x21); char readedInterruptConfig = IoReadByteFromPort(0x21);
IoWriteByteOnPort(0x21, 0xFD & readedInterruptConfig); IoWriteByteOnPort(0x21, 0xFD & readedInterruptConfig);
KeRestoreIRQs(flags); KeRestoreIRQs(flags);
IoEnableNMI();
ScanCodesInit(); ScanCodesInit();
} }
@ -116,4 +114,5 @@ void KeybHandler(void)
if(code < 0) code = 0; if(code < 0) code = 0;
} }
KeybPrint((int)code); KeybPrint((int)code);
IoSendEOItoPIC(0x21);
} }

View File

@ -27,8 +27,6 @@
#include <extras/buf.h> #include <extras/buf.h>
extern void RtcIsr(void); extern void RtcIsr(void);
extern void SendEOItoPIC(void);
extern void IdtRegisterIrq(void (*isr)(void), uchar irq, uchar flags);
ulong IoRtcTicks = 0; ulong IoRtcTicks = 0;
@ -70,6 +68,7 @@ void IoEnableRtc(void)
IoWriteByteOnPort(0x70, 0x0C); // Select status reg C IoWriteByteOnPort(0x70, 0x0C); // Select status reg C
IoReadByteFromPort(0x71); // Flush IoReadByteFromPort(0x71); // Flush
KeRestoreIRQs(flags); KeRestoreIRQs(flags);
IoEnableNMI();
} }
void RtcHandler(void) void RtcHandler(void)
@ -78,6 +77,6 @@ void RtcHandler(void)
IoWriteByteOnPort(0x70, 0x0C); // Selects status reg C IoWriteByteOnPort(0x70, 0x0C); // Selects status reg C
IoReadByteFromPort(0x71); // Flush IoReadByteFromPort(0x71); // Flush
IoRtcTicks++; IoRtcTicks++;
SendEOItoPIC(); IoSendEOItoPIC(0x28);
//bprintf(BStdOut, " - EOI* "); //bprintf(BStdOut, " - EOI* ");
} }