Commit 80e176fc by malcolm

Added load_errors to assign error functions to handlers

parent 00b25e59
Showing with 39 additions and 22 deletions
......@@ -3,89 +3,89 @@
void int_div_by_zero(uint32_t __attribute__((unused))error)
{
serial_writestring("DIV BY ZERO ERRO");
serial_writestring("DIV BY ZERO ERROR\n");
}
void int_debug(uint32_t __attribute__((unused))error)
{
serial_writestring("DEBUG ERROR");
serial_writestring("DEBUG ERROR\n");
}
void int_non_maskable_interrupt(uint32_t __attribute__((unused))error)
{
serial_writestring("NON MASKABLE INTERRUPT ERROR");
serial_writestring("NON MASKABLE INTERRUPT ERROR\n");
}
void int_breakpoint(uint32_t __attribute__((unused))error)
{
serial_writestring("BREAKPOINT ERROR");
serial_writestring("BREAKPOINT ERROR\n");
}
void int_overflow(uint32_t __attribute__((unused))error)
{
serial_writestring("OVERFLOW ERROR");
serial_writestring("OVERFLOW ERROR\n");
}
void int_bound_range_exceeded(uint32_t __attribute__((unused))error)
{
serial_writestring("BOUND RANGE EXCEEDED ERROR");
serial_writestring("BOUND RANGE EXCEEDED ERROR\n");
}
void int_invalid_opcode(uint32_t __attribute__((unused))error)
{
serial_writestring("INVALID OPCODE ERROR");
serial_writestring("INVALID OPCODE ERROR\n");
}
void int_device_not_available(uint32_t __attribute__((unused))error)
{
serial_writestring("DEVICE NOT AVAILABLE ERROR");
serial_writestring("DEVICE NOT AVAILABLE ERROR\n");
}
void int_double_fault(uint32_t __attribute__((unused))error)
{
serial_writestring("DOUBLE FAULT ERROR");
serial_writestring("DOUBLE FAULT ERROR\n");
}
void int_coprocessor_segment_overrun(uint32_t __attribute__((unused))error)
{
serial_writestring("COPROCESSOR SEGMENT OVERRUN ERROR");
serial_writestring("COPROCESSOR SEGMENT OVERRUN ERROR\n");
}
void int_invalid_tss(uint32_t __attribute__((unused))error)
{
serial_writestring("INVALID TSS ERROR");
serial_writestring("INVALID TSS ERROR\n");
}
void int_segment_not_present(uint32_t __attribute__((unused))error)
{
serial_writestring("SEGMENT NOT PRESENT ERROR");
serial_writestring("SEGMENT NOT PRESENT ERROR\n");
}
void int_stack_segment_fault(uint32_t __attribute__((unused))error)
{
serial_writestring("STACK SEGMENT ERROR");
serial_writestring("STACK SEGMENT ERROR\n");
}
void int_general_protection_fault(uint32_t __attribute__((unused))error)
{
serial_writestring("GENERAL PROTECTION FAULT ERROR");
serial_writestring("GENERAL PROTECTION FAULT ERROR\n");
}
void int_page_fault(uint32_t __attribute__((unused))error)
{
serial_writestring("PAGE FAULT ERROR");
serial_writestring("PAGE FAULT ERROR\n");
}
void int_reserved(uint32_t __attribute__((unused))error)
{
serial_writestring("RESERVED ERROR");
serial_writestring("RESERVED ERROR\n");
}
void int_x87_floating_point(uint32_t __attribute__((unused))error)
{
serial_writestring("X87 FLOATING POINT ERROR");
serial_writestring("X87 FLOATING POINT ERROR\n");
}
void int_alignment_check(uint32_t __attribute__((unused))error)
{
serial_writestring("ALIGNMENT ERROR");
serial_writestring("ALIGNMENT ERROR\n");
}
void int_machine_check(uint32_t __attribute__((unused))error)
{
serial_writestring("MACHINE CHECK ERROR");
serial_writestring("MACHINE CHECK ERROR\n");
}
void int_simd_floating_point(uint32_t __attribute__((unused))error)
{
serial_writestring("SIMD FLOATING POINT ERROR");
serial_writestring("SIMD FLOATING POINT ERROR\n");
}
void int_virtualization(uint32_t __attribute__((unused))error)
{
serial_writestring("VITUALIZATION ERROR");
serial_writestring("VITUALIZATION ERROR\n");
}
void int_security(uint32_t __attribute__((unused))error)
{
serial_writestring("SECURITY ERROR");
serial_writestring("SECURITY ERROR\n");
}
#include "idt.h"
#include "string.h"
#include "serial.h"
#include "exceptions.h"
#pragma GCC push_options
#pragma GCC optimize ("0")
......@@ -27,6 +28,21 @@ void idt_install()
asm volatile ("lidt (%0)": :"r"(&idtr));
}
void load_error_handlers()
{
void(*errors[])(uint32_t)={int_div_by_zero,int_debug,int_non_maskable_interrupt,int_breakpoint,int_overflow,
int_bound_range_exceeded,int_invalid_opcode,int_device_not_available,int_double_fault,
int_coprocessor_segment_overrun,int_invalid_tss,int_segment_not_present,
int_stack_segment_fault,int_general_protection_fault,int_page_fault,int_reserved,
int_x87_floating_point,int_alignment_check,int_machine_check,int_simd_floating_point,
int_virtualization,int_reserved,int_reserved,int_reserved,int_reserved,int_reserved,
int_reserved,int_reserved,int_reserved,int_reserved,int_security,int_reserved};
for(int i=0;i<32;i++)
{
handlers[i]=errors[i];
}
}
void default_handler(struct reg_state reg, uint32_t interrupt, uint32_t error, struct stack_state stack)
{
if(interrupt<32)
......@@ -96,6 +112,7 @@ int idt_init(uint16_t code_sel)
_code_sel = code_sel;
idtsetup();
idt_install();
load_error_handlers();
return 0;
}
#pragma GCC pop_options
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment