1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00
kernel/arch/hwint.asm

55 lines
971 B
NASM
Raw Normal View History

2017-11-02 22:51:24 -04:00
#include "config.h"
[EXTERN hwint_handler]
%macro HWINT 2
[GLOBAL hwint_%1]
hwint_%1:
cli
push byte 0
push byte %2
jmp hwint_common_stub
%endmacro
HWINT 0, 32
HWINT 1, 33
HWINT 2, 34
HWINT 3, 35
HWINT 4, 36
HWINT 5, 37
HWINT 6, 38
HWINT 7, 39
HWINT 8, 40
HWINT 9, 41
HWINT 10, 42
HWINT 11, 43
HWINT 12, 44
HWINT 13, 45
HWINT 14, 46
HWINT 15, 47
hwint_common_stub:
2017-11-02 22:52:39 -04:00
pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax
2017-11-02 22:51:24 -04:00
2017-11-02 22:52:39 -04:00
mov ax, ds ; Lower 16-bits of eax = ds.
push eax ; save the data segment descriptor
2017-11-02 22:51:24 -04:00
2017-11-02 22:52:39 -04:00
mov ax, GDT_KERNEL_DS_SELECTOR
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
2017-11-02 22:51:24 -04:00
2017-11-02 22:52:39 -04:00
call hwint_handler
2017-11-02 22:51:24 -04:00
2017-11-02 22:52:39 -04:00
pop eax ; reload the original data segment descriptor
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
2017-11-02 22:51:24 -04:00
2017-11-02 22:52:39 -04:00
popa ; Pops edi,esi,ebp...
add esp, 8 ; Cleans up the pushed error code and pushed ISR number
sti
iret ; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP