74 lines
1.1 KiB
NASM
74 lines
1.1 KiB
NASM
global PROC_SWITCH
|
|
PROC_SWITCH: dw 0
|
|
|
|
global TIMERVAL
|
|
global TIMERVAL_FRAC
|
|
TIMERVAL: dd 0
|
|
TIMERVAL_FRAC: dd 0
|
|
global timerHandler
|
|
timerHandler:
|
|
push eax
|
|
push ds
|
|
mov ax, 0x10
|
|
mov ds, ax
|
|
; Value from PITPgrm
|
|
add dword [TIMERVAL_FRAC], 0xfffdb8d0
|
|
adc dword [TIMERVAL], 0
|
|
mov al, 0x20
|
|
out 0x20, al
|
|
; Check task switch
|
|
movzx eax, word [PROC_SWITCH]
|
|
test eax, eax
|
|
jnz task_switch
|
|
pop ds
|
|
pop eax
|
|
iret
|
|
|
|
extern save_current_task_int
|
|
task_switch:
|
|
mov word [PROC_SWITCH], 0
|
|
pop ds
|
|
pop eax
|
|
call save_current_task_int
|
|
iret
|
|
|
|
|
|
global picInit
|
|
picInit:
|
|
mov al, 0x11 ; initialization sequence
|
|
out 0x20, al ; send to 8259A-1
|
|
jmp $+2
|
|
jmp $+2
|
|
out 0xA0, al ; and to 8259A-2
|
|
jmp $+2
|
|
jmp $+2
|
|
mov al, 0x20 ; start of hardware ints (0x20)
|
|
out 0x21, al
|
|
jmp $+2
|
|
jmp $+2
|
|
mov al, 0x28 ; start of hardware ints 2 (0x28)
|
|
out 0xA1, al
|
|
jmp $+2
|
|
jmp $+2
|
|
mov al, 0x04 ; 8259-1 is master
|
|
out 0x21, al
|
|
jmp $+2
|
|
jmp $+2
|
|
mov al, 0x02 ; 8259-2 is slave
|
|
out 0xA1, al
|
|
jmp $+2
|
|
jmp $+2
|
|
mov al, 0x01 ; 8086 mode for both
|
|
out 0x21, al
|
|
jmp $+2
|
|
jmp $+2
|
|
out 0xA1, al
|
|
jmp $+2
|
|
jmp $+2
|
|
mov al, 0xFF ; all interrupts off for now
|
|
out 0x21, al
|
|
jmp $+2
|
|
jmp $+2
|
|
out 0xA1, al
|
|
ret
|