delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/25/16:42:47

Message-Id: <199607252040.QAA28550@delorie.com>
Date: Thu, 25 Jul 96 16:15:01 EDT
From: "Jim Balz" <jbalz AT vnet DOT ibm DOT com>
To: djgpp AT delorie DOT com
Subject: OS/2 Warp DOS box.

I'm trying to use an imbedded controller board under OS/2 Warp.  It
has memory-mapped I/O at 0xFC000 (just below the 16MB ISA bus limit).
The PC has 8MB memory installed.

I can access the card with DJGPP-generated code just fine, if I boot
the PC under DOS.  It doesn't work if I boot under OS/2 and run in
the DOS box.  I suspect there's a problem with the way I'm using the
DPMI.  Here's a code fragment that I wrote using section 18.7 of the
FAQ's as a guide.  Can anyone point me in the right direction?

/* -------------------------------------------------------------- */
/* program to test access to absolute memory locations above 1MB */
#include <stdio.h>
#include <stdlib.h>
#include <go32.h>
#include <dpmi.h>
#include <sys\farptr.h>

main() {

unsigned long i;
__dpmi_meminfo info;
int sel;
extern unsigned short __dpmi_error;

if ( (sel = __dpmi_allocate_ldt_descriptors(1)) == -1)  {
   fprintf(stderr, "\n\n%x __dpmi_allocate_ldt_descriptors\n", __dpmi_error);
   exit(100);
      }

info.address=0xfc0000 + 0x280;
info.size=(unsigned long) 0x4000;
if (__dpmi_physical_address_mapping(&info))  {
   fprintf(stderr, "\n\n%x __dpmi_physical_address_mapping\n", __dpmi_error);
   exit(101);
   }

if (__dpmi_lock_linear_region(&info)) {  /* comment this out for DOS */
   fprintf(stderr, "\n\n%x __dpmi_lock_linear_region\n", __dpmi_error);
   exit(102);
   }

if (__dpmi_set_segment_base_address(sel, info.address))  {
   fprintf(stderr, "\n\n%x __dpmi_set_segment_base_address\n", __dpmi_error);
   exit(103);
   }

if (__dpmi_set_segment_limit(sel, 0x4000))   {
   fprintf(stderr, "\n\n%x __dpmi_set_segment_limit\n", __dpmi_error);
   exit(104);
   }

for (i=0; i<0x80; i++)
   printf("%c", _farpeekb(sel, i));    /* show byte from ID PROM */
printf("\n");
}

- Raw text -


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