Is multiboot2 info stored in memory without holes?

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.
Post Reply
User avatar
mrjbom
Member
Member
Posts: 300
Joined: Sun Jul 21, 2019 7:34 am

Is multiboot2 info stored in memory without holes?

Post by mrjbom »

Hi.
After grub boots kernel, I would like to copy all the information from multiboot2 info to bss, so I want to know if I can just copy total_bytes(stored in mbi structure)?
I.e., is all the info in the mbi in a continuous chunk of memory?

I was looking at the code in the multiboot2 spec and it seems that all the mbi info is in memory continuously.
Octocontrabass
Member
Member
Posts: 5218
Joined: Mon Mar 25, 2013 7:01 pm

Re: Is multiboot2 info stored in memory without holes?

Post by Octocontrabass »

It is all in one continuous chunk of memory, but you can't copy it to bss because its size is not a compile-time constant.
songziming
Member
Member
Posts: 65
Joined: Fri Jun 28, 2013 1:48 am
Contact:

Re: Is multiboot2 info stored in memory without holes?

Post by songziming »

You can reserve a buffer at end of BSS. Make sure that buffer is large enough to hold temporary info.

Copy boot info, mmap, sections, and all other temporary data to the buffer, and keep track of how many buffer used.

After all important data has been saved into BSS, you can use ram as you want.
Reinventing the Wheel, code: https://github.com/songziming/wheel
nullplan
Member
Member
Posts: 1644
Joined: Wed Aug 30, 2017 8:24 am

Re: Is multiboot2 info stored in memory without holes?

Post by nullplan »

May I ask why you want to do that? If it is just to have the data available after turning on paging, you may want to consider copying it to the initial stack instead. Bear in mind that you also need to relocate any pointers.
Carpe diem!
Post Reply