summaryrefslogtreecommitdiff
path: root/kernel/irq.c
blob: 6034735d848492c6b1418eddeba499be24efa54e (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
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "irq.h"
#include "portio.h"

void irq_init() {
	// ICW1
	outb(0x20, 0x11);
	outb(0xa0, 0x11);
	
	// ICW2 - Offset.
	outb(0x21, 0x20);
	outb(0xa1, 0x28);
	
	// ICW3
	outb(0x21, 0x04);
	outb(0xa1, 0x02);
	
	// ICW4
	outb(0x21, 0x01);
	outb(0xa1, 0x01);
	
	// OCW1 - Mask.
	outb(0x21, 0xfe);
	outb(0xa1, 0xff);
	
	// Initialize timer.
	// TODO: Move this elsewhere.
	outb(0x43, 0x36);
	outb(0x40, 0x00);
	outb(0x40, 0x00);
}

void irq_reset() {
	// OCW2
	outb(0x20, 0x20);
}

void irq_reset_slave() {
	// OCW2
	outb(0xa0, 0x20);
	
	irq_reset();
}