*BSD News Article 25570


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!news.kei.com!sol.ctr.columbia.edu!howland.reston.ans.net!cs.utexas.edu!utah-morgan!hellgate.utah.edu!fcom.cc.utah.edu!u.cc.utah.edu!cs.weber.edu!terry
From: terry@cs.weber.edu (A Wizard of Earth C)
Newsgroups: comp.unix.bsd
Subject: Re: How do I set up a 2 Meg sharable area between device driver and user?
Date: 5 Jan 1994 01:08:12 GMT
Organization: Weber State University, Ogden, UT
Lines: 37
Message-ID: <2gd3ts$fc6@u.cc.utah.edu>
References: <2gc1h1$hns@senator-bedfellow.MIT.EDU>
NNTP-Posting-Host: cs.weber.edu

In article <2gc1h1$hns@senator-bedfellow.MIT.EDU> Glen Schaff <glens@space.mit.edu> writes:
>I am working on a SUN 4.1.1 architecture, and have been trying to set up
>a 2 meg sharable memory region, that a user program can read, and my
>device driver writes. (finding documentation for this is about as easy as
>repairing the Hubble).  I believe this can be done using the mmap() dki
>functions.  I would greatly appreciate information on how to define this
>area, structure the driver routine that passes back the appropriate
>pointers, and access' the area from the user program.

You will need to pin the pages, then you will need to comunicate their
location to the driver. In all honesty, you are better of allocating
*contiguous* wired memory in the driver itself, and then mapping it
into the processes address space via a special ioctl() you put in your
driver for precisely that purpose.

If you are hell-bent on allocating the memory as a real shared memory
region accessable to multiple processes, with standard mapping rules,
you can get a segment, then make a call to the driver to map it and to
look up each of the pages (in case they are not contiguous) and store
2k of the translation addresses in the driver somewhere for when the
driver needs to get to it.

There is an (undocumented) ability to load a system call in 4.1.1, and
there is an example on using it to pin the pages on wuarchive.wustl.edu
in either comp.unix.sources or comp.unix.archives (I forget which).
This would help you on the road to #2.

If you come to your senses and decide on approach #1, the interfaces are
documented in the Sun device driver and kernel interface docs so that
you can do what you want (hint: look at the frame buffer example).


					Terry Lambert
					terry@cs.weber.edu
---
Any opinions in this posting are my own and not those of my present
or previous employers.