www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/11/09:41:29

Date: Fri, 11 May 2001 16:40:37 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: "Tims News" <ttodd_nospam AT cct DOT co DOT uk>
Message-Id: <3995-Fri11May2001164036+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <989577210.22969.0.nnrp-02.c30b1810@news.demon.co.uk>
(ttodd_nospam AT cct DOT co DOT uk)
Subject: Re: DMA, Pointers and Physical Memory
References: <989577210 DOT 22969 DOT 0 DOT nnrp-02 DOT c30b1810 AT news DOT demon DOT co DOT uk>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Tims News" <ttodd_nospam AT cct DOT co DOT uk>
> Newsgroups: comp.os.msdos.djgpp
> Date: Fri, 11 May 2001 11:42:10 +0100
> 
> I am currently working on MultiBus II Message Passing and have hit a small
> problem with the DMA transfer.
> 
> I need to convert a standard pointer (eg. struct mystruct* pInstance) to a
> PHYSICAL memory address.  This is not the address of the data to be
> transferred (that seems well documented in the FAQ - although I haven't
> tried the code yet), this is for the DMA command block.

Sorry, I don't understand: the DMA command block should include the
physical address of where the data should be moved.  Section 18.13 of
the FAQ describes several alternatives to find a physical address of a
memory buffer suitable for DMA.  What exactly are you missing in that
description?

> Also, PLEASE PLEASE PLEASE, if you send me a "read faq entry n"
> could you please also include the link for the FAQ to which you refer - as
> far as I can make out there are a number of (all sleightly) different ones
> around

The latest on-line version of the FAQ is here:

  http://www.delorie.com/djgpp/v2faq/faq.html

You can download the latest version (to read it locally) from here:

  ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/faq230b.zip

> // Convert pointer to physical memory location
>   Selector = *((UINT16*)(((UINT8*)(&pCmd))+4));
>   __dpmi_get_segment_base_address((UINT32)Selector, &Physical);
>   Physical += *((UINT32*)(&pCmd));

This is wrong: you compute the logical address, not a physical
address.  The base address of your program's data is not a physical
address, because it is _before_ the memory-mapping unit built into the
CPU translates it into a physical address.

In addition, you method of computing the selector is bogus: the
selector is not encoded within the address, as in real mode.  To get
the selector for your data, simply call the library function _my_ds().

Anyway, you _must_ use one of the methods described by the FAQ section
18.13 to get a physical address.

- Raw text -


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