To test if the problem was the C part, I added a 'call panic' command right at the beggining of every isr, but I still don't get anything
The code I got if made of some parts from the wiki and from a french website about osdeving.
Here is the code (please don't kill me if it's sh*t xD):
idt.c
Code: Select all
#include <idt.h>
#include <stddef.h>
#include <stdint.h>
void idt_entry(int num, uint32_t offset, uint16_t selector, uint8_t type_attr){
IDT[num].offset_1 = (offset & 0xffff);;
IDT[num].selector = selector;
IDT[num].zero = 0;
IDT[num].type_attr = type_attr;
IDT[num].offset_2 = (offset & 0xffff0000) >> 16;
}
void loadIDT(){
IDT_Pointer.limit = (sizeof(struct idt_entry) * IDT_SIZE) - 1;
IDT_Pointer.base = &IDT;
for (int i = 0; i < IDT_SIZE; i++){
idt_entry(i, (uint32_t)&_asm_int_default_hdlr, 0x08,0x0E);
}
idt_entry(33, (uint32_t)&_asm_int_2_hdlr, 0x08, 0x0E);
_loadIDT();
}
void _int_0_hdlr(){
}
void _int_1_hdlr(){
}
void _int_2_hdlr(){
}
Code: Select all
#include <stddef.h>
#include <stdint.h>
#define IDT_BASE 0x800
#define IDT_SIZE 0xFF
#define INTGATE 0x8E00
struct idt_entry {
uint16_t offset_1; // offset bits 0..15
uint16_t selector; // a code segment selector in GDT or LDT
uint8_t zero; // unused, set to 0
uint8_t type_attr; // type and attributes, see below
uint16_t offset_2; // offset bits 16..31
} __attribute__((packed));
struct idt_ptr {
unsigned short limit;
unsigned int base;
} __attribute__((packed));
struct idt_entry IDT[IDT_SIZE];
struct idt_ptr IDT_Pointer;
extern void _loadIDT();
extern void _asm_int_default_hdlr();
extern void _asm_int_0_hdlr();
extern void _asm_int_1_hdlr();
extern void _asm_int_2_hdlr();
void idt_entry(int num, uint32_t offset, uint16_t selector, uint8_t type_attr);
void loadIDT();
Code: Select all
.file "idt.c"
.global _loadIDT
.type _loadIDT, @function
.extern IDT_Pointer
_loadIDT:
lidt IDT_Pointer
mov 0x10, %eax
mov %ds, %eax
mov %es, %eax
mov %fs, %eax
mov %gs, %eax
mov %ss, %eax
jmp flush
flush:
ret
Code: Select all
.file "idt.c"
.global _asm_int_default_hdlr
.global _asm_int_0_hdlr
.global _asm_int_1_hdlr
.global _asm_int_2_hdlr
.extern _int_0_hdlr
.extern _int_1_hdlr
.extern _int_2_hdlr
_asm_int_default_hdlr:
call panic
iret
_asm_int_0_hdlr:
call panic
#pushad
cld
call _int_0_hdlr
#popad
iret
_asm_int_1_hdlr:
call panic
#pushad
cld
call _int_1_hdlr
#popad
iret
_asm_int_2_hdlr:
call panic
#pushad
cld
call _int_2_hdlr
#popad
iret