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 values
> 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 UNIX...
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 ports
with these pieces of inline-assembly :
unsigned char inp(unsigned short Port)
{
unsigned char Data = 0;
__asm __volatile("inb %%dx,%0" : "=a" (Data) : "d" (Port) );
return Data;
}
void outp(unsigned short Port, unsigned char Data)
{
unsigned char D = Data;
__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 directly :
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>
