2022-09-18 09:43:58 +02:00
|
|
|
#define MODULE "irq"
|
|
|
|
|
2022-09-05 16:13:51 +02:00
|
|
|
#include "interrupts/IRQ.h"
|
|
|
|
#include "io/IO.h"
|
|
|
|
#include "io/PIC.h"
|
2022-09-18 09:43:58 +02:00
|
|
|
#include "log/Log.h"
|
2022-09-21 17:56:53 +02:00
|
|
|
#include "misc/reboot.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-09-07 19:41:08 +02:00
|
|
|
[[maybe_unused]] volatile unsigned char scancode = IO::inb(0x60);
|
2022-09-18 09:47:58 +02:00
|
|
|
kdbgln("Keyboard key pressed/released, seconds since boot: %ld.%ld", PIT::ms_since_boot / 1000,
|
2022-09-18 09:43:58 +02:00
|
|
|
PIT::ms_since_boot % 1000);
|
2022-09-20 20:51:59 +02:00
|
|
|
reboot();
|
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;
|
|
|
|
}
|