Interrupts in long mode?

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.
chris13524
Member
Member
Posts: 45
Joined: Sat Feb 27, 2016 10:52 pm

Interrupts in long mode?

Post by chris13524 »

I'm trying to port my 32-bit interrupt code to 64-bits, however, when I try to boot, it randomly triple faults (some clock interrupt?) and reboots.

I've got my C and ASM files on GitHub: I'm currently not setting up any GDT or TSS stuff, as I understand it, UEFI will do this for me.

Any ideas would be extremely helpful!
My operating system:
https://github.com/neonorb/aura
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Interrupts in long mode?

Post by SpyderTL »

UEFI will set up a long mode GDT for you, but you probably shouldn't rely on it too much. You will need to set up your own GDT and IDT to make sure you actually have access to all of the memory space and have all of the interrupts covered.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
konacake
Member
Member
Posts: 27
Joined: Wed Jul 02, 2014 2:10 am

Re: Interrupts in long mode?

Post by konacake »

It's also generally not a good idea to assume things, you should either check for it or do it yourself (with everything)
chris13524
Member
Member
Posts: 45
Joined: Sat Feb 27, 2016 10:52 pm

Re: Interrupts in long mode?

Post by chris13524 »

Is it necessary to setup a GDT? I am running in 64-bit mode, isn't that just flat address space?
My operating system:
https://github.com/neonorb/aura
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Interrupts in long mode?

Post by Octocontrabass »

The GDT isn't used as much in long mode as it is in protected mode, but you still need it.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Interrupts in long mode?

Post by SpyderTL »

And you will need to set up your own paging tables, as well.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
chris13524
Member
Member
Posts: 45
Joined: Sat Feb 27, 2016 10:52 pm

Re: Interrupts in long mode?

Post by chris13524 »

Would it be possible that the IDT doesn't work because I haven't called ExitBootServices yet?
My operating system:
https://github.com/neonorb/aura
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: Interrupts in long mode?

Post by FallenAvatar »

chris13524 wrote:Would it be possible that the IDT doesn't work because I haven't called ExitBootServices yet?
Only if you are booting from UEFI, and NOT Multiboot. They are for all intents and purposes mutualy exclusive.

I WOULD however like to see your grub.cfg from/for your bootable image (whether for HD, Floppy, CD or something else)

- Monk
chris13524
Member
Member
Posts: 45
Joined: Sat Feb 27, 2016 10:52 pm

Re: Interrupts in long mode?

Post by chris13524 »

tjmonk15 wrote:
chris13524 wrote:Would it be possible that the IDT doesn't work because I haven't called ExitBootServices yet?
Only if you are booting from UEFI, and NOT Multiboot. They are for all intents and purposes mutualy exclusive.

I WOULD however like to see your grub.cfg from/for your bootable image (whether for HD, Floppy, CD or something else)

- Monk
I am not supporting booting other than from UEFI. One, it makes it much easier, and two, UEFI is a standard that everybody should be supporting anyways soo...

So I am right in assuming I need to call ExitBootServices before I can use the IDT?
My operating system:
https://github.com/neonorb/aura
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Interrupts in long mode?

Post by thepowersgang »

Yes. If you've been loaded as a UEFI application, then until you call ExitBootServices, you're an application - and have no direct hardware access (it's quite likely you're in usermode - probably depends on the implementation)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: Interrupts in long mode?

Post by FallenAvatar »

-SNIP-

Ugh, completely wrong thread for this reply. Sorry.
Last edited by FallenAvatar on Wed Sep 07, 2016 10:54 am, edited 1 time in total.
chris13524
Member
Member
Posts: 45
Joined: Sat Feb 27, 2016 10:52 pm

Re: Interrupts in long mode?

Post by chris13524 »

So you are targeting UEFI? And don't understand what "qemu -kernel kernel.img" actually means... *sigh* go read the Wiki/Google until you understand the difference between Multiboot and UEFI. THEN you can ask questions why.

- Monk

P.S. Pretty much your code does not work ever. It happens to work by chance when using Multiboot from Qemu, but since you are targeting Uefi, that is a false positive and means nothing. In reality, your code is horribly broken in every way. Including using a tutorial meant for multiboot when you didnt have a clue what that meant. Honestly, you need to learn research skills before we spend any time helping you
What are you talking about? I do not support multiboot. If you are looking at the source code, the multiboot file is only there incase I wanted to add support again, I will likely remove it soon.
And don't understand what "qemu -kernel kernel.img" actually means...
I am not running this command, I am building a FAT partition and copying my UEFI image to it. Take a look at my makefile, it's all there. I can even confirm it works in VirtualBox and on real hardware.

Like I said, I'm not using multiboot, I don't know why you think I am.
My operating system:
https://github.com/neonorb/aura
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Interrupts in long mode?

Post by thepowersgang »

I suspect that @tjmonk15 got their threads mixed up, and confused you with another user.

From a quick look at your codebase, you never call ExitBootServices - So, yes, you'll want to do that before you try and set up your own IDT etc.
Do note that you can't use the UEFI console after calling that (nor anything else from the boot services structure)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
chris13524
Member
Member
Posts: 45
Joined: Sat Feb 27, 2016 10:52 pm

Re: Interrupts in long mode?

Post by chris13524 »

Do note that you can't use the UEFI console after calling that (nor anything else from the boot services structure)
Are you sure about this? Reading the specifications it says that some protocols will still be available after calling ExitBootServices (and some will not). I do not see where it says which ones are which.
My operating system:
https://github.com/neonorb/aura
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Interrupts in long mode?

Post by Octocontrabass »

chris13524 wrote:I do not see where it says which ones are which.
Try section 2.2.2 of the current UEFI specification (2.6).
Post Reply