Page 1 of 1

Amount of RAM

Posted: Tue Aug 10, 2004 4:28 am
by Henry
I need to determine the amount of RAM that?s in my computer, and I need to know which areas that are available. How do I do that? I?ve read the FAQ but I didnt understand what was written there. I dont understand how you get a "map" from this code? Please help me!

Re:Amount of RAM

Posted: Tue Aug 10, 2004 6:08 am
by Candy
Henry wrote: I need to determine the amount of RAM that?s in my computer, and I need to know which areas that are available. How do I do that? I?ve read the FAQ but I didnt understand what was written there. I dont understand how you get a "map" from this code? Please help me!

... sometimes I'm amazed by the incomprehensibility of others behaviour.

Try RBIL, int15/e820 plus links from there. Try int88. Try the GRUB map. Try probing. Try to work something out at least, before you come here that the explanation is too complex.

The FAQ is probably the easiest way to learn those things. If you don't understand the faq, do a step down and first learn the stuff below it.

Re:Amount of RAM

Posted: Tue Aug 10, 2004 6:42 am
by Pype.Clicker
Henry wrote: I?ve read the FAQ but I didnt understand what was written there. I dont understand how you get a "map" from this code? Please help me!
it would help us if you can better explain *what* you don't understand ... i.e. what question are still pending ...

I suggest you concentrate on "newer BIOSes - GET SYSTEM MEMORY MAP" as the first step. just call the INT with appropriated values in registers and you'll get an array of entry (e.g. the map) telling you the system configuration. An entry like

Code: Select all

0000-0000-0010-0000  0000-0000-00F0-0000 0000-0001 
for instance tells memory range 1MB-16MB is available for the OS

Re:Amount of RAM

Posted: Tue Aug 10, 2004 7:47 am
by Henry
Pype: I get the map using int 15, but my problem is to interpret it. I dont see how you get that MB 1-16 is available from that digits you wrote. That?s what I didnt understand

Re:Amount of RAM

Posted: Tue Aug 10, 2004 8:19 am
by Brendan
Hi,
Henry wrote: Pype: I get the map using int 15, but my problem is to interpret it. I dont see how you get that MB 1-16 is available from that digits you wrote. That?s what I didnt understand
Pype's digits are in hexidecimal:
0000-0000-0010-0000 0000-0000-00F0-0000 0000-0001

In decimal this is:
1048576 15728640 1

Which means, after the first 1 Mb (1048576 bytes) there's 15 Mb (or 15728640 bytes) of RAM (which is type 1).


Are you using NASM?

Code: Select all

;es:di = address of memory map data entry

   mov ebx,[es:di]
   mov ecx,[es:di+4]         ;ecx:ebx = base address of area in bytes
   mov edx,[es:di+8]
   mov esi,[es:di+12]         ;esi:edx = length of area in bytes
   mov eax,[es:di+16]         ;eax = memory area type (1 is RAM)

Cheers,

Brendan

Re:Amount of RAM

Posted: Tue Aug 10, 2004 8:31 am
by Henry
thank you brendan!
but what if ther? are gaps, so that the 1-2 mb is free, the 2-4 is in use, the 4-5 is free and so on?

And, do I only have to check the first 16 Mbytes? Is everything above "free to use"?

Re:Amount of RAM

Posted: Tue Aug 10, 2004 8:45 am
by Pype.Clicker
Note that the 'QWORDs' are mainly there for compatibility with systems that will have more than 4GB of physical memory (which you can only use with the appropriate extension on some of the x86 processors)

As a first step, you can simply check that the 'highest' 32 bits of the region is made of zeroes and work with DWords everywhere:

Code: Select all

;; looking for a region where we can put data
;; assuming that the whole MAP table has been read into [Map]
;; assuming that ECX contains the amount of entries used in [Map]
ScanBiosMap:

mov edi,Map
.loop:
cmp [edi+16],1
  jne .nextEntry
cmp [edi+4],0
  jne .PaeSupportRequired
cmp [edi+12],0
  jne .PaeSupportRequired

;; we found a region that could interrest us ...
mov eax,[edi]      ;; eax is the start of the region
mov edx,[edi+8]
add edx, eax      ;; edx is the end of the region
call SetupFreeSpace

.nextEntry:
add edi,20
dec ecx
jne .loop
Hope That Helps