aboutsummaryrefslogtreecommitdiff
path: root/src/utils/pic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/pic.c')
-rw-r--r--src/utils/pic.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/src/utils/pic.c b/src/utils/pic.c
index f811d04..7681a13 100644
--- a/src/utils/pic.c
+++ b/src/utils/pic.c
@@ -1,6 +1,7 @@
#include "pic.h"
#include "asm.h"
#include "mem.h"
+#include "syscall.h"
struct IDT_REGISTER IDTR={
200*8,
@@ -9,32 +10,65 @@ struct IDT_REGISTER IDTR={
/// Bridge between IDT and functions call
asm (
-"PIC_IRQ_DEFAULT:"
+".macro SAVE_REGS \n\t"
+ "pushal \n\t"
+ "push %ds \n\t"
+ "push %es \n\t"
+ "push %fs \n\t"
+ "push %gs \n\t"
+ "push %ebx \n\t"
+ "mov $0x10,%bx \n\t"
+ "mov %bx,%ds \n\t"
+ "pop %ebx \n\t"
+".endm \n\t"
+".macro RESTORE_REGS \n\t"
+ "pop %gs \n\t"
+ "pop %fs \n\t"
+ "pop %es \n\t"
+ "pop %ds \n\t"
+ "popal \n\t"
+".endm \n\t"
+"PIC_IRQ_DEFAULT: \n\t"
+ "SAVE_REGS \n\t"
"movb $0x20, %al \n\t"
"outb %al, $0x20 \n\t"
+ "RESTORE_REGS \n\t"
"iret \n\t"
"PIC_IRQ_PRINT: \n\t"
+ "SAVE_REGS \n\t"
"call _8042_keypress \n\t"
"movb $0x20, %al \n\t"
"outb %al, $0x20 \n\t"
+ "RESTORE_REGS \n\t"
"iret \n\t"
"PIC_IRQ_CLOCK: \n\t"
+ "SAVE_REGS \n\t"
"call clock \n\t"
"movb $0x20, %al \n\t"
"outb %al, $0x20 \n\t"
+ "RESTORE_REGS \n\t"
+ "iret \n\t"
+"PIC_IRQ_SYSCALL: \n\t"
+ "SAVE_REGS \n\t"
+ "call syscall \n\t"
+ "movb $0x20, %al \n\t"
+ "outb %al, $0x20 \n\t"
+ "RESTORE_REGS \n\t"
"iret \n\t"
);
-extern u32 PIC_IRQ_DEFAULT,PIC_IRQ_PRINT,PIC_IRQ_CLOCK;
+extern u32 PIC_IRQ_DEFAULT,PIC_IRQ_PRINT,PIC_IRQ_CLOCK, PIC_IRQ_SYSCALL;
void pic_enable_interrupt(){
// Map first default 32 entries
for(int i=0;i<200;i++){
- pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_DEFAULT,IDT_TYPE_1},i);
+ pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_DEFAULT,IDT_INT_GATE},i);
if(i==32)
- pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_CLOCK,IDT_TYPE_1},i);
+ pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_CLOCK,IDT_INT_GATE},i);
if(i==33)
- pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_PRINT,IDT_TYPE_1},i);
+ pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_PRINT,IDT_INT_GATE},i);
+ if(i==48)
+ pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_SYSCALL,IDT_TRAP_GATE},i);
}
// Now configure 8952A