TITLE: Writing Device Drivers - Plug and Play Basics
IBM Developer Connection News Volume 6
by Steve Mastrianni

The hardware changes necessary for an adapter to support Plug and 
Play (PnP) are relatively minor, with the parts costing a total of 
less than $5 per adapter. The actual hardware consists of a 72-bit 
shift register, some non-volatile memory, and some tri-state 
buffers. Use the 72-bit shift register to identify the particular 
adapter.  The register contains 32 bits of vendor data, 32 bits of 
serial number and an 8-bit checksum. PnP adapters also contain 
several bytes of configuration data stored in non-volatile RAM. 
This data can be read and changed after you place the PnP card in 
the configuration state. 

A special set of registers on each PnP adapter, contained in a PnP 
Applications Specific Integrated Circuit, or ASIC, provide access 
to PnP cards and resource data. Even though the ISA bus is not 
addressable, the PnP chipset provides for a method to isolate PnP 
cards on the bus, one at a time, until all cards have been 
identified. It does this by placing the adapter card in a low or 
high impedance mode, depending on the data written to the card 
and the contents of the LFSR on the adapter. Cards are isolated, 
selected, and configured, then placed in a high impedance mode. 
This allows one card to be selected and configured, then placed 
into a high impedance mode so that it will no longer take part 
in the iterative process of adapter isolation. 

Two specific I/O ports have been reserved for PnP operation. The 
first is 0x279, which is actually the printer status port, normally 
a read-only register. The second is 0xa79, the printer status port 
+0x800. These two ports provide accessibility to the PnP hardware 
on each adapter using a special software sequence of reads and 
writes to these ports. Use a third port to read data from and write 
data to the card. This third port, however, is relocatable by the 
PnP isolation software. The PnP specification defines that this 
port should start at 0x203, but in practice, you should begin at 
0x20B, since a standard joystick occupies the lower port addresses. 
All PnP register I/O is performed using 8-bit transfers; 16-bit 
transfers are not supported. 

True Plug and Play support requires BIOS changes to detect and 
configure PnP cards at boot time. Newer machines with Flash BIOS 
should be easily modified; older machines with ROM BIOS are more 
difficult. Upon bootup, the BIOS performs the isolation sequence 
to ensure that the cards necessary for boot are enabled. It is 
assumed that those cards will always remain active. In most cases, 
this is accomplished by a single jumper or switch on the adapter 
card. Cards that are in the active state do not take part in the 
isolation sequence. If you insert a new card, the next time you 
turn the machine on, the BIOS should perform an 
auto-configuration sequence enabling the new card with acceptable 
settings. 

Steve Mastrianni is an Industry Consultant specializing in device 
drivers and real-time applications for OS/2.  The author of 
Writing OS/2 2.1 Device Drivers in C, Steve is regarded as one of 
the industry's leading experts in OS/2 and OS/2 device drivers.  
Steve can be reached on CompuServe@73354,746, or Internet at 
stevemas@vnet.ibm.com.