1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Merge branch 'cpu&memory' into BetterTerm

This commit is contained in:
Adrien Bourmault 2019-04-24 23:00:29 +02:00
commit ac0b194f52
4 changed files with 21 additions and 8 deletions

View File

@ -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
//

View File

@ -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);
}
}

View File

@ -27,8 +27,6 @@
#include <extras/buf.h>
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);
}

View File

@ -27,8 +27,6 @@
#include <extras/buf.h>
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* ");
}