delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/15/05:52:13

Message-Id: <3.0.1.32.19971015105112.005a71c8@mailhost.sm.ic.ac.uk>
Date: Wed, 15 Oct 1997 10:51:12 +0100
To: djgpp AT delorie DOT com
From: Paul Dixon <p DOT dixon AT ic DOT ac DOT uk>
Subject: Re: Physical address from array ? Not a clue!
Mime-Version: 1.0

>I'm really having trouble getting my head around this. given an array, 
>lets say "fred[70000]" how do you get the PHYSICAL address into an int so 
>you can pass that to, say, a dma chip which is ready to accept a 32-bit 
>address.

As a general rule you need to ensure that memory to be used by a DMA controller is within some controlled area of physical memory - for 8 bit DMA, it must be within the first 1MB and must not straddle a 64k boundary, for 16 bit it must lie within first 16MB and not straddle a 128k boundary, I dont know how these change with PCI [all my DMA experience is with ISA cards]. The memory also (obviously) has to be locked to ensure the physical address remains valid.

Therefore you cannot use an arbitrary chunk of memory from anywhere in your programmes memory map : I always do this using the DPMI function __dpmi_allocate_dos_memory() (which allocates locked memory within the first 1MB) but for 16 bit DMA you may wish to use __dpmi_allocate_linear_memory() / __dpmi_lock_linear_region() to obtain a chunk of suitably aligned memory outside the DOS area. You can then either use the dosmemget()/dosmemput(), movedata() functions or near pointer techniques to access the area from C code as appropriate.

For more info try 'info libc f dpmi' and read the FAQ for references to near pointer techniques.
--------------------------------------------------------------------
Paul Dixon                                   Email: p DOT dixon AT ic DOT ac DOT uk
Software Engineer                          tel:   +44 (171) 725 1098
Academic Dept of Paediatrics               fax:   +44 (171) 725 6284
St Mary's Hospital Medical School
 (a constituent college of 
                  Imperial College of Science, Technology & Medicine)
Norfolk Place, London W2 1PG, UK
---------------------------------------------------------------------

- Raw text -


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