Page 1 of 1
grub multiboot.h structures
Posted: Thu Mar 17, 2005 7:27 am
by Poseidon
from the multiboot.h what I use for the grub multiboot header I use also the memory_map_t structure to get the memory map, but do I have length_low and base_low, length_high and base_high or both (add low address to high address and same with length)?
thanks.
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 8:03 am
by Solar
From the
Multiboot documentation:
If bit 6 in the flags word is set, then the mmap_* fields are valid, and indicate the address and length of a buffer containing a memory map of the machine provided by the BIOS. mmap_addr is the address, and mmap_length is the total size of the buffer. The buffer consists of one or more of the following size/structure pairs (size is really used for skipping to the next pair):
[tt]
+-------------------+
-4 | size |
+-------------------+
0 | base_addr_low |
4 | base_addr_high |
8 | length_low |
12 | length_high |
16 | type |
+-------------------+
[/tt]
where size is the size of the associated structure in bytes, which can be greater than the minimum of 20 bytes. base_addr_low is the lower 32 bits of the starting address, and base_addr_high is the upper 32 bits, for a total of a 64-bit starting address. length_low is the lower 32 bits of the size of the memory region in bytes, and length_high is the upper 32 bits, for a total of a 64-bit length. type is the variety of address range represented, where a value of 1 indicates available RAM, and all other values currently indicated a reserved area.
Does this answer your question?
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 8:04 am
by dh
If you don't mind, could you post your structures and the code to utialize them? I'm having a hard time finding C code for the purpose. Thanks Ahead!!
Cheers, DH.
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 8:08 am
by durand
The memory map given by GRUB is able to support 64 bit memory ranges. But it splits up the 64 bit address into 2 32 bit unsigned integers.
So, according to the memory_map_t structure, each range will start at:
(base_high << 32) | (base_low)
giving you a 64 bit memory address.
The length of that memory range will be:
(length_high << 32 ) | ( length_low )
If you are only running a 32 bit machine and you have less than 4GB of memory, then it's kind of safe to ignore the high bits. So, your memory range will start at base_low and will be length_low bytes long.
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 8:32 am
by Pype.Clicker
durand wrote:
If you are only running a 32 bit machine and you have less than 4GB of memory, then it's kind of safe to ignore the high bits. So, your memory range will start at base_low and will be length_low bytes long.
hm. not quite. What about a region starting at 0x0000,0001,FF00,0000 and ending at 0x0000,0001,FFFF,FFFF, for instance ? ignoring the highest bits will lead to errors if those bits aren't 0. If your OS doesn't support memory above 4GB, it should rather ignore regions with "base.high>0" and truncate regions with "limit.high>0" to limit=0x0000,0000,FFFF,FFFF, imho.
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 8:50 am
by Poseidon
thanks
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 9:45 am
by Solar
Dragon_Hilord wrote:
I'm having a hard time finding C code for the purpose.
IIRC, the GRUB source tarball contains example code for basic Multiboot usage?
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 10:56 am
by mystran
Well, it contains what is known as a "Hello World" kernel. In fact, the GRUB hello world is quite sophisticated for a hello world kernel, as it also prints stuff like memory map information that GRUB gave it. So.. basicly it has example code for all multiboot stuff there is.
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 11:28 am
by durand
hm. not quite. What about a region starting at 0x0000,0001,FF00,0000 and ending at 0x0000,0001,FFFF,FFFF, for instance ? ignoring the highest bits will lead to errors if those bits aren't 0. If your OS doesn't support memory above 4GB, it should rather ignore regions with "base.high>0" and truncate regions with "limit.high>0" to limit=0x0000,0000,FFFF,FFFF, imho.
Oh yeah. true. Always good to check for that. But I mentioned 32 bits. Wouldn't that then mean that the machine has something that's sitting at +- 8GB of RAM in 32 bits? When would that occur?
Perhaps that would happen if PAE was enabled...and the machine was in 36 bit mode or whatever. Otherwise, I don't see how the CPU could reference that high up. What am I missing?
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 11:56 am
by Candy
since it's possible with PAE you can end up in such situations where you don't support it.
Re:grub multiboot.h structures
Posted: Thu Mar 17, 2005 2:32 pm
by dh
;P. I never looked at the source. :-[
Cheers, DH.
Re:grub multiboot.h structures
Posted: Fri Mar 18, 2005 8:04 am
by dh
I just found the structures and all. Takes a bit of work to make the structures the way I liked it so it worked.
For thoes don't who don't know, it's located in grub/docs/*