2022-09-18 09:43:58 +02:00
|
|
|
#define MODULE "irq"
|
|
|
|
|
2022-09-05 16:13:51 +02:00
|
|
|
#include "interrupts/IRQ.h"
|
2022-10-19 19:42:05 +02:00
|
|
|
#include "fs/devices/Keyboard.h"
|
2022-11-02 19:51:54 +01:00
|
|
|
#include "fs/devices/Console.h"
|
2022-09-05 16:13:51 +02:00
|
|
|
#include "io/IO.h"
|
|
|
|
#include "io/PIC.h"
|
2022-09-18 09:43:58 +02:00
|
|
|
#include "log/Log.h"
|
2022-10-19 19:42:05 +02:00
|
|
|
#include "misc/Scancodes.h"
|
2022-09-14 18:54:40 +02:00
|
|
|
#include "rand/Init.h"
|
2022-09-05 16:13:51 +02:00
|
|
|
#include "std/stdio.h"
|
2022-09-21 17:56:53 +02:00
|
|
|
#include "thread/PIT.h"
|
2022-09-20 19:58:04 +02:00
|
|
|
#include "thread/Scheduler.h"
|
2022-09-05 16:13:51 +02:00
|
|
|
|
2022-09-20 19:56:43 +02:00
|
|
|
void IRQ::interrupt_handler(Context* context)
|
2022-09-05 16:13:51 +02:00
|
|
|
{
|
|
|
|
switch (context->irq_number)
|
|
|
|
{
|
2022-09-20 19:58:04 +02:00
|
|
|
case 0:
|
|
|
|
PIT::tick();
|
|
|
|
Scheduler::task_tick(context);
|
|
|
|
break;
|
2022-09-05 16:13:51 +02:00
|
|
|
case 1: {
|
2022-10-19 19:42:05 +02:00
|
|
|
unsigned char scancode = IO::inb(0x60);
|
2022-11-02 19:51:54 +01:00
|
|
|
KeyboardDevice::append((char)scancode);
|
2022-10-19 19:42:05 +02:00
|
|
|
bool ignore = false;
|
|
|
|
char key = translate_scancode(scancode, &ignore);
|
|
|
|
if (ignore) break;
|
2022-11-02 19:51:54 +01:00
|
|
|
ConsoleDevice::append(key);
|
2022-09-05 16:13:51 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-09-18 09:43:58 +02:00
|
|
|
default: kwarnln("Unhandled IRQ: %ld", context->irq_number); break;
|
2022-09-05 16:13:51 +02:00
|
|
|
}
|
2022-09-14 18:54:40 +02:00
|
|
|
Mersenne::reseed();
|
2022-10-06 17:13:34 +02:00
|
|
|
PIC::send_eoi((unsigned char)(context->irq_number & 0xFF));
|
2022-09-05 16:13:51 +02:00
|
|
|
return;
|
|
|
|
}
|