*BSD News Article 86518


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!newsfeed.direct.ca!nntp.portal.ca!news.bc.net!info.ucla.edu!nnrp.info.ucla.edu!csulb.edu!hammer.uoregon.edu!news-xfer.netaxs.com!news.mathworks.com!fu-berlin.de!irz401!orion.sax.de!uriah.heep!news
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Accessing i/o-ports from user-code ?
Date: 9 Jan 1997 23:17:43 GMT
Organization: Private BSD site, Dresden
Lines: 33
Message-ID: <5b3uan$ji6@uriah.heep.sax.de>
References: <87g20rbmk6.fsf@acme1.ruhr.de> <32C740D4.2781E494@freebsd.org>
  <nJExans@quack.kfu.com>
Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch)
NNTP-Posting-Host: localhost.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: knews 0.9.6
X-Phone: +49-351-2012 669
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F  93 21 E0 7D F9 12 D6 4E
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:33834

nsayer@quack.kfu.com (Nick Sayer) wrote:

> I hacked the linux color quickcam program so that it would work under
> FreeBSD. An open file discriptor on /dev/io will allow _any_ I/O
> instruction. For added crash protection, might I suggest that some
> ioctls be added to /dev/io so that you can specify a range of I/O ports
> you intend to use? It'd probably keep me from having bad dreams that
> an alpha particle changes 0x378 to 0x1f0 and the quickcam program does a
> tap dance all over my hard disk... :-)

That's life. :-(

The problem is that adding IO port address ranges will add a lot of
cost.  The simple ``port IO allowed'' / ``port IO not allowed''
decision is handled by the ``IOPL'' bits in the flag word.  Simple and
efficient.  If direct IO is not allowed for your process, you'll get a
trap.

However, an IO range check will at least cost to add an IO permission
bitmap to the TSS (task state segment).  Since there's no reason to
use any other arbitrary limit for this bitmap than 64 KB (16 bits of
IO address space), you need to copy another 64 KB of data on each
context switch.  (IIRC, *BSD currently doesn't even use one TSS per
process.)  I remember times when Linus Torvalds stated that the i386
hardware task switching wasn't worth using, but he apparently later
changed his mind.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)