*BSD News Article 17616


Return to BSD News archive

Newsgroups: comp.os.386bsd.questions
Path: sserve!newshost.anu.edu.au!munnari.oz.au!network.ucsd.edu!dog.ee.lbl.gov!overload.lbl.gov!agate!howland.reston.ans.net!xlink.net!gmd.de!mururoa!veit
From: veit@mururoa.gmd.de (Holger Veit)
Subject: Re: inb(), /dev/mem and mmap(2)
Message-ID: <1993Jun28.151458.29599@gmd.de>
Sender: veit@mururoa (Holger Veit)
Nntp-Posting-Host: mururoa
Organization: GMD - German National Research Center for Computer Science
References:  <20mnuk$ai4@Germany.EU.net>
Date: Mon, 28 Jun 1993 15:14:58 GMT
Lines: 59

In article <20mnuk$ai4@Germany.EU.net>, bs@Germany.EU.net (Bernard Steiner) writes:
|> 
|> Folks,
|> Could someone out there enlighten me as to why mmap() fails on character
|> special files such as /dev/mem or /dev/zero, but works OK on regular files ?

Probably the mmap handler in the "device" driver is buggy or missing :-)

|> 
|> How does one read a byte from an ISA IOport ? Opening /dev/mem, lseek()ing
|> to 0xa0000+offset and then read()ing a byte does not appear to work.

This is is actually one of the missing *and* buggy features, in particular
mapping the video memory at an offset and then extending this area is
one of the bad implemented parts in all the console drivers and the VM system.

|> 
|> Has anybody implemented the /dev/ioport stuff ?
|> I've seen the stubs in i386/i386/mem.c, but then some macros seem to be
|> missing :-(
|> 
|> Is there any other way of doing an inb() and outb() outside the kernel ?

Yes, although it is not recommended, this is the method: Compile your console
driver with the XSERVER option, then you get a back door by the ioctl
CONSOLE_X_MODE_ON/OFF which switches your application into the CPU privilege
ring 0, so that it can execute inb/outb instructions. Somewhere in the include 
files there are macros for these instructions. The drawback is that 
CONSOLE_X_MODE_ON/OFF switch your keyboard into the strange scancode mode.
Advertisement on: This is not the case with codrv and its similar ioctl
CONSOLE_X_MODE(+argument), but this one has intentionally the restriction
to allow this ioctl to be issued by a suid program only. Advertisement off.

|> 
|> Am I just plain stupid, or may it be the case that some vital documentation is
|> missing ?

The documentation is there, there is a whole directory tree named /usr/src/sys ;-)
Sigh.


|> 
|> Thanks,
|> 	Bernard
|> -- 
|> =====    ____                          =====   EUnet Deutschland GmbH
|> =====   /      /   /   ___    ___  _/_ =====   Emil-Figge-Str. 80
|> =====  /----  /   /  /   /  /___/  /   =====   D-W-4600 Dortmund 50
|> ===== /____  /___/  /   /  /___   /    =====   Germany
|> =======                              =======   Vox +49 231 972 2222
|> ======= Connecting Europe since 1982 =======   Fax +49 231 972 1111

-- 
         Dr. Holger Veit                   | INTERNET: Holger.Veit@gmd.de
|  |   / GMD-SET German National Research  | Phone: (+49) 2241 14 2448
|__|  /  Center for Computer Science       | Fax:   (+49) 2241 14 2342
|  | /   P.O. Box 13 16                    | Had a nightmare yesterday:
|  |/    Schloss Birlinghoven              | My system started up with
         DW-5205 St. Augustin, Germany     | ... Booting vmunix.el ...