hi mem - is this correct ?

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
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

hi mem - is this correct ?

Post by extremecoder »

i am coding a mem detection routine using 0x0000E820 interrupt in real mode ...

my boot loader runs in a VMWare, and I have allocated 32MB for my OS ...

this is what I get for hi mem detection ... please see the attached screenshot ..

is this correct ?
Attachments
himem.JPG
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: hi mem - is this correct ?

Post by Brendan »

Hi,
extremecoder wrote:is this correct ?
It doesn't look correct to me.

First, the way the information is displayed is confusing. It's looks like "<starting_address> - <ending_address>" but it's actually "<starting_address> - <length>". The number of digits used shouldn't vary either (e.g. addresses should all be displayed with 16 hex digits, but you're using any number of digits between 13 digits and 16 digits which means the text doesn't line up into columns).

For example, it should be displayed like this:

Code: Select all

0x0000000000000000 to 0x000000000009F7FF - 1 (Free Memory)
0x000000000009F800 to 0x000000000009FFFF - 2 (Reserved Area)
0x00000000000DC000 to 0x00000000000FFFFF - 2 (Reserved Area)
0x0000000000100000 to 0x0000000001EEFFFF - 1 (Free Memory)
0x0000000001EF0000 to 0x0000000010EEFFFF - 3 (ACPI Reclaimable Memory)
0x0000000001EFF000 to 0x0000000002EFEFFF - 4 (ACPI Non Volatile Memory)
0x0000000001F00000 to 0x0000000002EFFFFF - 1 (Free Memory)
0x00000000FEC00000 to 0x00000001EEBFFFFF - 2 (Reserved Area)
0x00000000FEE00000 to 0x00000001EEDFFFFF - 2 (Reserved Area)
0x00000000FFFE0000 to 0x000000002FFDFFFF - 2 (Reserved Area)
Apart from that, the starting address and type for each area looks right, but the length for the last 6 areas looks wrong.

I would assume that the actual address map is meant to look like this:

Code: Select all

0x0000000000000000 to 0x000000000009F7FF - 1 (Free Memory)
0x000000000009F800 to 0x000000000009FFFF - 2 (Reserved Area)
0x00000000000DC000 to 0x00000000000FFFFF - 2 (Reserved Area)
0x0000000000100000 to 0x0000000001EEFFFF - 1 (Free Memory)
0x0000000001EF0000 to 0x0000000001EFEFFF - 3 (ACPI Reclaimable Memory)
0x0000000001EFF000 to 0x0000000001EFFFFF - 4 (ACPI Non Volatile Memory)
0x0000000001F00000 to 0x0000000001FFFFFF - 1 (Free Memory)
0x00000000FEC00000 to 0x00000000FEC00FFF - 2 (Reserved Area)
0x00000000FEE00000 to 0x00000000FEE00FFF - 2 (Reserved Area)
0x00000000FFFE0000 to 0x000000000FFFFFFF - 2 (Reserved Area)
Or if you display it as "<starting_address> - <length>", then:

Code: Select all

0x0000000000000000 - 0x000000000009F800 - 1 (Free Memory)
0x000000000009F800 - 0x0000000000000800 - 2 (Reserved Area)
0x00000000000DC000 - 0x0000000000024000 - 2 (Reserved Area)
0x0000000000100000 - 0x0000000001DF0000 - 1 (Free Memory)
0x0000000001EF0000 - 0x000000000000F000 - 3 (ACPI Reclaimable Memory)
0x0000000001EFF000 - 0x0000000000001000 - 4 (ACPI Non Volatile Memory)
0x0000000001F00000 - 0x0000000000100000 - 1 (Free Memory)
0x00000000FEC00000 - 0x0000000000001000 - 2 (Reserved Area)
0x00000000FEE00000 - 0x0000000000001000 - 2 (Reserved Area)
0x00000000FFFE0000 - 0x0000000000020000 - 2 (Reserved Area)
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.
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: hi mem - is this correct ?

Post by extremecoder »

the format is like this:

start address - length - type

but, when I calculate it's going beyond 32 MB ... the actual mem is 32 MB
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: hi mem - is this correct ?

Post by pcmattman »

No, your first two "Free Memory" sections are all under 32 MB (the second Free Memory section goes from the 1 MB mark to the 32 MB mark).

The memory regions afterwards are most likely device address spaces (LFB for a VGA device, memory mapped IO regions, etc...).
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: hi mem - is this correct ?

Post by extremecoder »

i understand now ...

the first one goes to 638 KB ... correct
second goes to 30 MB ... correct

but what is the third one, which is actually 16 MB ?

I changed the RAM to 64 MB and ran again ...

the first one goes to 638 KB ... correct
second goes to 61 MB ... correct

again the third one, same 16 MB ?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: hi mem - is this correct ?

Post by pcmattman »

What exactly makes you think it's 16 MB?
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: hi mem - is this correct ?

Post by extremecoder »

if you see the third entry, the length is 0x1000000, which is 16777216 bytes long or 16 MB ..
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: hi mem - is this correct ?

Post by pcmattman »

Now that makes sense. I couldn't tell if you meant length or start address.

As for why it shows that region as free - you either have an error in your code or there's a reason for it that someone else who knows more than me will be able to tell you.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: hi mem - is this correct ?

Post by Brendan »

Hi,
extremecoder wrote:if you see the third entry, the length is 0x1000000, which is 16777216 bytes long or 16 MB ..
The third entry has "length = 0x00024000", which is an entry for the ROM shadow (from 0x00000000000DC000 to 0x00000000000FFFFF). The fourth entry has "length = 0x01DF0000", which is an entry for RAM (0x0000000000100000 to 0x0000000001EEFFFF). Both of these entries look entirely correct (if you ignore the confusing way it's displayed).

The fifth and sixth entries (for ACPI reclaimable and ACPI non volatile) have sane starting addresses, but the sizes are completely messed up (they overlap???). The seventh entry is unusual (normally the ACPI stuff consumes the highest N KiB of RAM), but I'm guessing this has the right start address (because all other entries have the right start address) and the wrong size, and should be 64 KiB of RAM that ends at a sane address (from 0x0000000001F00000 to 0x0000000001FFFFFF). The most likely explanation is that VMware's BIOS reserves a certain amount of space for ACPI but then doesn't use all of it, so it lets you have the unused RAM back.

The eight entry is for the I/O APIC, which should only consume 4 KiB (correct start address with stuffed up size). The ninth entry is for the local APIC which also should only consume 4 KiB (correct start address with stuffed up size).

The tenth/last entry is for the firmware ROM which always ends at 0xFFFFFFFF (excluding ancient computers, where the ROM itself actually was in the "ROM shadow" area). A 128 KiB ROM (from 0x00000000FFFE0000 to 0x00000000FFFFFFFF) sounds right. A 512 MiB ROM (from 0x00000000FFFE0000 to 0x000000011FFDFFFF) sounds extremely unlikely. Again - right start address, wrong length.


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.
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: hi mem - is this correct ?

Post by extremecoder »

i tried my level best to debug the code ...

still the last 6 lengths are not coming correctly ... is it becoz of VMWare ?
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: hi mem - is this correct ?

Post by extremecoder »

Brendan, i found out the problem ... it was in a simple string zero'ing code ...

now I think it's right ... the format is :

start - length - type
Attachments
himem.JPG
Post Reply