Hallo Leute,
ich weiß nicht woran das hier liegt. Folgendes passiert bei mir:
%macro isr_stub 1
global isr%1
isr%1:
cli
push byte 0
push byte %1
jmp isr_common_stub
%endmacro
isr_common_stub:
; save cpu state by pushing
; main purpose registers onto the stack
pusha
mov eax, ds
push eax
mov eax, 0x10
mov ds, eax
mov es, eax
mov fs, eax
mov gs, eax
push esp
call Isr_Handler ; call interrupt handler
mov esp, eax
pop eax
mov ds, eax ; get old ds
;mov es, eax
;mov fs, eax
;mov gs, eax
popa
add esp, 8 ; pop error code, interrupt number
sti ; enable interrupts
iret ; interrupt return
Nachdem das Programm vom Isr_Handler zurückkehrt löst es bei der Instruktion mov ds, eax einen INT13 aus. Kommentiere ich dies Instruktion aus läuft alles soweit ohne Probleme.
Der Plan ist VOR Isr_Handler den Kernel-Mode aufzusetzen indem zuvor das verwendete DS Register gepush wird und dnach die Register entpsrechend gesetzt werden. Nach Isr_Handler will ich das alte DS wieder auslesen und in das Register schreiben.
Ich komme nicht wirklich dahinter was das Problem ist..
cpu_state* Isr_Handler(cpu_state *state) {
if (state->int_no <= 0x1F) {
dprint("[ISR] Exception captured. Kernel stopped.");
dprint("CPU State:");
dprint(" INT: %d, RING: %d, ERRCODE: 0x%X\n"
"\n"
" EAX: 0x%X EBP: 0x%X EBX: 0x%X ECX: 0x%X\n"
" EDI: 0x%X EDX: 0x%X EIP: 0x%X ESI: 0x%X\n"
" ESP: 0x%X EFLAGS: 0x%X\n"
" CS: 0x%X DS: 0x%X SS: 0x%X", state->int_no,
state->useresp, state->err_code, state->eax, state->ebp, state->ebx,
state->ecx, state->edi, state->edx, state->eip, state->esi,
state->esp, state->eflags, state->cs, state->ds, state->ss);
while (1) {
// Stop CPU
asm volatile ("cli; hlt");
}
}
// Hardware-Interrupts
if (state->int_no >= 0x20 && state->int_no <= 0x2f) {
dprint("[ISR] Hardware interrupt 0x%X received.", state->int_no);
dprint(" INT: %d, RING: %d, ERRCODE: 0x%X\n"
"\n"
" EAX: 0x%X EBP: 0x%X EBX: 0x%X ECX: 0x%X\n"
" EDI: 0x%X EDX: 0x%X EIP: 0x%X ESI: 0x%X\n"
" ESP: 0x%X EFLAGS: 0x%X\n"
" CS: 0x%X DS: 0x%X SS: 0x%X\n",
state->int_no, state->useresp, state->err_code,
state->eax, state->ebp, state->ebx, state->ecx,
state->edi, state->edx, state->eip, state->esi,
state->esp, state->eflags,
state->cs, state->ds, state->ss);
//uint32_t tss[32] = { 0x00, 0x00, 0x10 };
// Call Scheduler
if (state->int_no == 0x20) {
state = Scheduler_Schedule(scheduler, state);
}
if (state->int_no >= 0x28) {
// TODO Keyboard driver
outb(0xA0, 0x20);
}
outb(0x20, 0x20); // End of interrupt (EOI)
return state;
}