Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
ok, i'm trying to see if i can get a system interrupt to work. but, whenever i call the interrupt (int 81), interrupt runs (which is good), but then it triple faults. Bochs gives the response that
LDTR.valid=0 will be reported by BOCHS when you attempt to load a descriptor with an LDT selector (bit 2 set) while you haven't do any LLDT yet ...
Chris Griese likely pinpointed your problem... check your stack pushes/pops if you have a stub function in ASM, and do a stub function in ASM if you don't have one already ...
C functions automatically embrace your code with <push ebp; mov ebp, esp> and <mov esp, ebp> ... so trying to write an IRET in C code will fail.
The isr is added to the IDT at index 81 with settings of 0xEF00. Present, ring0, trap gate. I don't get why its telling me something about the LDT. I don't have one, but i thought they were optional?
northfuse wrote:
this is my isr:
The isr is added to the IDT at index 81 with settings of 0xEF00. Present, ring0, trap gate. I don't get why its telling me something about the LDT. I don't have one, but i thought they were optional?
Did you read this ?
LDTR.valid=0 will be reported by BOCHS when you attempt to load a descriptor with an LDT selector (bit 2 set) while you haven't do any LLDT yet ...
Indeed, the LDT is optionnal, but if some garbage is loaded in a segment register, the CPU might try to locate the LDT (because the selector is requesting so).
Btw, did you load IDT#81 with a pointer to system_call or system_call_isr ? (i know it's a dumb question ... i don't think you might have loaded system_call on purpose ... it's just in case).
Your ISR code looks correct, except for the "pushes" which is likely to be a typo
i got rid of the outportb call, and changed 'pushes' to 'push es' and it worked! couldn't find out what the pushes call meant, though. nasm didn't complain about it.
That's weird. I assembled your old interrupt handler, with the PUSHES instruction. It assembled with no errors, but in the disassembly, I saw that NASM had ignored that line.
northfuse wrote:
i got rid of the outportb call, and changed 'pushes' to 'push es' and it worked! couldn't find out what the pushes call meant, though. nasm didn't complain about it.
Arrrgh! NASM didn't complain because it thought "pushes" was a label. This behavior caught me too, once.
Feature or bug? Discuss.
"nasm -w+orphan-labels ..." will generate warnings for labels that don't end with colons.