Even more refactor

master
E. Almqvist 3 years ago
parent 82e3a85517
commit 5c0f0b6be6
  1. 11
      kernel/idt.c
  2. 2
      kernel/idt.h
  3. 22
      kernel/isr.asm
  4. 11
      kernel/pic.c
  5. 2
      kernel/pic.h

@ -17,16 +17,16 @@ __attribute__((aligned(16)))
static idt_entry IDT[IDT_MAX_DESCS];
static idtr IDTR;
void exception_handler() {
void interupt_handler(uint interupt) {
uint* exc_ptr = 0xe222;
uint8 exc = *exc_ptr;
pic_send_eoi(exc);
pic_send_eoi(interupt);
char* buf;
set_cursor_pos(0, 0);
print("[exc] ", EXC_COLOR);
buf = itoa(exc, buf, 10);
buf = itoa(interupt, buf, 10);
print(buf, 0x0c);
}
@ -52,9 +52,10 @@ void idt_init() {
idt_set_desc(idx, isr_stub_table[idx], 0x8e);
/*
outb_w(PIC1, 0xfd);
outb_w(PIC2, 0xfd);
*/
__asm__ __volatile__("lidt %0" : : "m"(IDTR));
//__asm__ __volatile__("sti");
__asm__ __volatile__("sti");
}

@ -5,7 +5,7 @@
#define EXC_COLOR 0x08
__attribute__((noreturn))
void exception_handler();
void interupt_handler(uint);
void idt_set_desc(uint8, void*, uint8);
void idt_init();

@ -2,23 +2,31 @@ isr_debug_ptr equ 0xe222
%macro isr_err_stub 1
isr_stub_%+%1:
mov [isr_debug_ptr], byte %1
call exception_handler
hlt
cli
pusha
push dword %1
call interupt_handler
pop eax
popa
;hlt
sti
iret
%endmacro
%macro isr_no_err_stub 1
isr_stub_%+%1:
mov [isr_debug_ptr], byte %1
call exception_handler
hlt
cli
pusha
push dword %1
call interupt_handler
pop eax
popa
;hlt
sti
iret
%endmacro
extern exception_handler
extern interupt_handler
isr_err_stub 0
isr_err_stub 1
isr_no_err_stub 2

@ -8,10 +8,6 @@ void pic_send_eoi(uint8 irq) {
}
void pic_remap(uint offset_1, uint offset_2) {
uint8 a1, a2;
a1 = inb(PIC1_DATA);
a2 = inb(PIC2_DATA);
// Start the init sequance
outb_w(PIC1_CMD, ICW_INIT_MASK);
@ -26,9 +22,8 @@ void pic_remap(uint offset_1, uint offset_2) {
outb_w(PIC1_DATA, ICW4_8086);
outb_w(PIC2_DATA, ICW4_8086);
// restore old masks
outb(PIC1_DATA, a1);
outb(PIC2_DATA, a2);
outb(PIC1_DATA, 0xff);
outb(PIC2_DATA, 0xff);
}
// disable the PIC
@ -44,7 +39,7 @@ void pic_init() {
}
// (un)set a specific irq
void irq(uint8 idx, bool t) {
void irq_mask(uint8 idx, bool t) {
uint16 port;
uint8 data;

@ -40,7 +40,7 @@ void pic_disable();
void pic_init();
// IRQs
void irq(uint8, bool);
void irq_mask(uint8, bool);
static uint16 irq_reg(int ocw3);
uint16 get_irr();

Loading…
Cancel
Save