1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-11-20 11:16:10 -05:00

Some refactoring

This commit is contained in:
Braiden Vasco 2017-11-05 13:50:13 +00:00
parent 33fc1026a9
commit 73ea1e22d5
5 changed files with 86 additions and 86 deletions

View file

@ -17,9 +17,12 @@ OBJS += console.c.o
OBJS += kprintf.c.o
OBJS += protected.c.o protected.asm.cpp.o
OBJS += exception.c.o exception.asm.cpp.o
OBJS += hwint.c.o hwint.asm.cpp.o
OBJS += syscall.c.o syscall.asm.cpp.o
OBJS += interrupt.asm.cpp.o
OBJS += exception.c.o
OBJS += hwint.c.o
OBJS += syscall.c.o
OBJS += timer.c.o

View file

@ -1,38 +0,0 @@
#include "config.h"
%include "interrupt.asm"
INTERRUPT_COMMON exception_handler, GDT_KERNEL_DS_SELECTOR
INTERRUPT_NOERRCODE 0 ; #DE - Divide Error Exception
INTERRUPT_NOERRCODE 1 ; #DB - Debug Exception
INTERRUPT_NOERRCODE 2 ; NMI - Non-maskable interrupt
INTERRUPT_NOERRCODE 3 ; #BP - Breakpoint Exception
INTERRUPT_NOERRCODE 4 ; #OF - Overflow Exception
INTERRUPT_NOERRCODE 5 ; #BR - BOUND Range Exceeded Exception
INTERRUPT_NOERRCODE 6 ; #UD - Invalid Opcode Exception
INTERRUPT_NOERRCODE 7 ; #NM - Device Not Available Exception
INTERRUPT_ERRCODE 8 ; #DF - Double Fault Exception
INTERRUPT_NOERRCODE 9 ; Reserved - Coprocessor Segment Overrun
INTERRUPT_ERRCODE 10 ; #TS - Invalid TSS Exception
INTERRUPT_ERRCODE 11 ; #NP - Segment Not Present
INTERRUPT_ERRCODE 12 ; #SS - Stack Fault Exception
INTERRUPT_ERRCODE 13 ; #GP - General Protection Exception
INTERRUPT_ERRCODE 14 ; #PF - Page-Fault Exception
INTERRUPT_NOERRCODE 15 ; Reserved
INTERRUPT_NOERRCODE 16 ; #MF - x87 FPU Floating-Point Error
INTERRUPT_ERRCODE 17 ; #AC - Alignment Check Exception
INTERRUPT_NOERRCODE 18 ; #MC - Machine-Check Exception
INTERRUPT_NOERRCODE 19 ; #XF - SIMD Floating-Point Exception
INTERRUPT_NOERRCODE 20 ; Reserved
INTERRUPT_NOERRCODE 21 ; Reserved
INTERRUPT_NOERRCODE 22 ; Reserved
INTERRUPT_NOERRCODE 23 ; Reserved
INTERRUPT_NOERRCODE 24 ; Reserved
INTERRUPT_NOERRCODE 25 ; Reserved
INTERRUPT_NOERRCODE 26 ; Reserved
INTERRUPT_NOERRCODE 27 ; Reserved
INTERRUPT_NOERRCODE 28 ; Reserved
INTERRUPT_NOERRCODE 29 ; Reserved
INTERRUPT_NOERRCODE 30 ; Reserved
INTERRUPT_NOERRCODE 31 ; Reserved

View file

@ -1,23 +0,0 @@
#include "config.h"
%include "interrupt.asm"
INTERRUPT_COMMON hwint_handler, GDT_KERNEL_DS_SELECTOR
INTERRUPT_NOERRCODE 32 ; Programmable Interval Timer
INTERRUPT_NOERRCODE 33 ; Keyboard
INTERRUPT_NOERRCODE 34 ; Slave PIC
INTERRUPT_NOERRCODE 35 ; COM 2/4
INTERRUPT_NOERRCODE 36 ; COM 1/3
INTERRUPT_NOERRCODE 37 ; LPT 2
INTERRUPT_NOERRCODE 38 ; Floppy Drive Controller
INTERRUPT_NOERRCODE 39 ; LPT 1
INTERRUPT_NOERRCODE 40 ; Real Time Clock
INTERRUPT_NOERRCODE 41 ; Master PIC
INTERRUPT_NOERRCODE 42 ; Reserved
INTERRUPT_NOERRCODE 43 ; Reserved
INTERRUPT_NOERRCODE 44 ; Reserved
INTERRUPT_NOERRCODE 45 ; Coprocessor exception
INTERRUPT_NOERRCODE 46 ; Hard Drive Controller
INTERRUPT_NOERRCODE 47 ; Reserved

View file

