]> git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/arch/x86/irq/sample_handler.c
Add Intel 8254 driver and print elapsed seconds
[nameless-os.git] / kernel / arch / x86 / irq / sample_handler.c
1 #include <tty.h>
2 #include <irq/i8259a.h>
3 #include <io.h>
4 #include <stdint.h>
5 #include <time/i8254.h>
6
7 unsigned int ticks = 0;
8
9 typedef uint32_t uword_t;
10
11 struct interrupt_frame {
12 uword_t ip;
13 uword_t cs;
14 uword_t flags;
15 };
16
17 struct abort_frame;
18
19 __attribute__((interrupt))
20 void keyb_handler(struct interrupt_frame *frame)
21 {
22 pic_send_eoi(1);
23 kprint("Got a keyboard interrupt!\n", 0);
24 inb(0x60);
25 }
26
27
28 __attribute__((interrupt))
29 void double_fault(struct abort_frame *frame)
30 {
31 *(volatile uint32_t *) (0xb8000) = 0xcf28cf3a;
32 halt:
33 asm volatile ("cli; hlt");
34 goto halt;
35 }
36
37
38 __attribute__((interrupt))
39 void timer_tick(struct interrupt_frame *frame)
40 {
41 pic_send_eoi(0);
42 ticks++;
43 }