Date: Tue, 29 Apr 1997 11:39:32 +0300 (IDT) From: Eli Zaretskii To: Gregary J Boyles cc: djgpp AT delorie DOT com Subject: Re: DPMI question In-Reply-To: <5juo4b$6h9@lion.cs.latrobe.edu.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.