2022-09-18 07:43:58 +00:00
|
|
|
#define MODULE "irq"
|
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
#include "interrupts/IRQ.h"
|
|
|
|
#include "io/IO.h"
|
|
|
|
#include "io/PIC.h"
|
2022-09-18 07:43:58 +00:00
|
|
|
#include "log/Log.h"
|
2022-09-21 15:56:53 +00:00
|
|
|
#include "misc/reboot.h"
|
2022-09-14 16:54:40 +00:00
|
|
|
#include "rand/Init.h"
|
2022-09-05 14:13:51 +00:00
|
|
|
#include "std/stdio.h"
|
2022-09-21 15:56:53 +00:00
|
|
|
#include "thread/PIT.h"
|
2022-09-20 17:58:04 +00:00
|
|
|
#include "thread/Scheduler.h"
|
2022-09-05 14:13:51 +00:00
|
|
|
|
2022-09-20 17:56:43 +00:00
|
|
|
void IRQ::interrupt_handler(Context* context)
|
2022-09-05 14:13:51 +00:00
|
|
|
{
|
|
|
|
switch (context->irq_number)
|
|
|
|
{
|
2022-09-20 17:58:04 +00:00
|
|
|
case 0:
|
|
|
|
PIT::tick();
|
|
|
|
Scheduler::task_tick(context);
|
|
|
|
break;
|
2022-09-05 14:13:51 +00:00
|
|
|
case 1: {
|
2022-09-07 17:41:08 +00:00
|
|
|
[[maybe_unused]] volatile unsigned char scancode = IO::inb(0x60);
|
2022-09-18 07:47:58 +00:00
|
|
|
kdbgln("Keyboard key pressed/released, seconds since boot: %ld.%ld", PIT::ms_since_boot / 1000,
|
2022-09-18 07:43:58 +00:00
|
|
|
PIT::ms_since_boot % 1000);
|
2022-09-20 18:51:59 +00:00
|
|
|
reboot();
|
2022-09-05 14:13:51 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-09-18 07:43:58 +00:00
|
|
|
default: kwarnln("Unhandled IRQ: %ld", context->irq_number); break;
|
2022-09-05 14:13:51 +00:00
|
|
|
}
|
2022-09-14 16:54:40 +00:00
|
|
|
Mersenne::reseed();
|
2022-09-05 14:13:51 +00:00
|
|
|
PIC::send_eoi(context->irq_number);
|
|
|
|
return;
|
|
|
|
}
|