Cleanup the lpt for probe code.

PR:		5773
Submitted by:	Dag-Erling Coidan Smorgrav <dag-erli@ifi.uio.no>
This commit is contained in:
Steve Price 1998-02-20 02:44:48 +00:00
parent 34d1c7b48c
commit 8f50e70513

View File

@ -46,7 +46,7 @@
* SUCH DAMAGE.
*
* from: unknown origin, 386BSD 0.1
* $Id: lpt.c,v 1.64 1998/01/08 23:41:10 eivind Exp $
* $Id: lpt.c,v 1.65 1998/01/24 02:54:21 eivind Exp $
*/
/*
@ -104,6 +104,7 @@
#include "lpt.h"
#include "opt_devfs.h"
#include "opt_inet.h"
#include "opt_lpt.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -188,7 +189,7 @@
#define BIOS_MAX_LPT 4
#ifndef DEBUG
#ifndef LPT_DEBUG
#define lprintf (void)
#else
#define lprintf if (lptflag) printf
@ -369,8 +370,14 @@ lptprobe(struct isa_device *dvp)
int port;
static short next_bios_lpt = 0;
int status;
u_char data;
u_char mask;
static u_char testbyte[18] = {
0x55, /* alternating zeros */
0xaa, /* alternating ones */
0xfe, 0xfd, 0xfb, 0xf7,
0xef, 0xdf, 0xbf, 0x7f, /* walking zero */
0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80 /* walking one */
};
int i;
/*
@ -393,27 +400,12 @@ lptprobe(struct isa_device *dvp)
/* 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: