GRUB memory map location

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
giszo
Member
Member
Posts: 124
Joined: Tue Nov 06, 2007 2:37 pm
Location: Hungary

GRUB memory map location

Post by giszo »

Hi!

I just run throught the multiboot specificaiton in the hope that I found something about the location of the memory map provided by the GRUB, but unfortunately I didn't found anything. Was I a bit of cursory and missed something or it's really not specified and can be everywhere?

I just use the memory right after my kernel binary to manage memory pages (this is some kind of bitmap) and if the GRUB memory map can be everywhere I may override it with my bitmap. My question is that should I create a backup of the GRUB memory map before I initialize my bitmap or the map is located in a specified location and I can make sure somehow that I won't override it?

Thanks,
giszo
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: GRUB memory map location

Post by Hangin10 »

The address and length of the memory map (which GRUB gets using a BIOS interrupt) are provided in the multiboot
structure passed in EBX to your kernel.

If I remember correctly, the address is the 12th 32bit value, and the length is the 11th (and is in bytes).

EDIT: http://www.gnu.org/software/grub/manual ... ion-format
giszo
Member
Member
Posts: 124
Joined: Tue Nov 06, 2007 2:37 pm
Location: Hungary

Re: GRUB memory map location

Post by giszo »

Hangin10 wrote:The address and length of the memory map (which GRUB gets using a BIOS interrupt) are provided in the multiboot
structure passed in EBX to your kernel.

If I remember correctly, the address is the 12th 32bit value, and the length is the 11th (and is in bytes).

EDIT: http://www.gnu.org/software/grub/manual ... ion-format
Thanks, but as I meant before I've read the multiboot documentation. I just wanted to know if the possible addresses for the GRUB memory map is limited to a range (for example to the lower 1mb of memory, etc.) or not.
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: GRUB memory map location

Post by Hangin10 »

:oops:, totally misread.

It's usually under 1MB, because it's just the results of a BIOS interrupt.
I don't think GRUB ever moves it elsewhere.

EDIT: If anyone else has more specific info on this, it would be appreciated.
I've had similar thoughts, as I've wondered what area would be not
used by GRUB, but provide for a nice, large stack before paging is ready.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: GRUB memory map location

Post by Brendan »

Hi,
Hangin10 wrote:EDIT: If anyone else has more specific info on this, it would be appreciated.
I've had similar thoughts, as I've wondered what area would be not
used by GRUB, but provide for a nice, large stack before paging is ready.
My thoughts are that if you're writing a "multi-boot compliant" kernel (or boot loader or whatever), then you can't assume the boot manager will be GRUB and won't be something else that behaves completely differently. You'd only be able to rely on what the multi-boot specification says, and the multi-boot specification doesn't say anything about the permitted location/s for anything. To get around this I only touch data in my code's ".data" and ".bss" sections until memory management is setup (to make sure I can't trash data provided by the boot manager before I need it).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply