Interupts works!

master 0.5
E. Almqvist 3 years ago
parent 5c0f0b6be6
commit a9c897e75d
  1. 5
      kernel/idt.c
  2. 60
      kernel/isr.asm
  3. 38
      kernel/pic.c
  4. 2
      kernel/pic.h

@ -18,14 +18,11 @@ static idt_entry IDT[IDT_MAX_DESCS];
static idtr IDTR;
void interupt_handler(uint interupt) {
uint* exc_ptr = 0xe222;
uint8 exc = *exc_ptr;
pic_send_eoi(interupt);
char* buf;
set_cursor_pos(0, 0);
print("[exc] ", EXC_COLOR);
print("[int] ", EXC_COLOR);
buf = itoa(interupt, buf, 10);
print(buf, 0x0c);
}

@ -4,24 +4,10 @@ isr_debug_ptr equ 0xe222
isr_stub_%+%1:
cli
pusha
push dword %1
push byte %1
call interupt_handler
pop eax
popa
;hlt
sti
iret
%endmacro
%macro isr_no_err_stub 1
isr_stub_%+%1:
cli
pusha
push dword %1
call interupt_handler
pop eax
popa
;hlt
sti
iret
%endmacro
@ -29,36 +15,36 @@ isr_stub_%+%1:
extern interupt_handler
isr_err_stub 0
isr_err_stub 1
isr_no_err_stub 2
isr_no_err_stub 3
isr_no_err_stub 4
isr_no_err_stub 5
isr_err_stub 2
isr_err_stub 3
isr_err_stub 4
isr_err_stub 5
isr_err_stub 6
isr_no_err_stub 7
isr_err_stub 7
isr_err_stub 8 ; err
isr_no_err_stub 9 ; keyboard?
isr_err_stub 9 ; keyboard?
isr_err_stub 10
isr_err_stub 11
isr_err_stub 12
isr_no_err_stub 13
isr_err_stub 13
isr_err_stub 14
isr_no_err_stub 15
isr_no_err_stub 16
isr_err_stub 15
isr_err_stub 16
isr_err_stub 17
isr_no_err_stub 18
isr_no_err_stub 19
isr_no_err_stub 20
isr_no_err_stub 21
isr_no_err_stub 22
isr_no_err_stub 23
isr_no_err_stub 24
isr_no_err_stub 25
isr_no_err_stub 26
isr_no_err_stub 27
isr_no_err_stub 28
isr_no_err_stub 29
isr_err_stub 18
isr_err_stub 19
isr_err_stub 20
isr_err_stub 21
isr_err_stub 22
isr_err_stub 23
isr_err_stub 24
isr_err_stub 25
isr_err_stub 26
isr_err_stub 27
isr_err_stub 28
isr_err_stub 29
isr_err_stub 30
isr_no_err_stub 31
isr_err_stub 31
global isr_stub_table
isr_stub_table:

@ -7,35 +7,35 @@ void pic_send_eoi(uint8 irq) {
outb(PIC1_CMD, PIC_EOI);
}
// disable the PIC
void pic_disable() {
outb(PIC1_DATA, 0xff);
outb(PIC2_DATA, 0xff);
}
void pic_remap(uint offset_1, uint offset_2) {
// Start the init sequance
outb_w(PIC1_CMD, ICW_INIT_MASK);
outb_w(PIC1_CMD, ICW_INIT_MASK); // write ICW1 to PIC master
outb_w(PIC2_CMD, ICW_INIT_MASK); // --||-- to PIC slave
outb_w(PIC2_CMD, ICW_INIT_MASK);
outb_w(PIC1_DATA, offset_1); // remap master
outb_w(PIC2_DATA, offset_2); // remap slave
outb_w(PIC1_DATA, offset_1);
outb_w(PIC2_DATA, offset_2);
outb_w(PIC1_DATA, 0x04); // IRQ2 to slave
outb_w(PIC2_DATA, 0x02);
outb_w(PIC1_DATA, 0x4);
outb_w(PIC2_DATA, 0x2);
outb_w(PIC1_DATA, ICW4_8086); // write ICW4 to PIC master
outb_w(PIC2_DATA, ICW4_8086); // --||-- to PIC slave
outb_w(PIC1_DATA, ICW4_8086);
outb_w(PIC2_DATA, ICW4_8086);
//pic_disable();
outb(PIC1_DATA, 0xff);
outb(PIC2_DATA, 0xff);
// enable all
outb(PIC1_DATA, 0x01);
outb(PIC2_DATA, 0x01);
}
// disable the PIC
// will probably never use this.
void pic_disable() {
outb(PIC1_DATA, 0xff);
outb(PIC2_DATA, 0xff);
}
void pic_init() {
pic_remap(PIC1, PIC2);
pic_remap(0x20, 0x28);
}
// (un)set a specific irq

@ -24,7 +24,7 @@
#define ICW4_BUF_MASTER 0x0C
#define ICW4_SFNM 0x10
#define ICW_INIT_MASK (ICW1_INIT | ICW1_ICW4)
#define ICW_INIT_MASK (ICW1_INIT | ICW1_ICW4) // 0x11
// ISR & IRR
#define PIC_R_IRR 0x0a

Loading…
Cancel
Save