Habs jetzt hinbekommen, das Interrupts.asm mit "ELF" komplimiert wird und
der Linker das akzeptiert. Aber die Interrupts wollen immer noch nicht gehen
, wenn ich jetzt
asm("sti");
am Ende der remap_irq - Funktion schreibe, dann sagt Bochs:
00004399371-i-@00001d72-[CPU0 ] >> mov byte ptr ds:[eax], 0x00 : C60000
00004399371-e-@00001d72-[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
Wenn ich ein Interrupt ausführe, ohne das "sti", sagt Bochs wieder das
selbe wie am Anfang:
00008848368-i-@00001038-[CPU0 ] >> int 0x16 : CD16
00008848368-e-@00001038-[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
Liegt das vielleicht daran?:
idt_set_gate(1, (unsigned)intr1, 0x08, 0x8E);
Hier nochmal der Code:
#include <stdint.h>
#include "hInit.h"
extern void intr0();
...
extern void intr47();
void install_interrupts();
int begin() {
install_interrupts();
v_clear();
v_print("$3-=Xype=-", 0);
v_print("$2Willkommen!", 2);
asm("int $0x16");
v_print(str_replace("Eingabe", "ga", ""), 3);
while(1);
}
static inline void outb(unsigned short port, unsigned char data) {
asm volatile ("outb %0, %1" : : "a" (data), "Nd" (port));
}
void remap_irq(void) {
outb(0x20, 0x11);
outb(0xA0, 0x11);
outb(0x21, 0x20);
outb(0xA1, 0x28);
outb(0x21, 0x04);
outb(0xA1, 0x02);
outb(0x21, 0x01);
outb(0xA1, 0x01);
outb(0x21, 0x0);
outb(0xA1, 0x0);
}
void install_interrupts() {
remap_irq();
idt_set_gate(0, (unsigned)intr0, 0x08, 0x8E);
idt_set_gate(1, (unsigned)intr1, 0x08, 0x8E);
idt_set_gate(2, (unsigned)intr2, 0x08, 0x8E);
...
idt_set_gate(47, (unsigned)intr47, 0x08, 0x8E);
struct {
unsigned int limit;
unsigned int base;
} __attribute__((packed)) idt_ptr = {
.limit = 256*8 - 1,
.base = (unsigned int)IDT,
};
asm("lidt %0" : : "m" (idt_ptr));
}
struct registers {
unsigned int gs, fs, es, ds;
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
unsigned int int_num, err_code;
unsigned int eip, cs, eflags, useresp, ss;
};
void *interrupt_routines[256];
void install_handler(int interrupt, void (*handler) (struct registers *regs)) {
interrupt_routines[interrupt] = handler;
}
void interrupt_handler(struct registers *reg) {
void (*handler)();
handler = interrupt_routines[reg->int_num];
if (handler) {
handler(reg);
}
if(reg->int_num >= 40) {
outb(0xA0, 0x20);
}
outb(0x20, 0x20);
}
void idt_set_gate(uint16_t num, uint32_t base, uint16_t sel, uint8_t attr) {
IDT[num].offset_low = (base & 0xFFFF);
IDT[num].offset_high = (base >> 16) & 0xFFFF;
IDT[num].selector = sel;
IDT[num].zero = 0;
IDT[num].attribute = attr;
}
#include "hString.h"
#include "hVideo.h"
#include "hInput.h"
Am Assembler - Code habe ich nur wie gesagt die Unterstriche
vor jedes "intr" und vor jede Funktion.