37 lines
938 B
C++
37 lines
938 B
C++
#define MODULE "irq"
|
|
|
|
#include "interrupts/IRQ.h"
|
|
#include "fs/devices/Console.h"
|
|
#include "fs/devices/Keyboard.h"
|
|
#include "io/IO.h"
|
|
#include "io/PIC.h"
|
|
#include "log/Log.h"
|
|
#include "misc/Scancodes.h"
|
|
#include "rand/Init.h"
|
|
#include "std/stdio.h"
|
|
#include "thread/PIT.h"
|
|
#include "thread/Scheduler.h"
|
|
|
|
void IRQ::interrupt_handler(Context* context)
|
|
{
|
|
switch (context->irq_number)
|
|
{
|
|
case 0:
|
|
PIT::tick();
|
|
Scheduler::task_tick(context);
|
|
break;
|
|
case 1: {
|
|
unsigned char scancode = IO::inb(0x60);
|
|
KeyboardDevice::append((char)scancode);
|
|
bool ignore = false;
|
|
char key = translate_scancode(scancode, &ignore);
|
|
if (ignore) break;
|
|
ConsoleDevice::append(key);
|
|
break;
|
|
}
|
|
default: kwarnln("Unhandled IRQ: %ld", context->irq_number); break;
|
|
}
|
|
Mersenne::reseed();
|
|
PIC::send_eoi((unsigned char)(context->irq_number & 0xFF));
|
|
return;
|
|
} |