Bochs PANIC when trying to print from within an ISR
Posted: Fri Jun 18, 2010 6:30 pm
I am working on an Ubuntu 64 system, and I have made sure that GCC was properly configured to produce 32 bit code. I have done OS development before, and have gotten past this point successfully with similar code.
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:
The isr stub is jumped to by each individual isr which pushes an error code and the interrupt number, like in the tutorials. The exception handler just prints out the interrupt number.
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.
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.