delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/05/03:40:49

Message-ID: <19991005060345.20262.rocketmail@web1405.mail.yahoo.com>
Date: Mon, 4 Oct 1999 23:03:45 -0700 (PDT)
From: Prashant TR <prashant_news AT yahoo DOT com>
Subject: Re: Finding physical memory size
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Cc: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

--- Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
> >  I mapped the entire extended memory (my RAM size
> -
> > 1M) to some variable "x". I'm using nearptr. But I
> get
> > a SIGSEGV when I try to access the address
> > x[__djgpp_base_address].
> 
> Please post a short complete test program that shows
> how do you do this.  
> It is possible that you didn't do everything to
> allow access to all 
> memory.
> 


Hi Eli,

  This is the code I have problems with.

#include <stdio.h>
#include <stdlib.h>
#include <dpmi.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/nearptr.h>
#include <sys/farptr.h>

int main()
{
 char *base;

 // Prints "Nearptr enabled".
 printf("Nearptr %s\n", (__djgpp_nearptr_enable()) ?
"Enabled" : "Disabled");

 base = (char *)(__djgpp_conventional_base);

 // Map extended memory to &base[0x100000].
 printf("Physical mapping %s\n",
        (!__djgpp_map_physical_memory(&base[0x100000],
         0x3f00000, 0x100000)) ?
         "OK" : "failed");

 // I have 64MB RAM. Prints "Physical mapping OK".

 // Even this doesn't help.
// mprotect(&base[__djgpp_base_address], 0x100000,
PROT_NONE);

 base[0x2000000] = base[0x2000000];  // This works.
(32MB)

 // Debugging this with FSDB shows that reading the
memory causes the exception.
 base[__djgpp_base_address] =
base[__djgpp_base_address]; // Causes SIGSEGV.

 return 0;
}

> > I know it's in use by the
> > program code, but is there a work around to this ?
> 
> Work-around for what?  If you did everything
> correctly, you should be 
> able to access the program's code without a SIGSEGV.
> 
I mentioned this because in the previous mail you told
me that you can access all physical memory _except_
the portion in use by the code and the DPMI host.

This seems true. I'm having trouble here.

Thanks,
Prashant TR

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

- Raw text -


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