getting there...
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
|
||||
#include <lib/print.h>
|
||||
|
||||
#include "process.h"
|
||||
#include "scheduler.h"
|
||||
#include "syscall.h"
|
||||
#include "common.h"
|
||||
#include "gdt.h"
|
||||
|
||||
#include <drivers/pic/pic.h>
|
||||
#include <drivers/ps2/ps2.h>
|
||||
@@ -27,13 +30,13 @@ typedef struct __attribute__((packed)) {
|
||||
} idt_ptr;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint32_t edi, esi, ebp, esp_dummy, ebx, edx, ecx, eax;
|
||||
uint32_t edi, esi, ebp, dummy, ebx, edx, ecx, eax;
|
||||
|
||||
uint32_t int_no;
|
||||
uint32_t error_code;
|
||||
|
||||
uint32_t eip, cs, eflags, useresp, ss;
|
||||
} registers;
|
||||
uint32_t eip, cs, eflags, u_esp, u_ss;
|
||||
} intr_regs_t;
|
||||
|
||||
// (interrupts.S)
|
||||
extern void load_idt(void);
|
||||
@@ -57,7 +60,9 @@ static void* isr_stub_table[256] = {
|
||||
|
||||
static const char* err_messages[32] = {
|
||||
[0] = "Divide by 0",
|
||||
[1] = "",
|
||||
[1] = "Debug",
|
||||
[4] = "Overflow",
|
||||
[6] = "Undefined Opcode",
|
||||
[8] = "",
|
||||
[13] = "General Protection Fault",
|
||||
[14] = "Page Fault",
|
||||
@@ -93,7 +98,7 @@ void init_idt() {
|
||||
load_idt();
|
||||
}
|
||||
|
||||
void common_interrupt_handler(registers *args) {
|
||||
void common_interrupt_handler(intr_regs_t *args) {
|
||||
switch (args->int_no) {
|
||||
case 0:
|
||||
case 1:
|
||||
@@ -111,14 +116,20 @@ void common_interrupt_handler(registers *args) {
|
||||
case 13:
|
||||
case 15:
|
||||
case 16:
|
||||
kprintf("CPU Error: [%d]%s\n", args->int_no, err_messages[args->int_no]);
|
||||
asm volatile("cli");
|
||||
kprintf("\n--- CPU Exception ---\n");
|
||||
kprintf("Error: [%d] %s\n", args->int_no, err_messages[args->int_no]);
|
||||
kprintf("Error Code: 0x%x\n", args->error_code);
|
||||
kprintf("Instruction Pointer: 0x%x\n", args->eip);
|
||||
kprintf("Stack Pointer: 0x%x\n", args->useresp);
|
||||
kprintf("Current Stack Pointer: 0x%x\n", (void*)args);
|
||||
kprintf("EAX: 0x%x\n", args->eax);
|
||||
kprintf("EFLAGS: 0x%x\n", args->eflags);
|
||||
kprintf("cr3: 0x%x\n", fetch_cr3());
|
||||
while(1);
|
||||
kprintf("Code Segment: 0x%x\n", args->cs);
|
||||
kprintf("Current cr3: 0x%x\n", fetch_cr3());
|
||||
kprintf("tss.esp0: 0x%x\n", tss.esp0);
|
||||
process_t* task = current_task();
|
||||
kprintf("Task kstack_top: 0x%x\n", task->kstack_top);
|
||||
asm volatile("hlt");
|
||||
break;
|
||||
case 14:{
|
||||
uint32_t faulting_address;
|
||||
@@ -127,14 +138,20 @@ void common_interrupt_handler(registers *args) {
|
||||
kprintf("Faulted Virtual Address: 0x%x\n", faulting_address);
|
||||
kprintf("Error Code: 0x%x\n", args->error_code);
|
||||
kprintf("Instruction Pointer: 0x%x\n", args->eip);
|
||||
kprintf("Stack Pointer: 0x%x\n", args->useresp);
|
||||
kprintf("Current Stack Pointer: 0x%x\n", (void*)args);
|
||||
kprintf("EAX: 0x%x\n", args->eax);
|
||||
kprintf("EFLAGS: 0x%x\n", args->eflags);
|
||||
kprintf("Code Segment: 0x%x\n", args->cs);
|
||||
kprintf("Current cr3: 0x%x\n", fetch_cr3());
|
||||
if (args->cs == 0x1b) {
|
||||
kprintf("User ESP: 0x%x\n", args->u_esp);
|
||||
kprintf("User SS: 0x%x\n", args->u_ss);
|
||||
}
|
||||
kprintf("Caused by: %s, %s, running in %s mode\n",
|
||||
(args->error_code & 0x01) ? "Protection Violation" : "Page Not Present",
|
||||
(args->error_code & 0x02) ? "Write" : "Read",
|
||||
(args->error_code & 0x04) ? "User" : "Supervisor");
|
||||
while(1);
|
||||
asm volatile("hlt");
|
||||
break;
|
||||
}
|
||||
case 33: {
|
||||
|
||||
Reference in New Issue
Block a user