delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/04/22:04:57

From: Tim Updegrove <tupdegrove AT lucent DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allocating DOS memory in Windows
Date: Thu, 04 Nov 1999 18:02:15 -0500
Organization: Lucent Technologies
Lines: 53
Message-ID: <38221076.966C6FFD@lucent.com>
References: <38205BE6 DOT B7CF872B AT lucent DOT com>
NNTP-Posting-Host: pai830tupdegrove.micro.lucent.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.61 [en] (Win95; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli (and others),

The problem I faced one month ago was trying to use
__dpmi_physical_address_mapping after allocating DOS memory when the program
was run after booting into MS-DOS.  Someone mentioned DOS memory is already
mapped.  So this part of the problem is fixed.

As I indicated below, just allocating DOS memory (and passing the segment to
the DMA hardware and using the selector in the program) works fine when
booting into MS-DOS.  The DMA hardware fetches the correct info.  However,
running the same exact executable in a MS-DOS box under Windows, the DMA
hardware doesn't fetch the correct info in memory which was first written by
the program.  The DMA hardware fetches the same address in both cases but,
under Windows, the data that the program wrote isn't present (but is present
when booting to MS-DOS).  I did add code to write and read this info (using
_farpeekl and _farpookl) and this works fine in Windows but the DMA hardware
doesn't fetch this data under Windows.  There must be some type of mapping
problem.  That is, the selector returned from allocating DOS memory under
Windows doesn't appear to point to the same data as the returned segment.
Again, the same exact executable was run in both environments.

As indicated below, steps 2-5 work with Windows (but don't work when booting
to MS-DOS because the memory is already mapped) but I would like one
solution to work in both environments.  Help is much appreciated.  Short
examples would be helpful.

Tim Updegrove wrote:

> This is a followup to a question on 10/15/99.  I'm trying to get a
> program which allocates DOS memory for a DMA buffer to work when booting
> to MS-DOS and also work in a MS-DOS box under Windows 98.  I can get
> each to work in a separate program but I'm hoping to find a solution
> that works both places in a single program.  Here are the steps that
> I've found to work.
>
> Booting to MS-DOS:
> 1. Allocate DOS memory and use the returned segment*16 for the physical
> DMA address and use the returned selector with _farpeekl and _farpookl.
>
> In a MS-DOS box with Windows 98:
> 1. Allocate DOS memory and use the returned segment*16 for the physical
> DMA address.
> 2.Pass segment*16 into __dpmi_physical_address_mapping to obtain a
> linear address.
> 3. Create a segment selector with __dpmi_allocate_ldt_descriptors.  The
> returned selector is used with _farpeekl and _farpookl.
> 4. Initialize the segment's base address & size with
> __dpmi_set_segment_base_address using the selector from step 3.
> 5. Initialize the segment's limit with __dpmi_set_segment_limit using
> the selector from step 3.
>
> Any help would be much appreciated.

- Raw text -


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