low-level routines
Daan Vreeken [PA4DAN]
Danovitsch at Vitsch.net
Sun Apr 20 04:38:07 PDT 2003
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
More information about the freebsd-hackers
mailing list