fix: correction interruptions, version fonctionnelle

This commit is contained in:
Nicolas Hordé 2018-08-17 11:17:24 +02:00
parent b09af8b250
commit d29fa15861
5 changed files with 160 additions and 81 deletions

View File

@ -8,8 +8,15 @@
#define nop() asm("nop"::) #define nop() asm("nop"::)
#define iret() asm("addl $0x0C, %esp; \ #define pushad() asm("pushal"::)
iret;")
#define popad() asm("popal"::)
#define pushf() asm("pushf"::)
#define popf() asm("popf"::)
#define iret() asm("iret"::)
#define irqendmaster() asm("movb $0x20,%al; \ #define irqendmaster() asm("movb $0x20,%al; \
outb %al,$0x20;") outb %al,$0x20;")

101
lib/idt.c
View File

@ -111,7 +111,11 @@ void cpuerror(const u8 *src)
void interruption() void interruption()
{ {
cli(); cli();
pushf();
pushad();
print("Appel d'une interruption\r\n"); print("Appel d'une interruption\r\n");
popad();
popf();
sti(); sti();
iret(); iret();
} }
@ -119,260 +123,316 @@ void interruption()
void exception0() void exception0()
{ {
print("divide error\r\n"); print("divide error\r\n");
iret();
} }
void exception1() void exception1()
{ {
cpuerror("debug exception\r\n"); cpuerror("debug exception\r\n");
iret();
} }
void exception2() void exception2()
{ {
cpuerror("non-maskable hardware interrupt\r\n"); cpuerror("non-maskable hardware interrupt\r\n");
iret();
} }
void exception3() void exception3()
{ {
cpuerror("INT3 instruction\r\n"); cpuerror("INT3 instruction\r\n");
iret();
} }
void exception4() void exception4()
{ {
cpuerror("INTO instruction detected overflow\r\n"); cpuerror("INTO instruction detected overflow\r\n");
iret();
} }
void exception5() void exception5()
{ {
print("BOUND instruction detected overrange\r\n"); print("BOUND instruction detected overrange\r\n");
iret();
} }
void exception6() void exception6()
{ {
cpuerror("invalid instruction opcode\r\n"); cpuerror("invalid instruction opcode\r\n");
iret();
} }
void exception7() void exception7()
{ {
cpuerror("no coprocessor\r\n"); cpuerror("no coprocessor\r\n");
iret();
} }
void exception8() void exception8()
{ {
cpuerror("double fault\r\n"); cpuerror("double fault\r\n");
iret();
} }
void exception9() void exception9()
{ {
cpuerror("coprocessor segment overrun\r\n"); cpuerror("coprocessor segment overrun\r\n");
iret();
} }
void exception10() void exception10()
{ {
cpuerror("invalid task state segment (TSS)\r\n"); cpuerror("invalid task state segment (TSS)\r\n");
iret();
} }
void exception11() void exception11()
{ {
cpuerror("segment not present\r\n"); cpuerror("segment not present\r\n");
iret();
} }
void exception12() void exception12()
{ {
cpuerror("stack fault"); cpuerror("stack fault");
iret();
} }
void exception13() void exception13()
{ {
cpuerror("general protection fault (GPF)\r\n"); cpuerror("general protection fault (GPF)\r\n");
iret();
} }
void exception14() void exception14()
{ {
cpuerror("page fault\r\n"); cpuerror("page fault\r\n");
iret();
} }
void exception15() void exception15()
{ {
cpuerror("(reserved)\r\n"); cpuerror("(reserved)\r\n");
iret();
} }
void exception16() void exception16()
{ {
cpuerror("coprocessor error\r\n"); cpuerror("coprocessor error\r\n");
iret();
} }
void exception17() void exception17()
{ {
cpuerror("alignment check\r\n"); cpuerror("alignment check\r\n");
iret();
} }
void exception18() void exception18()
{ {
cpuerror("machine check"); cpuerror("machine check");
iret();
} }
void irq0() void irq0()
{ {
cli(); cli();
pushf();
pushad();
print("irq 0"); print("irq 0");
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq1() void irq1()
{ {
cli(); cli();
pushf();
pushad();
print("irq 1"); print("irq 1");
while ((inb(0x64)&1)==0); while ((inb(0x64)&1)==0);
inb(0x60); inb(0x60);
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq2() void irq2()
{ {
cli(); cli();
pushf();
pushad();
print("irq 2"); print("irq 2");
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq3() void irq3()
{ {
cli(); cli();
pushf();
pushad();
print("irq 3"); print("irq 3");
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq4() void irq4()
{ {
cli(); cli();
pushf();
pushad();
print("irq 4"); print("irq 4");
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq5() void irq5()
{ {
cli(); cli();
pushf();
pushad();
print("irq 5"); print("irq 5");
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq6() void irq6()
{ {
cli(); cli();
pushf();
pushad();
print("irq 6"); print("irq 6");
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq7() void irq7()
{ {
cli(); cli();
pushf();
pushad();
print("irq 7"); print("irq 7");
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq8() void irq8()
{ {
cli(); cli();
pushf();
pushad();
print("irq 8"); print("irq 8");
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq9() void irq9()
{ {
cli(); cli();
pushf();
pushad();
print("irq 9"); print("irq 9");
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq10() void irq10()
{ {
cli(); cli();
pushf();
pushad();
print("irq 10"); print("irq 10");
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq11() void irq11()
{ {
cli(); cli();
pushf();
pushad();
print("irq 11"); print("irq 11");
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq12() void irq12()
{ {
cli(); cli();
pushf();
pushad();
print("irq 12"); print("irq 12");
while ((inb(0x64)&1)==0); while ((inb(0x64)&1)==0);
inb(0x60); inb(0x60);
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq13() void irq13()
{ {
cli(); cli();
pushf();
pushad();
print("irq 13"); print("irq 13");
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
void irq14() void irq14()
{ {
cli(); cli();
pushf();
pushad();
print("irq 14"); print("irq 14");
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }
@ -382,7 +442,10 @@ void irq15()
print("irq 15"); print("irq 15");
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x01C, %esp;");
iret(); iret();
} }

View File

@ -285,7 +285,9 @@ if ((bufferscan[lastscan]==0xE0)||((kbdstatus & STATUS_NUM)&&(key>=0x47)&&(key<=
void keyboard() void keyboard()
{ {
printf("test"); cli();
pushf();
pushad();
u8 scancode,ascii; u8 scancode,ascii;
cli(); cli();
while ((inb(0x64)&1)==0); while ((inb(0x64)&1)==0);
@ -293,14 +295,16 @@ scancode=inb(0x60);
ascii = convert(scancode); ascii = convert(scancode);
if(ascii != 0) if(ascii != 0)
{ {
putchar(ascii);
ptrascii++; ptrascii++;
if (ptrascii==255) ptrascii==0; if (ptrascii==255) ptrascii==0;
bufferascii[ptrascii]=ascii; bufferascii[ptrascii]=ascii;
} }
irqendmaster(); irqendmaster();
sti(); popad();
iret(); popf();
sti();
asm("addl $0x01C, %esp;");
iret();
} }
/******************************************************************************/ /******************************************************************************/

View File

@ -13,10 +13,15 @@ static u8 curspos=0;
void timer() void timer()
{ {
cli(); cli();
pushf();
pushad();
showchar(0,0,curs[curspos],7); showchar(0,0,curs[curspos],7);
curspos=(curspos+1)&0x3; curspos=(curspos+1)&0x3;
irqendmaster(); irqendmaster();
popad();
popf();
sti(); sti();
asm("addl $0x1C,%esp;iret;"); asm("addl $0x0C, %esp;");
iret();
} }

View File

@ -45,7 +45,7 @@ int main(void) {
ok(); ok();
print("Activation de l'IRQ 0\000"); print("Activation de l'IRQ 0\000");
//enableirq(0); enableirq(0);
ok(); ok();
print("Installation du handler clavier\000"); print("Installation du handler clavier\000");