Autor Thema: IDT will einfach nich funzen!!  (Gelesen 4742 mal)

hackgod

  • Beiträge: 70
    • Profil anzeigen
Gespeichert
« am: 24. July 2005, 09:11 »
Hi Leute,
ich weiss nicht mehr weiter. Ich krieg die IDT einfach nicht geproggt.
Ich hab zwar einen IDT-Code, aber ich glaub den kann ich in die Tonne
treten. Ich beschreibe hier mal mein Problem:
Bevor ich anfange IDT-Funktionen zu proggen, funzt mein Kernel eigentlich
einwandfrei. Er gibt den Text so aus wie ich ihn haben will, und sonst funzt
er ganz gut. Sobald ich aber anfange eine IDT zu implentieren, streikt mein
Kernel was die Textfunktionen angeht. Er bleibt einfach stehen. Nichts, Nada, Niente.
Woran kann das wohl liegen? Ich poste hier den Code für meine IDT:

idt.c:#include <idt.h>
#include <system.h>
struct idt_entry idt[256];
struct idt_ptr idtp;

extern void idt_load();

void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags)
{
    /* The interrupt routine's base address */
    idt[num].base_lo = (base & 0xFFFF);
    idt[num].base_hi = (base >> 16) & 0xFFFF;

    /* The segment or 'selector' that this IDT entry will use
    *  is set here, along with any access flags */
    idt[num].sel = sel;
    idt[num].always0 = 0;
    idt[num].flags = flags;
};
void idt_install()
{
    /* Sets the special IDT pointer up */
    idtp.limit = (sizeof (struct idt_entry) * 256) - 1;
    idtp.base = (unsigned long)&idt;

    /* Clear out the entire IDT, initializing it to zeros */
    memset(&idt, 0, sizeof(struct idt_entry) * 256);


    /* Points the processor's internal register to the new IDT */
    idt_load();
};

idt.h:#ifndef IDT_H
#define IDT_H
struct idt_entry
{
    unsigned short base_lo;
    unsigned short sel;        /* Our kernel segment goes here! */
    unsigned char always0;     /* This will ALWAYS be set to 0! */
    unsigned char flags;       /* Set using the above table! */
    unsigned short base_hi;
} __attribute__((packed));

struct idt_ptr
{
    unsigned short limit;
    unsigned long base;
} __attribute__((packed));

void idt_set_gate(unsigned char, unsigned long, unsigned short, unsigned char);
void idt_install();
#endif

isr.asm:global _isr0
global _isr1
global _isr2
global _isr3
global _isr4
global _isr5
global _isr6
global _isr7
global _isr8
global _isr9
global _isr10
global _isr11
global _isr12
global _isr13
global _isr14
global _isr15
global _isr16
global _isr17
global _isr18
global _isr19
global _isr20
global _isr21
global _isr22
global _isr23
global _isr24
global _isr25
global _isr26
global _isr27
global _isr28
global _isr29
global _isr30
global _isr31

_isr0:
cli
push 0
push 0
jmp isr_common_stub
_isr1:
cli
push 0
push 1
jmp isr_common_stub
_isr2:
cli
push 0
push 2
jmp isr_common_stub
_isr3:
cli
push 0
push 3
jmp isr_common_stub
_isr4:
cli
push 0
push 4
jmp isr_common_stub
_isr5:
cli
push 0
push 5
jmp isr_common_stub
_isr6:
cli
push 0
push 6
jmp isr_common_stub
_isr7:
cli
push 0
push 7
jmp isr_common_stub
_isr8:
cli
push 8
jmp isr_common_stub
_isr9:
cli
push 0
push 9
jmp isr_common_stub
_isr10:
cli
push 10
jmp isr_common_stub
_isr11:
cli
push 11
jmp isr_common_stub
_isr12:
cli
push 12
jmp isr_common_stub
_isr13:
cli
push 13
jmp isr_common_stub
_isr14:
cli
push 14
jmp isr_common_stub
_isr15:
cli
push 0
push 15
jmp isr_common_stub
_isr16:
cli
push 0
push 16
jmp isr_common_stub
_isr17:
cli
push 0
push 17
jmp isr_common_stub
_isr18:
cli
push 0
push 18
jmp isr_common_stub
_isr19:
cli
push 0
push 19
jmp isr_common_stub
_isr20:
cli
push 0
push 20
jmp isr_common_stub
_isr21:
cli
push 0
push 21
jmp isr_common_stub
_isr22:
cli
push 0
push 22
jmp isr_common_stub
_isr23:
cli
push 0
push 23
jmp isr_common_stub
_isr24:
cli
push 0
push 24
jmp isr_common_stub
_isr25:
cli
push 0
push 25
jmp isr_common_stub
_isr26:
cli
push 0
push 26
jmp isr_common_stub
_isr27:
cli
push 0
push 27
jmp isr_common_stub
_isr28:
cli
push 0
push 28
jmp isr_common_stub
_isr29:
cli
push 0
push 29
jmp isr_common_stub
_isr30:
cli
push 0
push 30
jmp isr_common_stub
_isr31:
cli
push 0
push 31
jmp isr_common_stub

extern _fault_handler

