Listing 2: From iohw.c.
extern void iogroup_acquire(_IOgroup group)
{
/* The LPT1 registers are dynamic designators since their port
* numbers vary from machine to machine. The BIOS tells us
* where the port is located. In a more complete example,
* this would be the place to set the I/O privilege mask to
* also grant access to port when the CPU is in protected
* instead of real mode. */
if (group == LPT1_GROUP) {
unsigned short *bios_table = (unsigned short *) 0x400008;
if (bios_table[0] == 0) {
printf("No printer port\n");
exit(EXIT_FAILURE);
}
printf("Found printer port at %X\n", bios_table[0]);
lpt1_data.location.port = bios_table[0];
lpt1_status.location.port = bios_table[0] + 1;
lpt1_control.location.port = bios_table[0] + 2;
/* Port at 0x3BC never has a ECP control register. Our standard
* check for a true ECP control register will cause us not to use
* it if it appears to be a copy of the SPP control register. */
if (bios_table[0] == 0x3BC)
lpt1_ecp_control.location.port = lpt1_control.location.port;
else
lpt1_ecp_control.location.port = bios_table[0] + 0x402;
}