35 lines
859 B
C++
Raw Normal View History

#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-09-05 16:13:51 +02:00
#include "io/IO.h"
#include "io/PIC.h"
#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"
#include "thread/Scheduler.h"
2022-09-05 16:13:51 +02:00
void IRQ::interrupt_handler(Context* context)
2022-09-05 16:13:51 +02:00
{
switch (context->irq_number)
{
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);
bool ignore = false;
char key = translate_scancode(scancode, &ignore);
if (ignore) break;
KeyboardDevice::append(key);
2022-09-05 16:13:51 +02:00
break;
}
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;
}