From owner-freebsd-hardware Wed Apr 16 07:54:19 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id HAA01159 for hardware-outgoing; Wed, 16 Apr 1997 07:54:19 -0700 (PDT) Received: from hydrogen.nike.efn.org (resnet.uoregon.edu [128.223.170.28]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA01152 for ; Wed, 16 Apr 1997 07:54:15 -0700 (PDT) Received: (from jmg@localhost) by hydrogen.nike.efn.org (8.8.4/8.8.4) id HAA28430; Wed, 16 Apr 1997 07:53:38 -0700 (PDT) Message-ID: <19970416075337.16693@hydrogen.nike.efn.org> Date: Wed, 16 Apr 1997 07:53:37 -0700 From: John-Mark Gurney To: Luiz de Barros Cc: freebsd-hardware@FreeBSD.ORG Subject: Re: talk to I/O Devices. References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.69 In-Reply-To: ; from Luiz de Barros on Wed, Apr 16, 1997 at 10:18:14AM -0300 Reply-To: John-Mark Gurney Organization: Cu Networking X-Operating-System: FreeBSD 2.2-960801-SNAP i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ Sender: owner-hardware@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Luiz de Barros scribbled this message on Apr 16: > Dear FreeBSD Experts, > > I would like to know how i can talk to an input/output device attached to > some I/O ports in C. I want something equivalent to outportb and inportb > from DOS. The board we want to develop is a remote power controller to > reset our computers in case of a crash. The board will be controlled by > I/O ports. this is relativily easy... all you need to do is open the /dev/io file... this will give you access to the io ports... then you use the out[wb] and in[wb] macros/functions in machine/cpufunc.h to perform the operations.. something like this works: #include #include #include #include void main() { int i; if(open("/dev/io", O_RDWR, 0) == -1) err(1, "open of /dev/io failed"); outb(0x3c8, 0); outb(0x3c9, 0); outb(0x3c9, 0); outb(0x3c9, 0); } hope this helps... ttyl... -- John-Mark Cu Networking Modem/FAX: +1 541 683 6954 Live in Peace, destroy Micro$oft, support free software, run FreeBSD