-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirqs.inc
103 lines (91 loc) · 1.33 KB
/
irqs.inc
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
98
99
100
101
102
103
; Обработчик прерываний IRQ2-IRQ7
irq07:
push ax
mov al, 0x20
out 0x20, al
pop ax
iretd
; Обработчик прерываний IRQ8-IRQ15
irq815:
push ax
mov al, 0x20
out 0xA0, al
pop ax
iretd
; Обработчик прерывания IRQ1
%include "irq1new.inc"
; %1: number
; %2: charater offset
%macro printchar 2
pushad
mov al, %2
mov ah, 8 * 3
mul ah
mov bl, %1
add bl, '0'
mov esi, chars
mov edi, 0
add di, ax
mov cl, 0
mov ch, 255
int 0x31
popad
%endmacro
%macro printhex 2
push es
push fs
pushad
mov ax, ds
mov es, ax
mov fs, ax
mov eax, %1
mov ebx, 16
mov edi, tss_str
int 0x33
mov ah, 8 * 3
mov al, %2
mul ah
mov edi, 0
add di, ax
mov ebp, tss_str
int 0x32
popad
pop fs
pop es
%endmacro
; Обработчик прерывания IRQ0
irq0:
push ax
push bx
mov bl, [cs:counttask]
cmp bl, 0
jz .end
mov ah, 0
mov al, [cs:curtask]
inc al
div bl
mov [cs:curtask], ah
mov bx, 0
mov bl, ah
shl bx, 4
lea bx, [gdt.task0_tss-gdt + bx]
test byte [cs:gdt+bx+5], 10b
; if task busy, return
jnz .end
; else swith to next task
mov word [cs:jmpinf+4], bx
mov al, 0x20
out 0x20, al
pop bx
pop ax
jmp far [cs:jmpinf]
iretd
.end:
mov al, 0x20
out 0x20, al
pop bx
pop ax
iretd
jmpinf:
dd 0
dd 0