Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Feb 1998 22:32:44 GMT
From:      Dag-Erling Coidan Smørgrav <finrod@ppp097.uio.no>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   i386/5773: Cleanup of /usr/src/sys/i386/isa/lpt.c
Message-ID:  <199802172232.WAA00901@ppp097.uio.no>

next in thread | raw e-mail | index | archive | help

>Number:         5773
>Category:       i386
>Synopsis:       Cleanup of /usr/src/sys/i386/isa/lpt.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 17 14:40:04 PST 1998
>Last-Modified:
>Originator:     Dag-Erling Coidan Smørgrav
>Organization:
University of Oslo, Department of Informatics
>Release:        FreeBSD 2.2.5-STABLE i386
>Environment:

2.2.5-STABLE, cvsupped today.

>Description:

Cleanup of parallell port probe (specifically, testing of manually
configured port adresses), and debug option changed from DEBUG to
LPT_DEBUG. Shortens source code by a few lines and compiled code by
about a hundred bytes. No change in functionality.

Specifically, the old probing code used a sequence of for loops to
generate test bytes. I replaced these with a single loop which tests
the data register with bytes from a compiled-in table.

>How-To-Repeat:

N/A

>Fix:
	
--- /usr/src/sys/i386/conf/options.i386.orig	Tue Feb 17 23:23:16 1998
+++ /usr/src/sys/i386/conf/options.i386		Tue Feb 17 23:22:20 1998
@@ -96,3 +96,5 @@
 PCVT_SCREENSAVER	opt_pcvt.h
 PCVT_USEKBDSEC		opt_pcvt.h
 PCVT_VT220KEYB		opt_pcvt.h
+
+LPT_DEBUG		opt_lpt.h
--- /usr/src/sys/i386/isa/lpt.c.orig	Tue Nov 12 10:08:38 1996
+++ /usr/src/sys/i386/isa/lpt.c		Tue Feb 17 23:19:48 1998
@@ -101,6 +101,7 @@
  * Poul-Henning Kamp <phk@freebsd.org>
  */
 
+#include "opt_lpt.h"
 #include "lpt.h"
 
 #include <sys/param.h>
@@ -190,7 +191,7 @@
 #define	BIOS_MAX_LPT	4
 
 
-#ifndef DEBUG
+#ifndef LPT_DEBUG
 #define lprintf (void)
 #else
 #define lprintf		if (lptflag) printf
@@ -301,6 +302,18 @@
 
 
 /*
+ * Sequence of bytes to use for testing ports
+ */
+static u_char testbyte[18] = {
+	0x55,					/* Alternating zeros */
+	0xaa,					/* Alternating ones */
+	0xfe, 0xfd, 0xfb, 0xf7,
+	0xef, 0xdf, 0xbf, 0x7f,			/* Walking zeros */
+	0x01, 0x02, 0x04, 0x08,
+	0x10, 0x20, 0x40, 0x80,			/* Walking ones */
+};
+
+/*
  * Internal routine to lptprobe to do port tests of one byte value
  */
 static int
@@ -368,12 +381,8 @@
 int
 lptprobe(struct isa_device *dvp)
 {
-	int		port;
+    int	port, status, i;
 	static short	next_bios_lpt = 0;
-	int		status;
-	u_char		data;
-	u_char		mask;
-	int		i;
 
 	/*
 	 * Make sure there is some way for lptopen to see that
@@ -395,28 +404,13 @@
 
 	/* Port was explicitly specified */
 	/* This allows probing of ports unknown to the BIOS */
-
 	port = dvp->id_iobase + lpt_data;
-	mask = 0xff;
-	data = 0x55;				/* Alternating zeros */
-	if (!lpt_port_test(port, data, mask))
-		{ status = 0 ; goto end_probe ; }
-
-	data = 0xaa;				/* Alternating ones */
-	if (!lpt_port_test(port, data, mask))
-		{ status = 0 ; goto end_probe ; }
-
-	for (i = 0; i < 8; i++)	{		/* Walking zero */
-		data = ~(1 << i);
-		if (!lpt_port_test(port, data, mask))
-			{ status = 0 ; goto end_probe ; }
-	}
-
-	for (i = 0; i < 8; i++)	{		/* Walking one */
-		data = (1 << i);
-		if (!lpt_port_test(port, data, mask))
-			{ status = 0 ; goto end_probe ; }
-	}
+	for (i = 0; i < 18; i++)
+		if (!lpt_port_test(port, testbyte[i], 0xff))
+		{
+			status = 0;
+			goto end_probe;
+		}
 
 end_probe:
 	/* write 0's to control and data ports */

>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



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