delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/15/16:11:24

Date: Wed, 15 Sep 1999 12:03:38 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Jay Warling <bitheads AT hotmail DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Problem accessing absolute physical address >1MB
In-Reply-To: <19990914233406.21066.qmail@hotmail.com>
Message-ID: <Pine.SUN.3.91.990915120311.27871R-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 14 Sep 1999, Jay Warling wrote:

> I have a need to access absolute physical memory for a project. I am trying
> a solution like the one in the FAQ section 18.7. Unfortunately I am getting
> SIGSEGV when the snippet of my code shown below reaches the _farpokel() 
> call.

Please always make a point of posting the complete crash traceback and
registers' dump when you report problems that cause programs to crash.
The crash message includes some crucial info that makes our guesswork
much easier.  Please run SYMIFY and post the crash message with the
information added by SYMIFY.

> Long term I need to access physical memory that resides between 256MB
> and 512MB. Does anyone have any suggestions on how to do this with DJGPP?
> I know it is a bizarre requirement.:-)

What exactly is ``bizarre'' with this, and what special problems do
you expect?  DJGPP gives you a flat 2GB address space, and the above
numbers are well within it...

> 	/* Make selector look like DS selector */
> 	asm ("
> 		 	movl %%ds, %0"
> 			: "=g" (iDSSelector)
> 		);

You could simply use the library function `_my_ds' here.

> 	iStatus = __dpmi_get_descriptor(iDSSelector, (void *)&bDescBuffer);
> 	iStatus = __dpmi_set_descriptor(iLdtSlot, (void *)&bDescBuffer);

I think this is wrong: you are copying the descriptor of DS into the
descriptor of your selector allocated for accessing the memory
region.  A segment descriptor has several fields that shouldn't be
copied blindly.  For example, DS is a ``large'' segment (meaning it is
larger than 64KB), whereas the selector you aloocated spans only 4KB,
and thus cannot be ``large''.  These problems might invalidate the
segment descriptor, and your program *will* crash.

Why did you need to copy the segment descriptor?  The code in the FAQ
doesn't tell you should do so.

Also, what was the declaration of bDescBuffer in the above snippet?

- Raw text -


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