From owner-freebsd-hackers@FreeBSD.ORG Sun Apr 20 04:38:07 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BE89537B404 for ; Sun, 20 Apr 2003 04:38:05 -0700 (PDT) Received: from Danovitsch.dnsq.org (b74143.upc-b.chello.nl [212.83.74.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id C6B7743FB1 for ; Sun, 20 Apr 2003 04:38:03 -0700 (PDT) (envelope-from Danovitsch@Vitsch.net) Received: from FreeBSD.Danovitsch.LAN (b83007.upc-b.chello.nl [212.83.83.7]) by Danovitsch.dnsq.org (8.12.3p2/8.11.3) with ESMTP id h3KBX8Ca013186; Sun, 20 Apr 2003 13:33:09 +0200 (CEST) (envelope-from Danovitsch@Vitsch.net) Content-Type: text/plain; charset="iso-8859-1" From: "Daan Vreeken [PA4DAN]" To: rhett@alasir.com Date: Sun, 20 Apr 2003 13:39:51 +0200 User-Agent: KMail/1.4.3 References: <20030420021752.13758.qmail@web21509.mail.yahoo.com> In-Reply-To: <20030420021752.13758.qmail@web21509.mail.yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304201339.51145.Danovitsch@Vitsch.net> cc: FreeBSD-hackers@FreeBSD.org Subject: Re: low-level routines X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Apr 2003 11:38:07 -0000 On Sunday 20 April 2003 04:17, RMH wrote: > Hello gentlemen, > > could you point me to some function(s) used by FreeBSD to read\write va= lues > from\to hardware ports? I remember outp\inp (or outportb\inportb for > Borland Turbo C) from DOS times, but these of course don't work for UNI= X... To read/write io ports directly on FreeBSD, you need to open /dev/io After your process has successfully opened /dev/io you can read/write por= ts=20 with these pieces of inline-assembly : unsigned char inp(unsigned short Port) { unsigned char Data =3D 0; =20 __asm __volatile("inb %%dx,%0" : "=3Da" (Data) : "d" (Port) ); =20 return Data; } void outp(unsigned short Port, unsigned char Data) { unsigned char D =3D Data; =20 __asm __volatile("outb %0,%%dx" : : "a" (D), "d" (Port) ); } Here's a link to some code that I use to write to the parallel port direc= tly : http://danovitsch.dnsq.org/cgi-bin/gpl/cat.cgi/lampd/v1.0?lampd.c grtz, Daan