delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/11/19/00:46:22

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Obtaining the physical address of a pointer using PMODE
Date: Fri, 18 Nov 2005 23:14:27 CST
Organization: Rice University, Houston, TX
Lines: 56
Message-ID: <437eb4b3.sandmann@clio.rice.edu>
References: <71078E41DDE3E541B024832F34BC3D0DA3081D AT cowexc03 DOT corp DOT mxtr DOT net> <dlfunv$2ta4$1 AT ulysses DOT news DOT tiscali DOT de>
NNTP-Posting-Host: clio.rice.edu
X-Trace: joe.rice.edu 1132378101 25840 128.42.105.3 (19 Nov 2005 05:28:21 GMT)
X-Complaints-To: abuse AT rice DOT edu
NNTP-Posting-Date: Sat, 19 Nov 2005 05:28:21 +0000 (UTC)
X-NewsEditor: ED-1.5.9
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> However if I use pmode/dj, isn't there a way to malloc a chunk of memory
> and somehow detect the physical address of this chunk?

Use malloc(), use the excellent instructions from Rod's note from 16-Nov-2005
to compute the physical address, and apply the appropriate alignments.  In
particular, quoting Rod...

All the virtual address in DJGPP are offset from some base address.  For any
virtual address in DJGPP, you can use three methods:
1) add __djgpp_base_address  (which is an int) 
(rest of informative message snipped)

> DOS with himem.sys installed and WITHOUT EMM386 is the only environment I am 
> really interested in.

That's good, because EMM386/VCPI active even pmode needs paging enabled.

> > Charles Sandmann gave us some example code, and put it at
> > ftp://clio.rice.edu/djgpp/cwsdma.zip.  He was talking about cleaning
> > it up and making it more publicized; I don't know if that ever happened.

I never made significant cleanup; but there is a cwsdma2 there.  I don't
remember how it was different anymore.

> I had a look at this code and I'm not sure I understand it completely.
> In the test routine there's:
> ....
>   dmabuf = AllocateDMABuffer(8*1024*1024);
>   if(dmabuf)
>     printf("Allocated 8M DMA buffer at DJGPP address 0x%x, physical 0x%x\n",
>       dmabuf,Physical_Address(dmabuf));
> ....
> 
> and it appears to me if that's really all that is needed to allocate a chunk 
> of memory and obtain the physical address for DMA.

Under a paging system with virtual memory, the allocated memory may be paged
out to disk, or scattered about in physical memory (not contiguous), or
potentially not even mapped yet.  So your simple assumption works for 
something like PMODE without EMM386, but not in general.

>   i = physical_map(0, __djgpp_selector_limit, MAXSIZE, virtual, physical, size);
>   if(i == 2)
>     return printf("CWSDPMI PD in UMB not supported, sorry\n");
>   if(i)
> 
> and I have no idea what that is good for i.e. what I need the physical_map 
> function for.

For any CWSDPMI environment (including emm386, swapped out, etc) this will tell
exactly where the memory is.  If you know how to program the DMA scatter/gather
maps you can use the physical map info to use the fragmented buffer.

So, if you distribute software and don't have complete control of the 
boot environment, this is a useful technique.

- Raw text -


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