*BSD News Article 17675


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!osuunx.ucc.okstate.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!howland.reston.ans.net!noc.near.net!uunet!mcsun!sun4nl!tuegate.tue.nl!svin09.info.win.tue.nl!wzv.win.tue.nl!gvr.win.tue.nl!guido
From: guido@gvr.win.tue.nl (Guido van Rooij)
Newsgroups: comp.os.386bsd.questions
Subject: Re: inb(), /dev/mem and mmap(2)
Date: 29 Jun 1993 12:35:02 GMT
Organization: Eindhoven University of Technology, The Netherlands
Lines: 77
Message-ID: <20pctm$ac4@wzv.win.tue.nl>
References: <20mnuk$ai4@Germany.EU.net} <1993Jun28.151458.29599@gmd.de>
NNTP-Posting-Host: gvr.win.tue.nl

veit@mururoa.gmd.de (Holger Veit) writes:

}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 :-)

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.

Some time ago I made a different, and to me, more clean way to do it.
WHen you can open a certain device (say /dev/mem or /dev/io, choose what
you want), then you can do all io you want. Still not nice but better
and much quicker then lseeking *per byte*.
It is incorporated in NetBSD. And i dont know yet abt the 0.2.4 patchkit.
If someone is interested let him/her email me. 

}|> 
}|> 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 ...

-Guido
-- 
Guido van Rooij                 |  Internet: guido@gvr.win.tue.nl
Bisschopsmolen 16               |  Phone:    ++31.40.461433
5612 DS Eindhoven               |  ((12+144+20)+3*sqrt(4))/7 
The Netherlands                 |    +(5*11)=9^2+0