Memory map from GRUB

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
jobn
Posts: 5
Joined: Sun Sep 05, 2010 7:32 am

Memory map from GRUB

Post 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?
tharkun
Member
Member
Posts: 51
Joined: Sat Mar 21, 2009 1:29 pm
Location: Ireland

Re: Memory map from GRUB

Post by tharkun »

What's the previous entry? Qemu could be mapping the video framebuffer up to 0xFFFC0000.
jobn
Posts: 5
Joined: Sun Sep 05, 2010 7:32 am

Re: Memory map from GRUB

Post 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
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Memory map from GRUB

Post 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.
jobn
Posts: 5
Joined: Sun Sep 05, 2010 7:32 am

Re: Memory map from GRUB

Post 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?
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Memory map from GRUB

Post 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.
Post Reply