Fix a silly issue with the Interrupts using bits instead of bytes when reading and writing ports.

This commit is contained in:
Curle 2019-08-19 22:54:08 +01:00
parent bec10bcee8
commit 24aad1e4a5

View File

@ -50,6 +50,7 @@ void ISR_Common(INTERRUPT_FRAME* Frame, size_t Exception) {
if(Exception < 32) {
/* exception_messages is an array of c-strings defined in kernel.h */
// TODO: Serial!
//serial_print(0x3F8, exception_messages[Exception]);
//serial_print(0x3F8, " Exception.\r\n");
printf("%s exception!", ExceptionStrings[Exception]);
@ -89,26 +90,26 @@ void IRQ_Common(INTERRUPT_FRAME* Frame, size_t Interrupt) {
/* The Slave PIC must be told it's been read in order to receive another 8+ IRQ. */
if(Interrupt > 7)
WritePort(0xA0, 0x20, 8);
WritePort(0xA0, 0x20, 1);
/* In either case, we tell the Master PIC it's been read to receive any IRQ. */
WritePort(0x20, 0x20, 8);
WritePort(0x20, 0x20, 1);
}
/* However, in order to actually be able to receive IRQs, we need to remap the PICs. */
void RemapIRQControllers() {
/* 0x20 is the Master PIC,
0xA0 is the Slave PIC. */
WritePort(0x20, 0x11, 8);
WritePort(0xA0, 0x11, 8);
WritePort(0x21, 0x20, 8);
WritePort(0xA1, 0x28, 8);
WritePort(0x21, 0x04, 8);
WritePort(0xA1, 0x02, 8);
WritePort(0x21, 0x01, 8);
WritePort(0xA1, 0x01, 8);
WritePort(0x21, 0x0, 8);
WritePort(0xA1, 0x0, 8);
WritePort(0x20, 0x11, 1);
WritePort(0xA0, 0x11, 1);
WritePort(0x21, 0x20, 1);
WritePort(0xA1, 0x28, 1);
WritePort(0x21, 0x04, 1);
WritePort(0xA1, 0x02, 1);
WritePort(0x21, 0x01, 1);
WritePort(0xA1, 0x01, 1);
WritePort(0x21, 0x0, 1);
WritePort(0xA1, 0x0, 1);
}
/* In order to actually handle the IRQs, though, we need to tell the kernel *where* the handlers are. */
@ -150,6 +151,11 @@ void UninstallIRQHandler(int IRQ) {
*/
__attribute__((interrupt)) void ISR0Handler(INTERRUPT_FRAME* Frame) {
// This baby is the timer.
// TODO: Change ISR0Handler to TimerHandler.
// Here, we can do some timer related stuff.
// For starts, we just tick a timer that tells us how long the program has been running.
time++;
ISR_Common(Frame, 0);
}
__attribute__((interrupt)) void ISR1Handler(INTERRUPT_FRAME* Frame) {