Mail Archives: djgpp/1998/01/06/15:16:40
This is a multi-part message in MIME format.
--------------1A5D54315340
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
John Patton wrote:
>
> Hi,
>
> I am trying to locate some code that gets the
> amount of actual physical memory installed on
> the machine. I am not concerned at this time
> about virtual memory or available memory. If
> the machine has 32MB of real memory, I want to
> display this. I tried using the biosmemory()
> function and the most I can get it to return is
> 640k. My machine has 32MB installed, not 640k.
> If anyone knows a way to do this, I would greatly
> appreciate it.
This polls the CMOS to determine how much memory your system has:
--
Tony O'Bryan
http://www.geocities.com/SiliconValley/Park/7201
--------------1A5D54315340
Content-Type: text/plain; charset=us-ascii; name="Test.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Test.c"
#include <stdio.h>
#include <dos.h>
int GetPhysicalMemory(void)
{
unsigned BaseMemory;
unsigned ExtendedMemory;
/* Gets the amount of base memory from CMOS up to 640K */
outportb(0x70,0x15);
BaseMemory = inportb(0x71);
outportb(0x70,0x16);
BaseMemory += inportb(0x71) << 8;
/* Gets the amount of extended memory from CMOS */
outportb(0x70,0x17);
ExtendedMemory = inportb(0x71);
outportb(0x70,0x18);
ExtendedMemory += inportb(0x71) << 8;
/*
* Always leaves off the 384K between 640K and 1M, so add it in if there is
* any extended memory present.
*/
ExtendedMemory += ExtendedMemory ? 384 : 0;
return ExtendedMemory + BaseMemory;
}
--------------1A5D54315340--
- Raw text -