@ -1,35 +1,37 @@
%macro INTERRUPT_NOERRCODE 1
[GLOBAL interrupt_%1]
interrupt_%1:
#include "config.h"
%macro INTERRUPT_NOERRCODE 2
[GLOBAL interrupt_%2]
interrupt_%2:
cli
push byte 0
push byte %1
jmp interrupt_common
push byte %2
jmp %1_wrapper
%endmacro
%macro INTERRUPT_ERRCODE 1
[GLOBAL interrupt_%1]
interrupt_%1:
%macro INTERRUPT_ERRCODE 2
[GLOBAL interrupt_%2]
interrupt_%2:
cli
push byte %1
jmp interrupt_common
push byte %2
jmp %1_wrapper
%endmacro
%macro INTERRUPT_COMMON 2
[EXTERN %1]
interrupt_common:
%macro INTERRUPT_COMMON 1
[EXTERN %1_handler]
%1_wrapper:
pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax
mov ax, ds ; Lower 16-bits of eax = ds.
push eax ; save the data segment descriptor
mov ax, %2
mov ax, GDT_KERNEL_DS_SELECTOR
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
call %1
call %1_handler
pop eax ; reload the original data segment descriptor
mov ds, ax
@ -42,3 +44,66 @@ interrupt_common:
sti
iret ; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP
%endmacro
INTERRUPT_COMMON exception
INTERRUPT_COMMON hwint
INTERRUPT_COMMON syscall
; Protected mode exteptions
INTERRUPT_NOERRCODE exception, 0 ; #DE - Divide Error Exception
INTERRUPT_NOERRCODE exception, 1 ; #DB - Debug Exception
INTERRUPT_NOERRCODE exception, 2 ; NMI - Non-maskable interrupt
INTERRUPT_NOERRCODE exception, 3 ; #BP - Breakpoint Exception
INTERRUPT_NOERRCODE exception, 4 ; #OF - Overflow Exception
INTERRUPT_NOERRCODE exception, 5 ; #BR - BOUND Range Exceeded Exception
INTERRUPT_NOERRCODE exception, 6 ; #UD - Invalid Opcode Exception
INTERRUPT_NOERRCODE exception, 7 ; #NM - Device Not Available Exception
INTERRUPT_ERRCODE exception, 8 ; #DF - Double Fault Exception
INTERRUPT_NOERRCODE exception, 9 ; Reserved - Coprocessor Segment Overrun
INTERRUPT_ERRCODE exception, 10 ; #TS - Invalid TSS Exception
INTERRUPT_ERRCODE exception, 11 ; #NP - Segment Not Present
INTERRUPT_ERRCODE exception, 12 ; #SS - Stack Fault Exception
INTERRUPT_ERRCODE exception, 13 ; #GP - General Protection Exception
INTERRUPT_ERRCODE exception, 14 ; #PF - Page-Fault Exception
INTERRUPT_NOERRCODE exception, 15 ; Reserved
INTERRUPT_NOERRCODE exception, 16 ; #MF - x87 FPU Floating-Point Error
INTERRUPT_ERRCODE exception, 17 ; #AC - Alignment Check Exception
INTERRUPT_NOERRCODE exception, 18 ; #MC - Machine-Check Exception
INTERRUPT_NOERRCODE exception, 19 ; #XF - SIMD Floating-Point Exception
INTERRUPT_NOERRCODE exception, 20 ; Reserved
INTERRUPT_NOERRCODE exception, 21 ; Reserved
INTERRUPT_NOERRCODE exception, 22 ; Reserved
INTERRUPT_NOERRCODE exception, 23 ; Reserved
INTERRUPT_NOERRCODE exception, 24 ; Reserved
INTERRUPT_NOERRCODE exception, 25 ; Reserved
INTERRUPT_NOERRCODE exception, 26 ; Reserved
INTERRUPT_NOERRCODE exception, 27 ; Reserved
INTERRUPT_NOERRCODE exception, 28 ; Reserved
INTERRUPT_NOERRCODE exception, 29 ; Reserved
INTERRUPT_NOERRCODE exception, 30 ; Reserved
INTERRUPT_NOERRCODE exception, 31 ; Reserved
; Hardware IRQs
INTERRUPT_NOERRCODE hwint, 32 ; Programmable Interval Timer
INTERRUPT_NOERRCODE hwint, 33 ; Keyboard
INTERRUPT_NOERRCODE hwint, 34 ; Slave PIC
INTERRUPT_NOERRCODE hwint, 35 ; COM 2/4
INTERRUPT_NOERRCODE hwint, 36 ; COM 1/3
INTERRUPT_NOERRCODE hwint, 37 ; LPT 2
INTERRUPT_NOERRCODE hwint, 38 ; Floppy Drive Controller
INTERRUPT_NOERRCODE hwint, 39 ; LPT 1
INTERRUPT_NOERRCODE hwint, 40 ; Real Time Clock
INTERRUPT_NOERRCODE hwint, 41 ; Master PIC
INTERRUPT_NOERRCODE hwint, 42 ; Reserved
INTERRUPT_NOERRCODE hwint, 43 ; Reserved
INTERRUPT_NOERRCODE hwint, 44 ; Reserved
INTERRUPT_NOERRCODE hwint, 45 ; Coprocessor exception
INTERRUPT_NOERRCODE hwint, 46 ; Hard Drive Controller
INTERRUPT_NOERRCODE hwint, 47 ; Reserved
; Syscalls
INTERRUPT_NOERRCODE syscall, INT_SYSCALL

View file

@ -1,7 +0,0 @@
#include "config.h"
%include "interrupt.asm"
INTERRUPT_COMMON syscall_handler, GDT_KERNEL_DS_SELECTOR
INTERRUPT_NOERRCODE INT_SYSCALL