www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/13/11:53:03

Date: Mon, 13 Jan 1997 11:08:53 -0500 (EST)
From: Peter Berdeklis <peter AT chinook DOT physics DOT utoronto DOT ca>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
cc: djgpp AT delorie DOT com
Subject: Re: Help! __dpmi_lock_linear_region wont!
In-Reply-To: <Pine.SUN.3.91.970112151639.7675S-100000@is>
Message-ID: <Pine.SGI.3.91.970113103619.26934B-100000@chinook.physics.utoronto.ca>
MIME-Version: 1.0

On Sun, 12 Jan 1997, Eli Zaretskii wrote:

> 
> On Thu, 9 Jan 1997, Peter Berdeklis wrote:
> 
> > I'm trying to lock some DOS memory for a real mode interrupt handler and a 
> > bunch of DMA buffers, but every call to __dpmi_lock_linear_region returns 
> > a -1.  Why?
> 
> AFAIK, DOS memory is always locked anyway.  So why do you want to lock 
> it?

I want to lock it because it is being used by a hardware ISR.

Note that I can not find anything in the DPMI spec that says that DOS
memory must be locked.  In fact the function "Mark Real Mode Region as
Pagable" says, "Under some  implementations  of  DPMI,  all  memory  in
virtual 8086 mode is locked by default."  This suggests that under some 
implementations it isn't.

> 
> > vector_mem.handle = 0;	// should be don't care for this call, right?
> > vector_mem.size = handler_size;
> > vector_mem.address = real_mode_int_segment << 4;  // dos memory always in
> > 						// paragraphs so offset=0,
> > 						// right?
> > 
> > if( __dpmi_lock_linear_region( &vector_mem ) == -1 )
> > 	exit(-1);	// region not locked, exit
> > }
> 
> `real_mode_int_segment' isn't a valid protected-mode address (else you 
> could just dereference it as a pointer, instead of the farptr, dosmemget 
> and such, right?), that's why the call fails (I think).
> 

I know that the segment is not a PMode selector.  The function 
__dpmi_lock_linear_region requires the _linear_ address of the memory to 
be locked.

Also from the DPMI spec, 

"Page locks are maintained as a count.  When the count is decremented to
zero, the page is unlocked and can be swapped to disk.  This means that if
a region of memory is locked three times then it must be unlocked three
times before the pages will be unlocked."

so a call to lock linear memory should simply increase the lock count, 
not fail.  This is not the case for the "Mark Real Mode Region as 
Pagable" call, which uses a binary state flag, but that's not the 
function I'm calling.

---------------
Peter Berdeklis
Dept. of Physics, Univ. of Toronto

- Raw text -


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