Copyright ã1995 by NeXT Computer, Inc.  All Rights Reserved.

Auto Detection of Devices

EISA- and PCI-compliant systems can support automatic detection of devices, referred to as the auto detect feature. When auto detect is supported, the system can determine which devices are connected to the bus and the location of the devices. Devices are easier to configure because less information is required in the .table files for the driver. Auto detect is nondestructive: It doesn't change the state of any device. 

Auto detect determines which devices are connected to a bus and their bus location. Each device identifies itself with an auto detect ID and indicates its location with an anchor.

Auto Detect IDs and Anchors

Each device driver identifies itself by an auto detect ID string, which is a list of identifiers that can be used to detect the devices that can be controlled by the driver. The meaning of the identifiers is different for each bus type.

For the EISA, PCI and Plug and Play bus types, this ID is expressed as a 32-bit hexadecimal number containing the vendor ID and the device ID for the device. For the EISA bus and for Plug and Play, the device ID is in the lower 16 bits, and the vendor ID is in the upper 16 bits. For the PCI bus, the vendor ID is in the lower 16 bits, and the device ID is in the upper 16 bits. The ªAuto Detect IDsº key should contain IDs for all the devices that can be controlled by the device driver. There is currently no provision for matching ªdon't careº bits in the ID, although that may be added in the future.

When your driver is configured in the system, the configuration software will scan the bus for devices that match your auto detect IDs. When it finds a device, it will create a device description for your driver with a value for the ªLocationº key that allows you to locate your device on the bus. This key is known as the ªanchorº for your device and is different for each bus type.

For the EISA bus, the anchor is a slot number between 0 and 15. The value of the ªLocationº key is ªSlot <n>º, where <n> is your slot number.

For the PCI bus, the anchor is a three-part identifier containing the bus number, the device number, and the function number for your device. The bus number can be between 0 and 255, the device number can be between 0 and 31, and the function number can be between 0 and 7. The syntax of the ªLocationº key is ªDev:<d> Func:<f> Bus:<b>º, where <b> is the bus number, <d> is the device number, and <f> is the function number.

Plug and Play support does not currently define an anchor for the card. Instead, the resources assigned in your configuration table, such as base I/O address, IRQ level, and DMA channels, are programmed into your device using the Plug and Play control registers. In the future, an anchor will be assigned so you can use new Driver Kit methods to control resources in more detail.

Auto Detect Process

The driver bundle's Default.table has two key/value pairs of interest for auto detection: ªBus Typeº and ªAuto Detect IDsº. The first tells which bus the driver supports. The second lists the auto detect IDs of all the supported devices for this driver, expressed in the 32-bit hexadecimal number format.

Auto detection is used at two times: During installation and when you use the Configure application.

During initial installation, the auto detect software scans each bus and obtains from each device its auto detect ID and its anchor in the form that the bus uses. It adds the ªLocationº key to your driver's device description in memory.

Note:  A computer may have more than one bus, and the buses may be different types.

When you use Configure to add a driver to your system, it looks at every file with a .table extension (with the exception of Instancen.table files) in each configuration bundle, trying to match bus types and auto detect IDs. It first examines the ªBus Typeº and then the ªAuto Detect IDsº key/value pairs and generates a candidate list of drivers for each device found. There may be more than one candidate driver for a device. In that case, the user is presented with a list of drivers for the device and asked to pick one. After the user chooses, the .table file is copied to an Instancen.table with this line appended:

"Location" = "anchor"

where anchor is the anchor in the format appropriate for the bus.

There are cases where ªLocationº is blank. Each bus-specific category of IODirectDevice (IOEISADirectDevice, IOPCIDirectDevice, and so on) and IODeviceDescription subclass (IOPCMCIADeviceDescription and so on) provide methods for extracting this information, such as getPCIDevice:function:bus and getEISASlotNumber.