From owner-freebsd-questions Mon Apr 22 00:29:02 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id AAA16955 for questions-outgoing; Mon, 22 Apr 1996 00:29:02 -0700 (PDT) Received: from mail.rwth-aachen.de (mail.RWTH-Aachen.DE [137.226.144.9]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id AAA16940 for ; Mon, 22 Apr 1996 00:28:57 -0700 (PDT) Received: from gilberto.physik.rwth-aachen.de (gilberto.physik.rwth-aachen.de) by mail.rwth-aachen.de (PMDF V5.0-4 #13110) id <01I3U55SH07K001URQ@mail.rwth-aachen.de>; Mon, 22 Apr 1996 09:15:26 +0100 Received: (from kuku@localhost) by gilberto.physik.rwth-aachen.de (8.6.11/8.6.9) id JAA24177; Mon, 22 Apr 1996 09:21:17 +0200 Date: Mon, 22 Apr 1996 09:21:17 +0200 (MET DST) From: "Christoph P. Kukulies" Subject: Re: How can I read/write from/to an I/O-port? In-reply-to: <199604191211.MAA03635@CoDe.CoDe.hu> To: zgabor@CoDe.hu (Gabor Zahemszky) Cc: kuku@gilberto.physik.rwth-aachen.de, freebsd-questions@freebsd.org Reply-to: Christoph Kukulies Message-id: <199604220721.JAA24177@gilberto.physik.rwth-aachen.de> MIME-version: 1.0 X-Mailer: ELM [version 2.4 PL25 ME8b] Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > > > > > > > > Hi, > > > > > > I have a little problem. So I hope someone can help > > > me: > > > > > > Under Linux a /dev/port exits to write/read to/from an I/O-port. > > > Does a similar /dev/??? exits under FreeBSD or must I write > > > a little device driver for this? > > > > Under FreeBSD there is /dev/io. > > > > Do an open("/dev/io",flags,mode) on it and you can access i/o > > ports using in/out instructions. > > OK. How? What does flags mean? How can I use the fd, I get from open? > (A little example please....) /usr/include/fcntl.h: #define O_RDONLY 0x0000 /* open for reading only */ #define O_WRONLY 0x0001 /* open for writing only */ #define O_RDWR 0x0002 /* open for reading and writing */ #define O_ACCMODE 0x0003 /* mask for above modes */ If you want to read & write to a specific port, use O_RDWR. Once you have opened the io space (device), you can read/write (be cautious!) to any location in the io space. That can be done by in/out (inline assembler - gcc) or by functions, doing that. Look at the driver code in /sys/i386/isa. It's full of example code. > > -- > Gabor Zahemszky > > -:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:- > Earth is the cradle of human sense, but you can't stay in the cradle forever. > Tsiolkovsky > --Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de