Newsgroups: comp.os.minix
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!newshost.telstra.net!asstdc.scgt.oz.au!metro!metro!news.cs.su.oz.au!harbinger.cc.monash.edu.au!news.mira.net.au!vic.news.telstra.net!act.news.telstra.net!imci3!imci4!newsfeed.internetmci.com!howland.reston.ans.net!EU.net!sun4nl!cs.vu.nl!kjb
From: kjb@cs.vu.nl (Kees J Bot)
Subject: Re: Mapping addresses from high memory
Nntp-Posting-Host: hornet.cs.vu.nl
References: <4js8p8$co1@central.server.swt.edu>
Sender: news@cs.vu.nl
Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
Date: Wed, 3 Apr 1996 13:16:47 GMT
Message-ID: <DpAFK0.FpD.0.-s@cs.vu.nl>
Lines: 35

rv18973@nyssa.swt.edu (Ranjani Vaidyanathan) writes:

>Hi Everbody,
>	I wanted to find out if there is any function in minix that can 
>map address located in the high end of memory (say 0xfee00000) to kernel
>address space. Basically I need some kind of pointer to the address so 
>that I can read and write to that address.
>Right now I am using a crude method of using phys_copy every time I 
>want to read or write the high memory.

So you want the inverse of the vir2phys() function.  This is easy:

	#define phys2vir(addr)	((vir_bytes) ((addr) - vir2phys(0)))

	char *p;

	p = (char *) phys2vir(0xfee00000);

But alas you cannot use this pointer.  Each Minix process is limited to
its own memory space.  The kernel tasks are no exception.  To get around
this you have to change the line

	init_dataseg(&gdt[DS_INDEX], data_base, data_bytes, INTR_PRIVILEGE);

in kernel/protect.c::prot_init() into

	init_dataseg(&gdt[DS_INDEX], data_base, 0L, INTR_PRIVILEGE);

This will allow the kernel tasks to access the entire 4G address space
of the 386.  By the way, phys_copy() is only a few cycles slower than
memcpy().  :-)
--
long:  http://www.cs.vu.nl/~ast/minix.html         Kees J. Bot  (kjb@cs.vu.nl)
short: http://www.cs.vu.nl/ftp/minix/README.html        Systems Programmer
ftp:   ftp://ftp.cs.vu.nl/pub/minix/		   Vrije Universiteit Amsterdam
