Page 19 of 20

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 8:16 pm
by zap8600
I'm doing something wrong. What is it?

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 8:22 pm
by Octocontrabass
What have you done to debug it so far?

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 8:26 pm
by zap8600
Octocontrabass wrote:What have you done to debug it so far?
Nothing at the moment. I'm still trying to get GRUB to recognise the multiboot header.

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 8:33 pm
by Octocontrabass
Have you examined your kernel binary in a hex editor? Your Multiboot header needs to be located within the first 8kB of your kernel. You may need to modify your linker script or your linker flags to ensure the linker doesn't insert any other sections or any padding before the Multiboot header.

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 8:42 pm
by zap8600
Octocontrabass wrote:Have you examined your kernel binary in a hex editor? Your Multiboot header needs to be located within the first 8kB of your kernel. You may need to modify your linker script or your linker flags to ensure the linker doesn't insert any other sections or any padding before the Multiboot header.
There are no sections before the multiboot header. I don't use linker flags, but there are C flags used. If correct, you're saying that the multiboot header should be at the start of the file, right? If so, then (I think) only the ELF header is there. I'm not sure.

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 9:13 pm
by Octocontrabass
zap8600 wrote:If correct, you're saying that the multiboot header should be at the start of the file, right?
No, the ELF header goes at the start of the file. The Multiboot header should be somewhere after the ELF header, within the first 8kB of the file.

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 9:17 pm
by zap8600
Octocontrabass wrote:
zap8600 wrote:If correct, you're saying that the multiboot header should be at the start of the file, right?
No, the ELF header goes at the start of the file. The Multiboot header should be somewhere after the ELF header, within the first 8kB of the file.
Is there a certain value I'm looking for?

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 9:29 pm
by Octocontrabass
What value does the Multiboot header start with? Look for that value.

(Don't forget that x86 is little-endian.)

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 9:34 pm
by zap8600
Octocontrabass wrote:What value does the Multiboot header start with? Look for that value.

(Don't forget that x86 is little-endian.)
The header starts with 0x1BADB002, the value for the magic. I'm also not sure what little-endian is.

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 9:54 pm
by Octocontrabass
zap8600 wrote:I'm also not sure what little-endian is.
That's the sort of thing you should probably already know before you try to write an OS.

Type it into your favorite search engine, see if you can figure out why it matters when you're looking for your Multiboot header.

Re: How to make a GDT?

Posted: Tue Dec 13, 2022 10:10 pm
by zap8600
Octocontrabass wrote:
zap8600 wrote:I'm also not sure what little-endian is.
That's the sort of thing you should probably already know before you try to write an OS.

Type it into your favorite search engine, see if you can figure out why it matters when you're looking for your Multiboot header.
If correct, little-endian means that the data is stored with the least significant bit first. Does that just mean reverse order?

Re: How to make a GDT?

Posted: Wed Dec 14, 2022 10:12 am
by zap8600
Should I use something like NASM? Should I use EDK2 to make my kernel an EFI file? Is there an existing multiboot header I can use? What do I do?

Edit: I'm going to just continue to use the Limine boot protocol. I thought it would of been better to to set up paging myself, because I would learn from it, but I'll just use the Limine boot protocol, since I'm dumb.

Re: How to make a GDT?

Posted: Wed Dec 14, 2022 10:35 am
by iansjack
We’re all dumb until someone has taught us or we have read the appropriate documents.

I would suggest you use multiboot (it’s easy to construct the header if you read the specifications) and use grub as your boot loader. It can handle BIOS or UEFI.

Re: How to make a GDT?

Posted: Wed Dec 14, 2022 10:50 am
by zap8600
iansjack wrote:We’re all dumb until someone has taught us or we have read the appropriate documents.

I would suggest you use multiboot (it’s easy to construct the header if you read the specifications) and use grub as your boot loader. It can handle BIOS or UEFI.
Will my OS boot, even if GRUB doesn't recognize the multiboot header?

Re: How to make a GDT?

Posted: Wed Dec 14, 2022 11:08 am
by iansjack
No.