Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Apr 2003 13:39:51 +0200
From:      "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
To:        rhett@alasir.com
Cc:        FreeBSD-hackers@FreeBSD.org
Subject:   Re: low-level routines
Message-ID:  <200304201339.51145.Danovitsch@Vitsch.net>
In-Reply-To: <20030420021752.13758.qmail@web21509.mail.yahoo.com>
References:  <20030420021752.13758.qmail@web21509.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304201339.51145.Danovitsch>