isr_common_stub:
    pusha
    push ds
    push es
    push fs
    push gs
    mov ax, 0x10   ; Load the Kernel Data Segment descriptor!
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
    mov eax, esp   ; Push us the stack
    push eax
    mov eax, _fault_handler
    call eax       ; A special call, preserves the 'eip' register
    pop eax
    pop gs
    pop fs
    pop es
    pop ds
    popa
    add esp, 8     ; Cleans up the pushed error code and pushed ISR number
    iret           ; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP!

isrs.c:#include <isrs.h>
#include <idt.h>
#include <video.h>
void isrs_install()
{
idt_set_gate(0,(unsigned)isr0,0x08,0x8E);
idt_set_gate(1,(unsigned)isr1,0x08,0x8E);
idt_set_gate(2,(unsigned)isr2,0x08,0x8E);
idt_set_gate(3,(unsigned)isr3,0x08,0x8E);
idt_set_gate(4,(unsigned)isr4,0x08,0x8E);
idt_set_gate(5,(unsigned)isr5,0x08,0x8E);
idt_set_gate(6,(unsigned)isr6,0x08,0x8E);
idt_set_gate(7,(unsigned)isr7,0x08,0x8E);
idt_set_gate(8,(unsigned)isr8,0x08,0x8E);
idt_set_gate(9,(unsigned)isr9,0x08,0x8E);
idt_set_gate(10,(unsigned)isr10,0x08,0x8E);
idt_set_gate(11,(unsigned)isr11,0x08,0x8E);
idt_set_gate(12,(unsigned)isr12,0x08,0x8E);
idt_set_gate(13,(unsigned)isr13,0x08,0x8E);
idt_set_gate(14,(unsigned)isr14,0x08,0x8E);
idt_set_gate(15,(unsigned)isr15,0x08,0x8E);
idt_set_gate(16,(unsigned)isr16,0x08,0x8E);
idt_set_gate(17,(unsigned)isr17,0x08,0x8E);
idt_set_gate(18,(unsigned)isr18,0x08,0x8E);
idt_set_gate(19,(unsigned)isr19,0x08,0x8E);
idt_set_gate(20,(unsigned)isr20,0x08,0x8E);
idt_set_gate(21,(unsigned)isr21,0x08,0x8E);
idt_set_gate(22,(unsigned)isr22,0x08,0x8E);
idt_set_gate(23,(unsigned)isr23,0x08,0x8E);
idt_set_gate(24,(unsigned)isr24,0x08,0x8E);
idt_set_gate(25,(unsigned)isr25,0x08,0x8E);
idt_set_gate(26,(unsigned)isr26,0x08,0x8E);
idt_set_gate(27,(unsigned)isr27,0x08,0x8E);
idt_set_gate(28,(unsigned)isr28,0x08,0x8E);
idt_set_gate(29,(unsigned)isr29,0x08,0x8E);
idt_set_gate(30,(unsigned)isr30,0x08,0x8E);
idt_set_gate(31,(unsigned)isr31,0x08,0x8E);
};
void fault_handler(struct regs *r)
{
    /* Is this a fault whose number is from 0 to 31? */
    if (r->int_no < 32)
    {
        /* Display the description for the Exception that occurred.
        *  In this tutorial, we will simply halt the system using an
        *  infinite loop */
        printf(exception_messages[r->int_no],15);
        printf(" Exception. System Halted!\n",15);
        for (;;);
    }
};

isrs.h:#ifndef ISRS_H
#define ISRS_H

extern void isr0();
extern void isr1();
extern void isr2();
extern void isr3();
extern void isr4();
extern void isr5();
extern void isr6();
extern void isr7();
extern void isr8();
extern void isr9();
extern void isr10();
extern void isr11();
extern void isr12();
extern void isr13();
extern void isr14();
extern void isr15();
extern void isr16();
extern void isr17();
extern void isr18();
extern void isr19();
extern void isr20();
extern void isr21();
extern void isr22();
extern void isr23();
extern void isr24();
extern void isr25();
extern void isr26();
extern void isr27();
extern void isr28();
extern void isr29();
extern void isr30();
extern void isr31();

void isrs_install();
struct regs
{
    unsigned int ds, es, fs, gs;      /* pushed the segs last */
    unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;  /* pushed by 'pusha' */
    unsigned int int_no, err_code;    /* our 'push byte #' and ecodes do this */
    unsigned int eip, cs, eflags, useresp, ss;   /* pushed by the processor automatically */
};
unsigned char *exception_messages[] =
{
"Division by Zero",
"Debug",
"Non maskable Interrupt",
"Breakpoint",
"Into detected Overflow",
"Out of Bounds",
"Invalid Opcode",
"No Coprocessor",

"Double Fault",
"Coprocessor Segment Overrun",
"Bad TSS",
"Segment not present",
"Stack Fault",
"General Protection Fault",
"Page Fault",
"Unknown Interrupt",

"Coprocessor Fault",
"Alignment Check",
"Machine Check",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",

"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
};
#endif


So, das ist jetzt ne ganze Menge Code. Ich hoffe, dass mir jemand helfen
kann. Vielleicht hilft es zu sagen, dass das Tutorial, wo ich den Code weghab,
auf GRUB ausgelegt ist.

Bis denne

hackgod

hackgod

  • Beiträge: 70
    • Profil anzeigen
Gespeichert
« Antwort #1 am: 24. July 2005, 11:34 »
ich will ja nich drängeln oder so, aber ich komme bei dem Projekt echt nicht weiter. Das schlimmste is, ich verlier immer mehr die Lust etwas zu machen, weil es einfach nich klappen will. :(

 

Einloggen