Hello. I've been working on code to test the speed of the APIC using the PIT. There are several problems I can't figure out. First, when testing my ISRs for the two timers, I get general protection faults on returning from the interrupts. Second, neither timer actually fires any interrupts. Any help on this would be much appreciated.
Link to the relevant file.
#GP on some ISRs, APIC and PIT not sending IRQs
Re: #GP on some ISRs, APIC and PIT not sending IRQs
Update: I figured out what was causing the #GPs. I hadn't loaded the right CS. Unfortunately, my code for loading the right CS doesn't work. When trying to load a new code segment for my bootloader, my code produces a #GP fault. Here is a link to the relevant code.
Edit: And i wasn't getting interrupts because I forgot to unmask them .
Edit: And i wasn't getting interrupts because I forgot to unmask them .
Last edited by K3achas on Fri Feb 22, 2019 6:15 am, edited 1 time in total.
Re: #GP on some ISRs, APIC and PIT not sending IRQs
Code: Select all
mov [rbx + gdt + 0x8], rax ; code segment 0x8
[...]
cs_swap:push qword 0x10
lea rax, [rel slb0]
push rax
retf
Carpe diem!
Re: #GP on some ISRs, APIC and PIT not sending IRQs
Thanks for pointing out that flaw. Unfortunately, that did not fix it.
Re: #GP on some ISRs, APIC and PIT not sending IRQs
I managed to solve the code by interrupting to load the right CS instead. Thanks to all who helped. The right code has been uploaded. The rest of this post will be stuff to help people search for the answer.
x86 reload CS. x86_64 reload CS. x86_64 load CS. x86_64 cannot load CS. x86_64 long mode load CS.
x86 reload CS. x86_64 reload CS. x86_64 load CS. x86_64 cannot load CS. x86_64 long mode load CS.
-
- Member
- Posts: 5586
- Joined: Mon Mar 25, 2013 7:01 pm
Re: #GP on some ISRs, APIC and PIT not sending IRQs
There's nothing wrong with using RETF to change CS, and I'd strongly recommend you change your code back to using RETF for clarity.
The reason it didn't work for you is NASM. When generating 64-bit code, NASM assembles RETF into the 32-bit form instead of the expected 64-bit form. You have to use "RETFQ" to get the expected 64-bit RETF.
(For comparison, YASM will produce the expected 64-bit RETF when generating 64-bit code.)
The reason it didn't work for you is NASM. When generating 64-bit code, NASM assembles RETF into the 32-bit form instead of the expected 64-bit form. You have to use "RETFQ" to get the expected 64-bit RETF.
(For comparison, YASM will produce the expected 64-bit RETF when generating 64-bit code.)