From owner-freebsd-questions@FreeBSD.ORG Thu Apr 3 23:44:03 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1178E37B401 for ; Thu, 3 Apr 2003 23:44:03 -0800 (PST) Received: from Danovitsch.dnsq.org (b74143.upc-b.chello.nl [212.83.74.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4119F43FAF for ; Thu, 3 Apr 2003 23:44:01 -0800 (PST) (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 h347dFCR016084; Fri, 4 Apr 2003 09:39:16 +0200 (CEST) (envelope-from Danovitsch@Vitsch.net) Content-Type: text/plain; charset="iso-8859-1" From: "Daan Vreeken [PA4DAN]" To: Dtseven@gmx.at Date: Fri, 4 Apr 2003 09:45:06 +0200 User-Agent: KMail/1.4.3 References: <200304040931.34722."Dtseven@gmx.at"> In-Reply-To: <200304040931.34722."Dtseven@gmx.at"> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304040945.06653.Danovitsch@Vitsch.net> cc: FreeBSD-questions@FreeBSD.org Subject: Re: LPT1 Port in ASM or C X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Apr 2003 07:44:03 -0000 On Friday 04 April 2003 09:31, Dtseven@gmx.at wrote: > Hi all! > I want to know how I can control the lpt1 port in asm or C. > I'm a newbie. > Any help would be greatly appreciated. There are two ways to do that. 1. Directly poke around with the ports 2. open /dev/lpt0 and communicate with that I have never looked at the second way, but I can tell you how to do it th= e=20 first way :) In FreeBSD to have direct port-access you application needs to open /dev/= io Once it has done that, it can directly write to any port it wants. Opening /dev/io should look something like : FILE *IO; IO =3D fopen("/dev/io","rw"); And then you can write/read ports with this little piece of assembly : void outp(unsigned short Port, unsigned char Data) { unsigned char D =3D Data; =20 __asm __volatile("outb %0,%%dx" : : "a" (D), "d" (Port) ); } unsigned char inp(unsigned short Port) { unsigned char Data =3D 0; =20 __asm __volatile("inb %%dx,%0" : "=3Da" (Data) : "d" (Port) ); return Data; } With the following command you should create a nice 1-0-1-0 bit pattern o= n the=20 parallel port : outp(0x378,0xaa); I have some example code (that does much more than controlling the port) = here: http://danovitsch.dnsq.org/cgi-bin/gpl/cat.cgi/lampd/v1.0?lampd.c grtz & good luck, Daan