OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 11:23 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: #GP on some ISRs, APIC and PIT not sending IRQs
PostPosted: Mon Feb 18, 2019 2:27 pm 
Offline
User avatar

Joined: Sat May 26, 2018 5:32 pm
Posts: 22
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.

_________________
The maker of Foxtrot microkernels. Currently just Greyhound, which is currently smaller than 3 KiB.
Also working on osmkVII.


Top
 Profile  
 
 Post subject: Re: #GP on some ISRs, APIC and PIT not sending IRQs
PostPosted: Thu Feb 21, 2019 7:38 pm 
Offline
User avatar

Joined: Sat May 26, 2018 5:32 pm
Posts: 22
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 #-o #-o #-o .

_________________
The maker of Foxtrot microkernels. Currently just Greyhound, which is currently smaller than 3 KiB.
Also working on osmkVII.


Last edited by K3achas on Fri Feb 22, 2019 6:15 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: #GP on some ISRs, APIC and PIT not sending IRQs
PostPosted: Thu Feb 21, 2019 10:17 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1604
Code:
mov [rbx + gdt + 0x8], rax   ; code segment 0x8
[...]
cs_swap:push qword 0x10
   lea rax, [rel slb0]
   push rax
   retf


Notice the problem yet? Your code segment is 0x08, but you are trying to enter segment 0x10.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: #GP on some ISRs, APIC and PIT not sending IRQs
PostPosted: Fri Feb 22, 2019 6:18 am 
Offline
User avatar

Joined: Sat May 26, 2018 5:32 pm
Posts: 22
Thanks for pointing out that flaw. Unfortunately, that did not fix it.

_________________
The maker of Foxtrot microkernels. Currently just Greyhound, which is currently smaller than 3 KiB.
Also working on osmkVII.


Top
 Profile  
 
 Post subject: Re: #GP on some ISRs, APIC and PIT not sending IRQs
PostPosted: Fri Feb 22, 2019 9:09 am 
Offline
User avatar

Joined: Sat May 26, 2018 5:32 pm
Posts: 22
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.

_________________
The maker of Foxtrot microkernels. Currently just Greyhound, which is currently smaller than 3 KiB.
Also working on osmkVII.


Top
 Profile  
 
 Post subject: Re: #GP on some ISRs, APIC and PIT not sending IRQs
PostPosted: Fri Feb 22, 2019 11:21 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
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.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 107 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group