www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/22/22:20:17

From: tdu AT enter DOT net (Tim Updegrove)
Newsgroups: comp.os.msdos.djgpp
Subject: Allocate dos memory
Date: Fri, 23 Apr 1999 01:48:10 GMT
Message-ID: <371fcde7.5102505@news.enter.net>
X-Newsreader: Forte Free Agent 1.11/32.235
NNTP-Posting-Host: 207.18.11.22
X-Original-NNTP-Posting-Host: 207.18.11.22
X-Trace: 22 Apr 1999 21:51:11 -0400, 207.18.11.22
Organization: Enter.Net
Lines: 46
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'm still trying to allocate memory and get a physical address for a
DMA controller.  As a temporary approach to my physical address
problem, I've tried to use __dpmi_allocate_dos_memory.  The below
piece of code works but I have several questions:

1.   How do I get the physical address from the selector and/or
segment that is returned by  __dpmi_allocate_dos_memory?  Is it just
(segment*16)+offset?

2. I assume this area of memory doesn't have to be locked.  Correct?

3. If more than 64k bytes are allocated (like I did), must
__dpmi_get_selector_increment_value or something be called to get a
new selector when crossing a 64k boundary?

------------------------------------------------------------
  int
    i,
    desc_lwds,
    desc_sel, 
    desc_seg; 

  desc_lwds = 32768; 
  desc_seg = __dpmi_allocate_dos_memory(((desc_lwds*4)+15) >> 4,
&desc_sel);

  _farsetsel(desc_sel);
  
  printf("Writing memory area\n");
  for(i=0; i < desc_lwds; i++)
    _farnspokel(i*4, i);
  
  printf("Verifying memory area\n");
  for(i=0; i < desc_lwds; i++) {
    data = _farnspeekl(i*4);
    if (data != i) {
      printf("Error: Expected data=%08lx Actual data=%08lx\n", i,
data);
      exit(1);
    } /* compare */
  } /* for */


Tim Updegrove
tdu AT enter DOT net (remove the "nospam." in the reply address)

- Raw text -


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