Bring in the simplified port probe from src/sys/i386/isa/lpt.c

This commit is contained in:
des 1999-02-08 13:55:43 +00:00
parent ec671918f4
commit e96a20a328

View File

@ -47,7 +47,7 @@
*
* from: unknown origin, 386BSD 0.1
* From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
* $Id: nlpt.c,v 1.12 1999/01/10 12:04:54 nsouch Exp $
* $Id: nlpt.c,v 1.13 1999/01/27 20:09:19 dillon Exp $
*/
/*
@ -221,6 +221,9 @@ nlpt_port_test(struct lpt_data *sc, u_char data, u_char mask)
}
/*
* Probe simplified by replacing multiple loops with a hardcoded
* test pattern - 1999/02/08 des@freebsd.org
*
* New lpt port probe Geoff Rehmet - Rhodes University - 14/2/94
* Based partially on Rod Grimes' printer probe
*
@ -267,38 +270,29 @@ nlpt_port_test(struct lpt_data *sc, u_char data, u_char mask)
static int
nlpt_detect(struct lpt_data *sc)
{
int status;
u_char data;
u_char mask;
int i, error;
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, error, status;
status = 1; /* assume success */
if ((error = lpt_request_ppbus(sc, PPB_DONTWAIT))) {
printf(LPT_NAME ": cannot alloc ppbus (%d)!\n", error);
status = 0 ; goto end_probe ;
status = 0;
goto end_probe;
}
mask = 0xff;
data = 0x55; /* Alternating zeros */
if (!nlpt_port_test(sc, data, mask))
{ status = 0 ; goto end_probe ; }
data = 0xaa; /* Alternating ones */
if (!nlpt_port_test(sc, data, mask))
{ status = 0 ; goto end_probe ; }
for (i = 0; i < 8; i++) { /* Walking zero */
data = ~(1 << i);
if (!nlpt_port_test(sc, data, mask))
{ status = 0 ; goto end_probe ; }
}
for (i = 0; i < 8; i++) { /* Walking one */
data = (1 << i);
if (!nlpt_port_test(sc, data, mask))
{ status = 0 ; goto end_probe ; }
}
for (i = 0; i < 18 && status; i++)
if (!nlpt_port_test(sc, testbyte[i], 0xff)) {
status = 0;
goto end_probe;
}
end_probe:
/* write 0's to control and data ports */