Hallo,
ich bin gerade dabei die IDT zu programmieren, habe aber ein Problem.
Wenn ich kompilieren will meldet mir das Terminal, dass bei
static uint64_t idt[IDT_ENTRIES];
IDT_ENTRIES nicht deklariert ist.
Hier meine ganze idt.c:
#ifndef INCLUDE_idt_H
#define INCLUDE_idt_H
#include "types.h"
#include "console.h"
//Exceptions:
extern void intr_stub_0();
extern void intr_stub_1();
extern void intr_stub_2();
extern void intr_stub_3();
extern void intr_stub_4();
extern void intr_stub_5();
extern void intr_stub_6();
extern void intr_stub_7();
extern void intr_stub_8();
extern void intr_stub_9();
extern void intr_stub_10();
extern void intr_stub_11();
extern void intr_stub_12();
extern void intr_stub_13();
extern void intr_stub_14();
extern void intr_stub_15();
extern void intr_stub_16();
extern void intr_stub_17();
extern void intr_stub_18();
extern void intr_stub_19();
//Interrupt-Requests:
extern void intr_stub_32();
extern void intr_stub_33();
extern void intr_stub_34();
extern void intr_stub_35();
extern void intr_stub_36();
extern void intr_stub_37();
extern void intr_stub_38();
extern void intr_stub_39();
extern void intr_stub_40();
extern void intr_stub_41();
extern void intr_stub_42();
extern void intr_stub_43();
extern void intr_stub_44();
extern void intr_stub_45();
extern void intr_stub_46();
extern void intr_stub_47();
//Syscalls:
extern void intr_stub_48();
static uint64_t idt[IDT_ENTRIES];
struct {
unsigned short int limit;
void* pointer;
} __attribute__((packed)) idtp = {
.limit = IDT_ENTRIES * 8 - 1,
.pointer = idt,
};
struct cpu_state {
unsigned long eax;
unsigned long ebx;
unsigned long ecx;
unsigned long edx;
unsigned long esi;
unsigned long edi;
unsigned long ebp;
unsigned long intr;
unsigned long error;
unsigned long eip;
unsigned long cs;
unsigned long eflags;
unsigned long esp;
unsigned long ss;
};
static void set_idt_entry(int i, unsigned long long base, unsigned int selektor, int flags)
{
idt[i] = base & 0xffff;
idt[i] |= (selektor & 0xffff) << 16;
idt[i] |= (flags & 0xffLL) << 40;
idt[i] |= ((base >> 16) & 0xffff) << 48;
}
void init_idt(void)
{
//set_idt_entry(0, (uint32_t)int_handler, 0x8, IDT_FLAG_RING0 | IDT_FLAG_PRESENT);
//set_idt_entry(0, (uint32_t)int_handler, 0x8, 0x8e);
//Exceptions:
set_idt_entry(0, (uint32_t)intr_stub_0, 0x8, 0x8e);
set_idt_entry(1, (uint32_t)intr_stub_1, 0x8, 0x8e);
set_idt_entry(2, (uint32_t)intr_stub_2, 0x8, 0x8e);
set_idt_entry(3, (uint32_t)intr_stub_3, 0x8, 0x8e);
set_idt_entry(4, (uint32_t)intr_stub_4, 0x8, 0x8e);
set_idt_entry(5, (uint32_t)intr_stub_5, 0x8, 0x8e);
set_idt_entry(6, (uint32_t)intr_stub_6, 0x8, 0x8e);
set_idt_entry(7, (uint32_t)intr_stub_7, 0x8, 0x8e);
set_idt_entry(8, (uint32_t)intr_stub_8, 0x8, 0x8e);
set_idt_entry(9, (uint32_t)intr_stub_9, 0x8, 0x8e);
set_idt_entry(10, (uint32_t)intr_stub_10, 0x8, 0x8e);
set_idt_entry(11, (uint32_t)intr_stub_11, 0x8, 0x8e);
set_idt_entry(12, (uint32_t)intr_stub_12, 0x8, 0x8e);
set_idt_entry(13, (uint32_t)intr_stub_13, 0x8, 0x8e);
set_idt_entry(14, (uint32_t)intr_stub_14, 0x8, 0x8e);
set_idt_entry(15, (uint32_t)intr_stub_15, 0x8, 0x8e);
set_idt_entry(16, (uint32_t)intr_stub_16, 0x8, 0x8e);
set_idt_entry(17, (uint32_t)intr_stub_17, 0x8, 0x8e);
set_idt_entry(18, (uint32_t)intr_stub_18, 0x8, 0x8e);
set_idt_entry(19, (uint32_t)intr_stub_19, 0x8, 0x8e);
//IRQs:
set_idt_entry(32, (uint32_t)intr_stub_32, 0x8, 0x8e);
set_idt_entry(33, (uint32_t)intr_stub_33, 0x8, 0x8e);
set_idt_entry(34, (uint32_t)intr_stub_34, 0x8, 0x8e);
set_idt_entry(35, (uint32_t)intr_stub_35, 0x8, 0x8e);
set_idt_entry(36, (uint32_t)intr_stub_36, 0x8, 0x8e);
set_idt_entry(37, (uint32_t)intr_stub_37, 0x8, 0x8e);
set_idt_entry(38, (uint32_t)intr_stub_38, 0x8, 0x8e);
set_idt_entry(39, (uint32_t)intr_stub_39, 0x8, 0x8e);
set_idt_entry(40, (uint32_t)intr_stub_40, 0x8, 0x8e);
set_idt_entry(41, (uint32_t)intr_stub_41, 0x8, 0x8e);
set_idt_entry(42, (uint32_t)intr_stub_42, 0x8, 0x8e);
set_idt_entry(43, (uint32_t)intr_stub_43, 0x8, 0x8e);
set_idt_entry(44, (uint32_t)intr_stub_44, 0x8, 0x8e);
set_idt_entry(45, (uint32_t)intr_stub_45, 0x8, 0x8e);
set_idt_entry(46, (uint32_t)intr_stub_46, 0x8, 0x8e);
set_idt_entry(47, (uint32_t)intr_stub_47, 0x8, 0x8e);
//Syscalls:
set_idt_entry(48, (uint32_t)intr_stub_48, 0x8, 0x8e);
load_idt();
}
void load_idt(void)
{
asm volatile("lidt %0" : : "m" (idtp));
}
void int_handler(void)
{
kprintf("Ein Interrupt!\n");
while(1);
}
#endif
Was habe ich falsch gemacht?
Danke für eure Antworten.
MrTom3715