delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/16/04:22:55

Date: Mon, 16 Jun 1997 11:22:19 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: hung vo <hungvo AT earthlink DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: Help on Accessing Physical Memory
In-Reply-To: <33A06D41.66EB@earthlink.net>
Message-ID: <Pine.SUN.3.91.970616112157.17543J-100000@is>
MIME-Version: 1.0

On Thu, 12 Jun 1997, hung vo wrote:

> The sequence that I call is:
> __dpmi_allocate_ldt_descriptors(1);	/* to allocate a descriptor */
> __dpmi_physical_address_mapping (_info) /* to map physical to linear */
> __dpmi_lock_linear_region (_info)	/* to lock the linear */

Actually, you don't need to lock the region, it's always locked by
default when you map it in this way.  This is an error in the FAQ (to
be corrected in the next release).

> After allocated, and set the address and limit for the  selector as
> above, I set my pointer points to the selector, and trying to access
> (write to) the memory.
> 
> When I run my program under a Dos box from Win95, I always get the
> message "Can't map physical to linear address". So obviously, it failed
> on "__dpmi_physical_address_mapping (_info)"

Please throw together the shortest program that shows this problem and
post it.  It would be also nice if you could try running it on plain
DOS (no Windows) and see if it behaves differently.  (You might need
to install CWSDPMI for this.)

> Also my other question is once I got the selector, how do I use it to
> access to the Physical location? Presently I do this:
>       DWORD *my_ptr = (DWORD*) selector; 
> Is this correct ?

No, that's not how you need to do it.  Use the `farptr' functions to
access that memory, like so:

	unsigned char *byte = _farpeekb (selector, offset);

More info about this is in the FAQ, section 18.4; `farptr' functions
are documented in the library reference (type "info libc alpha _far"
from the DOS prompt).

- Raw text -


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