delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/15/22:29:34

From: tdu AT enter DOT net (Tim Updegrove)
Newsgroups: comp.os.msdos.djgpp
Subject: Physical to Linear fails in MS-DOS
Date: Sat, 16 Oct 1999 01:57:32 GMT
Message-ID: <3807d8ac.134142@news.enter.net>
X-Newsreader: Forte Free Agent 1.11/32.235
NNTP-Posting-Host: 207.16.152.26
X-Original-NNTP-Posting-Host: 207.16.152.26
X-Trace: 15 Oct 1999 22:01:22 -0400, 207.16.152.26
Organization: Enter.Net
Lines: 45
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've been very pleased with DJGPP and the support in this group.  Here
is my current problem.  The following sample program runs fine in a
MS-DOS box in Windows95/98 but the call to
__dpmi_physical_address_mapping fails under MS-DOS using cwsdpmi.exe.
I have written other programs which use this same function under
MS-DOS okay.  The difference is that, in the failing case, DOS memory
has been allocated and in the working case (code not shown) a physical
address is used in the mem_info structure.  Is this a DPMI problem
with cwsdpmi or something I'm doing wrong?  Help in allocating DOS
memory in MS-DOS is appreciated.
=======================================
#include <stdio.h>
#include <sys/farptr.h>
#include <string.h>
#include <go32.h>
#include <dos.h>
#include <dpmi.h>

int main() {

  int
  desc,
    segment;

  unsigned short
    selector;

  unsigned long linearaddr;
    __dpmi_meminfo meminfo;

  segment = __dpmi_allocate_dos_memory((16384+15)>>4, &desc);
  if (segment == -1) {
    printf("Couldn't allocate Dos memory.\n");
    exit(1);
  } /* allocate error */
	
  meminfo.size = 16384;
  meminfo.address = segment*16;
  if(__dpmi_physical_address_mapping(&meminfo) == -1) {
    printf("Could not convert phys addr into linear addr\n");
    exit(1);
  }
  printf("it works\n");
} /* main */

- Raw text -


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