delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/14/21:30:27

Message-ID: <19990914233406.21066.qmail@hotmail.com>
X-Originating-IP: [134.134.248.23]
From: "Jay Warling" <bitheads AT hotmail DOT com>
To: djgpp AT delorie DOT com
Subject: Problem accessing absolute physical address >1MB
Date: Tue, 14 Sep 1999 23:34:06 GMT
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

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.
I used the zip picker on the DJGPP web site to get the current installation.

Can anyone give me any suggestions what might be wrong with my code?

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.:-)

Thanks in advance,
Jay

PS: I am impressed with the DJGPP port with what I have seen so far.:-)

.
.
.
#include <dpmi.h>
#include <sys\farptr.h>
.
.
#define XFER_LIMIT_ADDR 4096
#define XFER_BASE_ADDR 50000000
.
.
  	int iLdtSlot = 0;
	int iDSSelector = 0;
  	int iStatus = -1;
	unsigned long pBlock = XFER_BASE_ADDR;
	unsigned long ulWriteValue = 0x0F0F0F0F;
	unsigned long ulReadValue;
    __dpmi_meminfo rgMemInfo;
.
.

	iLdtSlot =  __dpmi_allocate_ldt_descriptors(1);

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

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

	/* Map the physical device address to linear memory.  */
	rgMemInfo.address = XFER_BASE_ADDR;
	rgMemInfo.size = XFER_LIMIT_ADDR;
	__dpmi_physical_address_mapping (&rgMemInfo);
	/* Now set the selector to use the linear memory range */
  	if (__dpmi_set_segment_base_address (iLdtSlot, rgMemInfo.address))
	{ ... }
	if (__dpmi_set_segment_limit (iLdtSlot, rgMemInfo.size - 1))
	{... }

	/* Make pBlock point to the correct linear address.... */
	pBlock = rgMemInfo.address;

	_farpokel((unsigned short)iLdtSlot, pBlock, ulWriteValue);
	ulReadValue = _farpeekl((unsigned short)iLdtSlot, pBlock);}
.
.

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

- Raw text -


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