-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterrupt.s
More file actions
executable file
·98 lines (75 loc) · 1.66 KB
/
interrupt.s
File metadata and controls
executable file
·98 lines (75 loc) · 1.66 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
%define ICW_1 0x11 ; 00010001 binary. Enables initialization mode and we are sending ICW 4
%define PIC_1_CTRL 0x20 ; Primary PIC control register
%define PIC_2_CTRL 0xA0 ; Secondary PIC control register
%define PIC_1_DATA 0x21 ; Primary PIC data register
%define PIC_2_DATA 0xA1 ; Secondary PIC data register
%define IRQ_0 0x20 ; IRQs 0-7 mapped to use interrupts 0x20-0x27
%define IRQ_8 0x28 ; IRQs 8-15 mapped to use interrupts 0x28-0x36
global set_8259a,Load_Idtr,Enable_Int,set_8253,send_eoi,int_handler,sys_call_s,run
global timer_s
extern default_handler,sys_call,timer_c
set_8259a:
mov al, ICW_1
out PIC_1_CTRL, al
out PIC_2_CTRL, al
mov al, IRQ_0
out PIC_1_DATA, al
mov al, IRQ_8
out PIC_2_DATA, al
mov al, 0x4 ; 0x04 => 0100, second bit (IR line 2)
out PIC_1_DATA, al ; write to data register of primary PIC
mov al, 0x2 ; 010=> IR line 2
out PIC_2_DATA, al ; write to data register of secondary PIC
mov al, 1 ; bit 0 enables 80x86 mode
out PIC_1_DATA, al
out PIC_2_DATA, al
mov al, 0
out PIC_1_DATA, al
out PIC_2_DATA, al
ret
Load_Idtr:
push ebp
mov ebp,esp
lidt [ebp+8]
pop ebp
ret
Enable_Int:
sti
ret
set_8253:
mov dx,1193180/100 ; interrupt rate:100HZ
mov al,110110b
out 0x43,al
mov ax,dx
out 0x40,al
xchg ah,al
out 0x40,al
ret
send_eoi:
push eax
mov al,0x20
out 0x20,al
out 0xA0,al
pop eax
ret
int_handler:
pushad
call default_handler
call send_eoi
popad
iret
sys_call_s:
pushad
sti
call sys_call
popad
iret
timer_s:
pushad
call timer_c
call send_eoi
popad
iret
run:
popa
iret