Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The lpt_port_test function is called by lpt_detect to determine whether a printer is present. Here is its function definition:
static int lpt_port_test(device_t ppbus,u_char data, u_char mask) { int temp, timeout = 10000; data &= mask;
ppb_wdtr(ppbus, data); do { DELAY(10); temp =
ppb_rdtr(ppbus) & mask; } while (temp != data && --timeout);
return (temp == data); }
This function takes an 8-bit value and
writes it to the parallel port’s data register. Then it
reads from that register and
returns whether the value written and read match.