OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:28 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Can use Multiboot1 for x86_64 kernel?
PostPosted: Fri Dec 17, 2021 6:33 pm 
Offline
Member
Member

Joined: Wed Oct 20, 2021 6:00 pm
Posts: 102
Location: Paraguay
Hi,
I have one question? Can I use Multiboot1 with x86_64 kernel? If so, can it use with ELF64? I want to writing debug utilities with stack trace, but Multiboot2 is too complicated for me :D


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Fri Dec 17, 2021 8:13 pm 
Offline
Member
Member
User avatar

Joined: Tue Nov 24, 2020 10:17 am
Posts: 38
Multiboot 2 is not complicated. I strongly recommend it over Multiboot 1. I've also tried to start with Multiboot 1, but I met a lot of problems. I don't remember what kind of problems (this was more than a year ago), but at least with Multiboot 2 everything works great. Multiboot 1 & 2 are very similar for the most basic tasks. The main difference is how data is organized in memory. Multiboot 2 uses tags, which are placed in memory after the header. The common pitfall is that tags are aligned, so they may have some gaps between them. However it is not hard to parse them.

Also you can try my auxiliary library for kernel development (https://github.com/tailix/libkernaux). It includes Multiboot 2 parser. Unfortunatelly it's not well documented, examples are missing, and the API for Multiboot 2 parser will change soon.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Fri Dec 17, 2021 8:32 pm 
Offline
Member
Member

Joined: Wed Oct 20, 2021 6:00 pm
Posts: 102
Location: Paraguay
kotovalexarian wrote:
Multiboot 2 is not complicated. I strongly recommend it over Multiboot 1. I've also tried to start with Multiboot 1, but I met a lot of problems. I don't remember what kind of problems (this was more than a year ago), but at least with Multiboot 2 everything works great. Multiboot 1 & 2 are very similar for the most basic tasks. The main difference is how data is organized in memory. Multiboot 2 uses tags, which are placed in memory after the header. The common pitfall is that tags are aligned, so they may have some gaps between them. However it is not hard to parse them.

Also you can try my auxiliary library for kernel development (https://github.com/tailix/libkernaux). It includes Multiboot 2 parser. Unfortunatelly it's not well documented, examples are missing, and the API for Multiboot 2 parser will change soon.

Thank you.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 1:52 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 04, 2021 7:25 am
Posts: 31
Yes, you can use Multiboot1 for a x86_64 kernel.

_________________
mid.net.ua


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 3:26 am 
Offline
Member
Member

Joined: Wed Oct 20, 2021 6:00 pm
Posts: 102
Location: Paraguay
mid wrote:
Yes, you can use Multiboot1 for a x86_64 kernel.

Oh, thank you.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 6:55 am 
Offline
Member
Member

Joined: Wed Oct 20, 2021 6:00 pm
Posts: 102
Location: Paraguay
NeonLightions wrote:
mid wrote:
Yes, you can use Multiboot1 for a x86_64 kernel.

Oh, thank you.

Wait, there's still one question: Can I use it with ELF64?


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 7:27 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
Ye, GRUB works with ELF64. I'm not sure if that's actually in the multiboot spec, however.

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 7:53 am 
Offline
Member
Member

Joined: Wed Oct 20, 2021 6:00 pm
Posts: 102
Location: Paraguay
By the way, I have post my code on stack tracing to my repo. It just catch 1 function name and stop. Can anyone help me solve this?


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 1:53 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
Multiboot1 will always drop you off in a 32-bit environment. If you can write a 32-bit entry point in assembler that manages to prepare all the paging structures you require and switches to 64-bit mode before running any C function, then yes, you can use multiboot1. I personally have chosen to implement multiboot1 for my 64-bit kernel by using the module mechanism: I have written a small 32-bit "kernel" that takes the actual 64-bit kernel as a module (and requests page alignment of all modules). And then just creates the paging structures the main kernel requires, and formats the multiboot information in a kernel-specific way, and then it just launches the 64-bit kernel.

This is done so that I can also have a UEFI bootloader independent of the multiboot loader, and run my kernel on both UEFI and legacy machines. However, if you are creating a 64-bit kernel, then the number of machines not able to run a UEFI application is minuscule compared the number of those that are, so the UEFI application is almost certainly more important than the multiboot application. I would therefore suggest you look into creating one of those and find an emulator that allows you to run UEFI applications, or a way to configure your emulator to do so.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 3:18 pm 
Offline
Member
Member
User avatar

Joined: Tue Nov 24, 2020 10:17 am
Posts: 38
NeonLightions wrote:
Can anyone help me solve this?
Please, make your question more specific and give a link to your code.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sat Dec 18, 2021 7:59 pm 
Offline
Member
Member

Joined: Wed Oct 20, 2021 6:00 pm
Posts: 102
Location: Paraguay
kotovalexarian wrote:
NeonLightions wrote:
Can anyone help me solve this?
Please, make your question more specific and give a link to your code.

I'm sorry, I forgot to give you my repo, here is it: https://github.com/NeonLightions/Amore-OS-x64
Also, I want to have a back trace mechanism like Python. It will take return address in stack frames, look for symbol name in ELF symbol table and print it into screen.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sun Dec 19, 2021 2:46 am 
Offline

Joined: Tue Jul 07, 2020 3:18 pm
Posts: 15
As I understand right even multiboot2 leaves you in protected mode(32bit). And you need to switch to long mode(64bit) by yourself.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sun Dec 19, 2021 6:07 pm 
Offline
Member
Member
User avatar

Joined: Tue Nov 24, 2020 10:17 am
Posts: 38
NeonLightions wrote:
Also, I want to have a back trace mechanism like Python. It will take return address in stack frames, look for symbol name in ELF symbol table and print it into screen.
That's a nice idea. I also feel the need in such mechanism. I have not idea how to achieve this, but I'll take a look.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sun Dec 19, 2021 7:52 pm 
Offline
Member
Member

Joined: Wed Oct 20, 2021 6:00 pm
Posts: 102
Location: Paraguay
kotovalexarian wrote:
NeonLightions wrote:
Also, I want to have a back trace mechanism like Python. It will take return address in stack frames, look for symbol name in ELF symbol table and print it into screen.
That's a nice idea. I also feel the need in such mechanism. I have not idea how to achieve this, but I'll take a look.

Thanks, I'm looking forward to it.


Top
 Profile  
 
 Post subject: Re: Can use Multiboot1 for x86_64 kernel?
PostPosted: Sun Dec 19, 2021 9:57 pm 
Offline
Member
Member
User avatar

Joined: Tue Nov 24, 2020 10:17 am
Posts: 38
Here is some stack tracing example: https://github.com/josehu07/hux-kernel/ ... -&-Testing


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 75 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