ISR
This commit is contained in:
@@ -31,9 +31,9 @@ void GDT_Init() {
|
||||
|
||||
// Null segment
|
||||
GDT_Set_Gate(0, 0, 0, 0, 0);
|
||||
// Code Base 0 limit 32 Access EXEC + RW
|
||||
// Code Base 0 limit 32 Access EXEC + RW
|
||||
GDT_Set_Gate(1, 0x00000000, 0xFFFFFFFF, GDT_ACCESS_PRESENT | GDT_ACCESS_EXEC | GDT_ACCESS_RW, GDT_FLAG_GR_PAGE | GDT_FLAG_SZ_32B);
|
||||
// Data Base 0 Limit 32 Access RW
|
||||
// Data Base 0 Limit 32 Access RW
|
||||
GDT_Set_Gate(2, 0x00000000, 0xFFFFFFFF, GDT_ACCESS_PRESENT | GDT_ACCESS_RW, GDT_FLAG_GR_PAGE | GDT_FLAG_SZ_32B);
|
||||
|
||||
lgdt(_GDTptr);
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include <kernel/kernio.h>
|
||||
|
||||
struct Regs_t {
|
||||
unsigned int gs, fs, es, ds; /* pushed the segs last */
|
||||
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
|
||||
unsigned int int_no, err_code; /* our 'push byte #' and ecodes do this */
|
||||
unsigned int eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
|
||||
unsigned int gs, fs, es, ds; /* pushed the segs last */
|
||||
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
|
||||
unsigned int int_no, err_code; /* our 'push byte #' and ecodes do this */
|
||||
unsigned int eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
|
||||
};
|
||||
|
||||
char *PanicMessage[] = {
|
||||
@@ -48,7 +48,6 @@ char *PanicMessage[] = {
|
||||
extern "C" {
|
||||
|
||||
void DEFAULT_ISR() {
|
||||
Write("SMH \n");
|
||||
outb(0x20,0x20);
|
||||
}
|
||||
|
||||
@@ -57,12 +56,13 @@ void KeyboardHandler() {
|
||||
outb(0x20,0x20);
|
||||
}
|
||||
|
||||
void FaultHandler(struct Regs_t *r) {
|
||||
uint32_t val;
|
||||
asm volatile ( "mov %%cr2, %0" : "=r"(val) );
|
||||
PanicKernel(val, PanicMessage[r->int_no]);
|
||||
for (;;)
|
||||
asm("hlt");
|
||||
void FaultHandler(struct Regs_t* r) {
|
||||
if (r->int_no < 32) {
|
||||
uint32_t val;
|
||||
asm volatile ( "mov %%cr2, %0" : "=r"(val) );
|
||||
PanicKernel(val, PanicMessage[r->int_no], "kernel/isr.cpp:64", "FaultHandler(struct Regs_t* r)");
|
||||
for(;;) {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <kernel/drivers/terminal/terminal.h>
|
||||
|
||||
void PanicKernel(char code, char* why, char* where, char* what) {
|
||||
asm("cli");
|
||||
|
||||
if (why == "") {
|
||||
switch (code) {
|
||||
case 0x00:
|
||||
@@ -79,5 +81,7 @@ void PanicKernel(char code, char* why, char* where, char* what) {
|
||||
Write("Error Code: 0x");
|
||||
Write(itohx(code));
|
||||
|
||||
asm("cli"); // Clear interrupt bit / dissable interrupts
|
||||
for (;;) {
|
||||
asm("hlt");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,14 @@
|
||||
|
||||
void PIC_Default_Remap() {
|
||||
outb(0x20, 0x11);
|
||||
io_wait();
|
||||
outb(0xA0, 0x11);
|
||||
io_wait();
|
||||
outb(0x21, 0x20);
|
||||
io_wait();
|
||||
outb(0xA1, 0x28);
|
||||
io_wait();
|
||||
outb(0x21, 0x04);
|
||||
io_wait();
|
||||
outb(0xA1, 0x02);
|
||||
io_wait();
|
||||
outb(0x21, 0x01);
|
||||
io_wait();
|
||||
outb(0xA1, 0x01);
|
||||
io_wait();
|
||||
outb(0x21, 0x0);
|
||||
io_wait();
|
||||
outb(0xA1, 0x0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user