delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/29/05:00:55

Date: Tue, 29 Apr 1997 11:39:32 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Gregary J Boyles <boylesgj AT lion DOT cs DOT latrobe DOT edu DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: DPMI question
In-Reply-To: <5juo4b$6h9@lion.cs.latrobe.edu.au>
Message-ID: <Pine.SUN.3.91.970429113908.23034F-100000@is>
MIME-Version: 1.0

On 27 Apr 1997, Gregary J Boyles wrote:

> What is the difference between __dpmi_lock_linear_region(...) and
> _go32_dpmi_lock_code(...)/_go32_dpmi_lock_data(...)?

The `__dpmi' call needs a linear address of the region, whereas the
`_go32' functions get a simple C pointer and compute the linear
address by themselves.

> I am writing a key board handler in C++ so is there any
> reason why I can't just stick dummy functions at the very top and very
> bottom of my source and lock everything (code and data) in one go with
> __dpmi_lock_linear_region(...)?

There are several problems with that approach:

	1) Data and code from C/C++ programs go into different
sections in memory.  Dummy functions can be only used to lock code
(but see below).

	2) There is static data and automatic data (which goes to the
stack), and you need to lock both kinds.

	3) Dummy functions will work for locking code, but you need to
be aware that this technique is an ad-hoc hack, and could be broken by
a future release of gcc.

> Does this mean that, for the address of my dummy function which marks the
> start of my lock region, I should set the address data member to the
> address of my dummy function + __djgpp_base_address?

No, you need to get the base address of the code segment.  You can use
the DPMI function `__dpmi_get_segment_base_address' on the code
selector (given by `_my_cs').  But using the `_go32' variety is much
easier and is the recommended way of locking C code and data.  Note
however that the `_go32' functions only solve the first of the above
problems; they do nothing about the rest.  In particular, your
automatic variables are not locked.

- Raw text -


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