Bring in the simplified port probe from src/sys/i386/isa/lpt.c
This commit is contained in:
parent
08d8a5b841
commit
9539cd4d92
@ -47,7 +47,7 @@
|
|||||||
*
|
*
|
||||||
* from: unknown origin, 386BSD 0.1
|
* from: unknown origin, 386BSD 0.1
|
||||||
* From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
|
* 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
|
* New lpt port probe Geoff Rehmet - Rhodes University - 14/2/94
|
||||||
* Based partially on Rod Grimes' printer probe
|
* 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
|
static int
|
||||||
nlpt_detect(struct lpt_data *sc)
|
nlpt_detect(struct lpt_data *sc)
|
||||||
{
|
{
|
||||||
int status;
|
static u_char testbyte[18] = {
|
||||||
u_char data;
|
0x55, /* alternating zeros */
|
||||||
u_char mask;
|
0xaa, /* alternating ones */
|
||||||
int i, error;
|
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 */
|
status = 1; /* assume success */
|
||||||
|
|
||||||
if ((error = lpt_request_ppbus(sc, PPB_DONTWAIT))) {
|
if ((error = lpt_request_ppbus(sc, PPB_DONTWAIT))) {
|
||||||
printf(LPT_NAME ": cannot alloc ppbus (%d)!\n", error);
|
printf(LPT_NAME ": cannot alloc ppbus (%d)!\n", error);
|
||||||
status = 0 ; goto end_probe ;
|
status = 0;
|
||||||
|
goto end_probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = 0xff;
|
for (i = 0; i < 18 && status; i++)
|
||||||
data = 0x55; /* Alternating zeros */
|
if (!nlpt_port_test(sc, testbyte[i], 0xff)) {
|
||||||
if (!nlpt_port_test(sc, data, mask))
|
status = 0;
|
||||||
{ status = 0 ; goto end_probe ; }
|
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 ; }
|
|
||||||
}
|
|
||||||
|
|
||||||
end_probe:
|
end_probe:
|
||||||
/* write 0's to control and data ports */
|
/* write 0's to control and data ports */
|
||||||
|
Loading…
Reference in New Issue
Block a user