Problems with split ASM/C++ interrupt handler
Posted: Fri Jul 04, 2014 6:43 pm
Hello! Advance apologies if this is in the wrong subforum.
I'm trying to write a simple kernel in C++. I just finished writing basic interrupt support (based off of James Molloy's great tutorial - http://www.jamesmolloy.co.uk/tutorial_h ... 20IDT.html), and I'm having trouble with the ISR. I have two parts to it, one in assembly and another in C++.
Assembly, with two macros for err/noerr interrupts and a common stub:
And the high-level interrupt handling function:
Everything compiles and links fine, but when I trigger a software interrupt (asm volatile ("int 0x03") from the kernelmain) I get a screen filled with "Interrupt!" and endless QEMU resets. Commenting out "call handleISR" prevents this from happening and returns execution to the kernel, but also (obviously) prevents interrupts from being handled. What did I mess up? If anyone needs more info or code I'd be happy to provide it.
Thanks in advance,
John
I'm trying to write a simple kernel in C++. I just finished writing basic interrupt support (based off of James Molloy's great tutorial - http://www.jamesmolloy.co.uk/tutorial_h ... 20IDT.html), and I'm having trouble with the ISR. I have two parts to it, one in assembly and another in C++.
Assembly, with two macros for err/noerr interrupts and a common stub:
Code: Select all
%macro ISR_NOERR 1
GLOBAL isr%1
isr%1:
cli
push byte 0
push byte %1
jmp ISRTestStub
%endmacro
%macro ISR_ERR 1
GLOBAL isr%1
isr%1:
cli
push byte %1
jmp ISRTestStub
%endmacro
ISR_NOERR 0
ISR_NOERR 1
ISR_NOERR 2
ISR_NOERR 3
ISR_NOERR 4
ISR_NOERR 5
ISR_NOERR 6
ISR_NOERR 7
ISR_ERR 8
ISR_NOERR 9
ISR_ERR 10
ISR_ERR 11
ISR_ERR 12
ISR_ERR 13
ISR_ERR 14
ISR_NOERR 15
ISR_NOERR 16
ISR_NOERR 17
ISR_NOERR 18
ISR_NOERR 19
ISR_NOERR 20
ISR_NOERR 21
ISR_NOERR 22
ISR_NOERR 23
ISR_NOERR 24
ISR_NOERR 25
ISR_NOERR 26
ISR_NOERR 27
ISR_NOERR 28
ISR_NOERR 29
ISR_NOERR 30
ISR_NOERR 31
EXTERN handleISR
ISRStub:
pusha
mov ax, ds
push eax
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
call handleISR
pop ebx
mov ds, bx
mov es, bx
mov fs, bx
mov gs, bx
popa
add esp, 8
sti
iret
Code: Select all
typedef struct registers
{
uint32_t ds;
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
uint32_t intNum, errCode;
uint32_t eip, cs, eflags, useresp, ss;
} registers_t;
void handleISR(registers_t regs)
{
intvid->printTerminalString("Interrupt!\n");
}
Thanks in advance,
John