I am new to OS developing and I wanted to go directly with UEFI and x64, trying to avoid BIOS-boot and mode switching. It works good so far, however I can't really get CPU-exception interrupts working. First I tried to do it manually with "lidt" and a lot of inline assembler, but I found the UEFI-function "RegisterExceptionCallback" in the official documentation here:
https://uefi.org/sites/default/files/re ... 21.1036676
This looked promising, so I went with that. However it doesn't really work. Qemu doesn't double/triple fault anymore, when an exception occurs, but my exception handling function isn't called.
This is my code:
Code: Select all
void exceptionDiv() { // The function I want to be called when the exception occurs
kprintf("Exception 0x0!\n"); // This never happens
asm volatile("iretq");
}
// ...
EFI_DEBUG_SUPPORT_PROTOCOL *dsp;
EFI_GUID dspGUID = EFI_DEBUG_SUPPORT_PROTOCOL_GUID;
status = ST->BootServices->LocateProtocol(&dspGUID, NULL, (void**) &dsp);
dsp->RegisterExceptionCallback(dsp, 0, exceptionDiv, EXCEPT_EBC_DIVIDE_ERROR);
kprintf("Test1\n"); // This works
uint32 test1 = 42, test2 = 0;
test1 /= test2; // The exception occurs here
kprintf("Test2\n"); // This never happens