luciaos/handler.nasm

74 lines
1.1 KiB
NASM
Raw Permalink Normal View History

2024-01-07 22:33:27 -06:00
global PROC_SWITCH
PROC_SWITCH: dw 0
2022-09-14 21:54:59 -05:00
2023-02-10 01:06:42 -06:00
global TIMERVAL
2024-01-07 22:33:27 -06:00
global TIMERVAL_FRAC
TIMERVAL: dd 0
2024-01-07 22:33:27 -06:00
TIMERVAL_FRAC: dd 0
2022-09-14 21:54:59 -05:00
global timerHandler
timerHandler:
push eax
push ds
mov ax, 0x10
mov ds, ax
2024-01-07 22:33:27 -06:00
; Value from PITPgrm
add dword [TIMERVAL_FRAC], 0xfffdb8d0
adc dword [TIMERVAL], 0
2022-09-14 21:54:59 -05:00
mov al, 0x20
out 0x20, al
2024-01-07 22:33:27 -06:00
; Check task switch
movzx eax, word [PROC_SWITCH]
test eax, eax
jnz task_switch
2022-09-14 21:54:59 -05:00
pop ds
pop eax
iret
2024-01-07 22:33:27 -06:00
extern save_current_task_int
task_switch:
mov word [PROC_SWITCH], 0
pop ds
pop eax
call save_current_task_int
iret
2022-09-14 21:54:59 -05:00
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