Page 1 of 1

Is multiboot2 info stored in memory without holes?

Posted: Wed Dec 27, 2023 7:39 pm
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.

Re: Is multiboot2 info stored in memory without holes?

Posted: Wed Dec 27, 2023 8:14 pm
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.

Re: Is multiboot2 info stored in memory without holes?

Posted: Wed Dec 27, 2023 11:34 pm
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.

Re: Is multiboot2 info stored in memory without holes?

Posted: Thu Dec 28, 2023 2:05 am
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.