Page 1 of 1

Memory map from GRUB

Posted: Sun Sep 05, 2010 7:41 am
by jobn
I successfully got the multiboot information structure from GRUB and parsed the memory map. However, the last entry int the map seems very strange to me. It contains this information:
  • Start: 0xfffc0000
  • Length: 256KB
  • Type: Unavailable
So the last 256KB of 4GB RAM are reported as unavailable. The weird thing is that I'm running my kernel in QEMU with only 1GB of RAM.

Any idea where this entry comes from?

Re: Memory map from GRUB

Posted: Sun Sep 05, 2010 7:50 am
by tharkun
What's the previous entry? Qemu could be mapping the video framebuffer up to 0xFFFC0000.

Re: Memory map from GRUB

Posted: Sun Sep 05, 2010 7:59 am
by jobn
I will post all the entries for completeness:
    • Start: 0x0
    • Length: 637KB
    • Type: Available
    • Start: 0x9f400
    • Length: 3KB
    • Type: Unavailable
    • Start: 0xf0000
    • Length: 64KB
    • Type: Unavailable
    • Start: 0x100000
    • Length: 1047540KB
    • Type: Available
    • Start: 0x3fffd000
    • Length: 12KB
    • Type: Unavailable
    • Start: 0xfffc0000
    • Length: 256KB
    • Type: Unavailable

Re: Memory map from GRUB

Posted: Sun Sep 05, 2010 8:10 am
by bewing
Do you have a real clear idea of what a BIOS is? And a BIOS ROM?
The end of your 4G memory space is the address of your BIOS ROM. Your emulator is reserving 256K of memory for your BIOS ROM. Since it is ROM, it is not available as memory.

Re: Memory map from GRUB

Posted: Sun Sep 05, 2010 8:44 am
by jobn
bewing wrote:Do you have a real clear idea of what a BIOS is? And a BIOS ROM?
The end of your 4G memory space is the address of your BIOS ROM. Your emulator is reserving 256K of memory for your BIOS ROM. Since it is ROM, it is not available as memory.
Well, I thought I had :)

My understanding is that the values returned in the memory map are physical addresses. So how can it be that if I only have 1GB of RAM, the BIOS ROM is located at an address close to 4GB?

Re: Memory map from GRUB

Posted: Sun Sep 05, 2010 1:15 pm
by bewing
Because RAM chips and ROM chips are two physically different things. They have different sets of addressing wires going to them. You have 1GB of addressing wires going to the RAM chips, and 256K of addressing wires going to the ROM chips. And those wires need to have different physical memory addresses, to access them. The Intel chip spec says that when the chip boots at poweron, the very first memory address that it tries to access is 0xfffffff0. This is expected to be 16 bytes before the very end of a boot ROM chip. (Then the boot ROM copies 64K of itself down to address 0xf0000, below 1M.) There is nothing anywhere that says that your computer's memory (especially the distinction between RAM and ROM!) must be contiguous. In fact, if you have more than 3GB of RAM, it is pretty much guaranteed that your RAM won't be contiguous, either.