réplica de
https://github.com/Arnau478/quark.git
synced 2024-11-23 12:58:07 +01:00
Finished and fixed ISR+IDT
This commit is contained in:
pare
f5f7b7fc73
commit
7bb5e0d16c
S'han modificat 7 arxius amb 35 adicions i 7 eliminacions
|
@ -7,12 +7,12 @@ typedef struct{
|
|||
uint8_t reserved;
|
||||
uint8_t flags;
|
||||
uint16_t base_high;
|
||||
} idt_entry;
|
||||
} __attribute__((packed)) idt_entry;
|
||||
|
||||
typedef struct{
|
||||
uint16_t limit;
|
||||
idt_entry *ptr;
|
||||
} idt_descriptor;
|
||||
} __attribute__((packed)) idt_descriptor;
|
||||
|
||||
idt_entry g_idt[256];
|
||||
|
||||
|
|
|
@ -29,3 +29,8 @@ i686_outw:
|
|||
mov ax, [esp + 8]
|
||||
out dx, ax
|
||||
ret
|
||||
|
||||
global i686_panic
|
||||
i686_panic:
|
||||
cli
|
||||
hlt
|
||||
|
|
|
@ -4,3 +4,5 @@ uint8_t __attribute__((cdecl)) i686_inb(uint16_t port);
|
|||
void __attribute__((cdecl)) i686_outb(uint16_t port, uint8_t value);
|
||||
uint16_t __attribute__((cdecl)) i686_inw(uint16_t port);
|
||||
void __attribute__((cdecl)) i686_outw(uint16_t port, uint16_t value);
|
||||
|
||||
void __attribute__((cdecl)) i686_panic();
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include <stddef.h>
|
||||
#include "isr.h"
|
||||
#include "../../stdio.h"
|
||||
#include "idt.h"
|
||||
#include "io.h"
|
||||
|
||||
static isr_handler g_isr_handlers[256];
|
||||
|
||||
|
@ -43,11 +46,26 @@ void i686_isr_initialize_gates();
|
|||
void i686_isr_initialize(){
|
||||
i686_isr_initialize_gates();
|
||||
|
||||
// Remap PIC
|
||||
for(int i = 0; i < 256; i++){
|
||||
i686_idt_enable_gate(i);
|
||||
}
|
||||
}
|
||||
|
||||
void i686_isr_handler(registers *regs){
|
||||
printf("Interrupt %i\n", regs->interrupt);
|
||||
void __attribute__((cdecl)) i686_isr_handler(registers *regs){
|
||||
if(g_isr_handlers[regs->interrupt] != NULL){
|
||||
g_isr_handlers[regs->interrupt](regs);
|
||||
}
|
||||
else if(regs->interrupt >= 32){
|
||||
printf("Unhandled interrupt %i\n", regs->interrupt);
|
||||
}
|
||||
else{
|
||||
printf("Unhandled interrupt %i %s\n", regs->interrupt, g_exceptions[regs->interrupt]);
|
||||
printf(" eax=%i ebx=%i ecx=%i edx=%i esi=%i edi=%i\n", regs->eax, regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
|
||||
printf(" esp=%i ebp=%i eip=%i eflags=%i cs=%i ds=%i ss=%i\n", regs->esp, regs->ebp, regs->eip, regs->eflags, regs->cs, regs->ds, regs->ss);
|
||||
printf(" interrupt=%i errorcode=%i\n", regs->interrupt, regs->error);
|
||||
printf("!!! KERNEL PANIC !!!\n");
|
||||
i686_panic();
|
||||
}
|
||||
}
|
||||
|
||||
void i686_isr_register_handler(int interrupt, isr_handler handler){
|
||||
|
|
|
@ -11,7 +11,7 @@ typedef struct{
|
|||
uint32_t eip, cs, eflags, esp, ss;
|
||||
} __attribute__((packed)) registers;
|
||||
|
||||
typedef void (*isr_handler)(registers regs);
|
||||
typedef void (*isr_handler)(registers *regs);
|
||||
|
||||
void i686_isr_initialize();
|
||||
void i686_isr_register_handler(int interrupt, isr_handler handler);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "hal.h"
|
||||
#include "../arch/i686/gdt.h"
|
||||
#include "../arch/i686/idt.h"
|
||||
#include "../arch/i686/isr.h"
|
||||
|
||||
void hal_initialize(){
|
||||
i686_gdt_initialize();
|
||||
i686_idt_initialize();
|
||||
i686_isr_initialize();
|
||||
}
|
||||
|
|
|
@ -8,5 +8,6 @@ void __attribute__((cdecl)) kmain(uint64_t magic, uint64_t addr){
|
|||
puts("\x1b[33mWARNING\x1b[0m");
|
||||
printf(": amazing %s ahead!\n", "math");
|
||||
printf("%i+%i=%i\n", 1, 1, 2);
|
||||
for(;;); // Halt here
|
||||
printf("0/0=%i", 0/0);
|
||||
for(;;);
|
||||
}
|
||||
|
|
Loading…
Referencia en una nova incidència