Multiboot 1 Boot Information total size

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
ajxs
Member
Member
Posts: 27
Joined: Mon Jun 13, 2016 2:25 am
Libera.chat IRC: ajxs
Location: Sydney

Multiboot 1 Boot Information total size

Post by ajxs »

Is there a quick and reliable way find out the total size of the Multiboot 1 boot information in memory?

Just to clarify: I'm not asking about the size of the structure pointed to by the value in the EBX register, I'm asking about the total size of all the information in memory.

I'm currently working on an x86 Multiboot 1 compatible Kernel. The standard offers no guarantees about where GRUB will place this information or its total size. The specification states:
The Multiboot information structure and its related substructures may be placed anywhere in memory by the boot loader (with the exception of the memory reserved for the kernel and boot modules, of course). It is the operating system’s responsibility to avoid overwriting this memory until it is done using it.
In practice this seems to be loaded within the lowest 1MB of memory. Up until this point, during boot I initialise my boot paging structures with identity mapping for the lowest 1MB as a way to ensure that the Multiboot information is accessible by the higher-half kernel main. Finding out the location of this structure is trivial, but I haven't found any information about finding an accurate size. ( Ideally without walking the entire structure ).
It looks like the Multiboot 2 information structure provides this information very clearly. Moving to Multiboot 2 in the long run sounds like a good idea.

I asked this question on StackOverflow, and haven't received any responses yet. I understand if people would rather answer there and get the reputation reward. Here's the link to my question:
https://stackoverflow.com/questions/588 ... total-size
songziming
Member
Member
Posts: 71
Joined: Fri Jun 28, 2013 1:48 am
Contact:

Re: Multiboot 1 Boot Information total size

Post by songziming »

No. Multiboot info struct is not the only data structure passed by grub, and those information might be discontinuous. Even if you have the total byte count, you still don't know which piece of memory is used.

Before memory manager starts, copy everything you might need in the future into a buffer (normally bss). Since bss is a part of kernel image, grub won't put any data structure there. After all the important info is backed up, init memory manager, which would overwrite existing data. When you need those grub info, use the backup version instead.
Reinventing the Wheel, code: https://github.com/songziming/wheel
ajxs
Member
Member
Posts: 27
Joined: Mon Jun 13, 2016 2:25 am
Libera.chat IRC: ajxs
Location: Sydney

Re: Multiboot 1 Boot Information total size

Post by ajxs »

Thank you for the reply! That sounds like a good strategy for working with this.
Post Reply