From 59bd638188f321992fb756b3b8041c878c3c27ff Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 25 Apr 2019 23:09:04 +0200 Subject: [PATCH] reworking on IDT --- include/kernel/idt.h | 2 +- kaleid/kernel/cpu/idt.c | 2 +- kaleid/kernel/cpu/isr.asm | 17 ++++++++++++----- kaleid/kernel/cpu/isr.inc | 16 ++++++++++++---- kaleid/kernel/init/init.c | 14 ++++++++------ 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/include/kernel/idt.h b/include/kernel/idt.h index 3083a20..62263dc 100644 --- a/include/kernel/idt.h +++ b/include/kernel/idt.h @@ -89,7 +89,7 @@ static char *IsrExceptions[32] = { void IdtRegisterIrq(void (*isr)(void), uchar irq, uchar flags); void IdtSetup(void); void IdtSetGate(uchar rank, ulong base, ushort selector, uchar flags); -void IdtHandler(ulong intNo); +//void IdtHandler(ulong intNo); static void EnablePIC(void); void SendEOItoPIC(uchar isr); diff --git a/kaleid/kernel/cpu/idt.c b/kaleid/kernel/cpu/idt.c index 5dfb88b..b3f01b3 100644 --- a/kaleid/kernel/cpu/idt.c +++ b/kaleid/kernel/cpu/idt.c @@ -200,6 +200,6 @@ void IdtHandler(ulong intNo) KeStartPanic("[ISR 0x%x] Irrecoverable %s\n", intNo, exceptionMsg); } else { bprintf(BStdOut, "[ISR 0x%x] %s\n", intNo, exceptionMsg); - IoSendEOItoPIC(intNo); + //IoSendEOItoPIC(intNo); } } diff --git a/kaleid/kernel/cpu/isr.asm b/kaleid/kernel/cpu/isr.asm index 3491e6f..3633b44 100644 --- a/kaleid/kernel/cpu/isr.asm +++ b/kaleid/kernel/cpu/isr.asm @@ -52,18 +52,25 @@ divideByZero: ;; ISR handler ;; isrPreHandler: - pushAll - - xor rax, rax mov ax, ds push rax + mov ax, 0x0 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + call IdtHandler - pop rax - mov ds, ax + pop rbx + mov ds, bx + mov es, bx + mov fs, bx + mov gs, bx popAll + add rsp, 8 sti iretq diff --git a/kaleid/kernel/cpu/isr.inc b/kaleid/kernel/cpu/isr.inc index 8f65def..6aad457 100644 --- a/kaleid/kernel/cpu/isr.inc +++ b/kaleid/kernel/cpu/isr.inc @@ -21,6 +21,9 @@ ; You should have received a copy of the GNU General Public License ; ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; + +[BITS 64] + %macro pushAll 0 push rax push rcx @@ -42,17 +45,22 @@ %endmacro %macro IsrWithoutErrCode 1 - global isr%1 - isr%1: +global isr%1 +isr%1: cli + push byte 0 + pushAll + xor rdi, rdi mov rdi, %1 jmp isrPreHandler %endmacro %macro IsrWithErrCode 1 - global isr%1 - isr%1: +global isr%1 +isr%1: cli + pushAll + xor rdi, rdi mov rdi, %1 jmp isrPreHandler %endmacro diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 781b47a..c92dc06 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -94,12 +94,14 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) IoPrintRtcTime(); - KernLog("There was %d ticks\n", IoGetRtcTicks()); - for (uint i = 1; i < 10 ; i++) { - while (IoGetRtcTicks() < i * 10000) { - } - IoPrintRtcTime(); - } + /* KernLog("There was %d ticks\n", IoGetRtcTicks()); */ + /* for (uint i = 1; i < 2 ; i++) { */ + /* while (IoGetRtcTicks() < i * 10000) { */ + /* } */ + /* IoPrintRtcTime(); */ + /* } */ + long var = -1; + KernLog("salut : %s", var); KernLog("Goodbye after %d ticks\n", IoGetRtcTicks()); // End this machine's suffering