delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/30/14:14:24

Date: Thu, 30 Sep 1999 13:52:54 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Johnny Chan <johnny_chan AT phoenix DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: How to browse thru all the Physical RAM installed
In-Reply-To: <000301bf09e3$3fa705c0$ae3d7a86@phoenix.com>
Message-ID: <Pine.SUN.3.91.990930135231.20873S-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 28 Sep 1999, Johnny Chan wrote:

> I want to know how to browse thru all the phyiscal RAM I had installed in
> the system.

Please explain ``browse thru memory''.  Specifically, does this mean
you need to access all of the memory in one large chunk, or can you
do this in a piecemeal fashion?  Also, when you access that memory,
what do you want to do, exactly?  (The best technique to achieve that
depends on answers to these questions.)

> I am writing a diagnostic program in MSDOS using DJGPP and WDOSX to verify a
> network server device. This device requires anything from 500MB to 1GB of
> physical memory.

What do you mean it ``requires anything from 500MB to 1GB of physical
memory''?  Does it need that much avaialable to it at all times?

> I am trying to develop some software to hack on those
> physical memory to sniff the activities on the RAM.

Again, please explain what do you mean by ``activities on the RAM''.

> if (__djgpp_nearptr_enable())
> {
>   x=(char *)(__djgpp_conventional_base);
>   printf ("%.8lX\n", __djgpp_conventional_base);
>   for (i=0; i<800000h; i++)	// read first 8MB
>     printf ("%X ", x[i]);
>   __djgpp_nearptr_disable();
> }
> 
> I tried this code in my 16MB computer and __djgpp_conventional_base shows
> FFBFF3C1h. Anybody people know why it is FFBFF3C1h?

Please read section 18.6 of the DJGPP FAQ list: it explains, among
other things, that __djgpp_conventional_base is the *negated* base
address of the DS segment used by a DJGPP program.  In other words, it
is a NEGATIVE number.

(In fact, I suggest to read the entire Chapter 18 of the FAQ, even
though some of the material there is irrelevant to your specific
problem.  Section 18.7, in addition to 18.6, is a must.)

> I wonder if this really can access to the full 4GB RAM?

Yes, it can.  But you need to be aware of a subtlety here.  The call
to __djgpp_nearptr_enable allows access to every address in the 4GB
space, but it does NOT map any physical addresses into this address
space.  In other words, you can access any address, but your program
manipulates *logical* addresses, not *physical* ones, so what you will
see is not the contents of the respective physical address, because
the physical address isn't mapped in, and the physical-to-logical
address relationship is not 1:1.

What you need to do in addition is to map the physical addresses into
your address space.  Section 18.7 explains how.

(The nearptr hack was originally invented to allow access to
memory-mapped devices in the first 1MB, like the video RAM, and those
are always mapped in in the DPMI environment.  Addresses above 1MB are
by default NOT mapped in.)

> Do you know any DOS-like 32bit debug.exe I can use? any sample code on this
> area?

What's wrong with the DJGPP debuggers, like FSDB and the DJGPP port of
GDB?  See section 12.1 of the FAQ for more details.

> Also, I wonder how I can map all the RAM I have on the system (for example
> 2GB RAM) as the logical linear memory so that my program can access it using
> the near ptr?

See above; section 18.7 of the FAQ has the details.

> Finally, as we all known, there are IO.SYS, MSDOS.SYS, COMMAND.COM, drivers,
> and ther DPMI clients reside on the memory. where can I get the memory
> mapping directory?

I don't understand this question.  What memory mapping do you need?
If you want to know which parts of conventional memory are taken up,
you will have to walk the DOS memory chain.  Since you don't have any
memory manager installed, extended memory should not be a problem for
you (because nobody can use it except CWSDPMI and your program
anyway).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019