Now, when I try to print a message within my ISR handler, the screen fills with garbage and after a while, Bochs panics with the message "APIC write at unaligned address 0xfee00ffc." However, I am using the old PIC and not the APIC. I have checked and made sure that my text-mode printf code works fine outside of the interrupt handler. I also inserted code to halt the processor inside the exception handler function. It printed fine, and halted, leading me to believe the problem has something to do with the cleanup code after the exception handler. And if I just leave the exception handler as a blank stub function, it returns fine and I can print after it.
As of now, the ISR code is a slightly modified version of the same from JamesM's kernel development tutorials. The part of the code I feel has the problem is this:
Code: Select all
ALIGN 4
isr_stub:
pushad
mov ax,ds
push eax
mov ax,0x10 ; Kernel data segment
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
call exception_handler
pop eax
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
popad
add esp,8
iret
The "add esp,8" cleans up the pushed error code and interrupt number.
I plan to optimize the interrupt code later, but I want to get it at least working first. Any help would be appreciated.