summaryrefslogtreecommitdiff
path: root/src/kernel/arch/i386/interrupts/isr.c
blob: 86f697f79eeb8c4d6baa7860df60a3556b8888a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <kernel/arch/i386/interrupts/isr.h>
#include <kernel/arch/log.h>
#include <kernel/panic.h>
#include <stdbool.h>
#include <stdint.h>

#define log_n_panic(x) {tty_const(x); panic();}

bool isr_test_interrupt_called = false;

void isr_stage3(int interrupt) {
	switch (interrupt) {
		case 0x08: log_n_panic("#DF"); // double fault
		case 0x0D: log_n_panic("#GP"); // general protection fault
		case 0x0E: { // page fault
			int cr2;
			tty_const("#PF at ");
			asm ("mov %%cr2, %0;" : "=r"(cr2) ::);
			_tty_var(cr2);
			panic();
		}

		case 0x34:
			isr_test_interrupt_called = true;
			return;

		default:   log_n_panic("unknown interrupt");
	}
}