Next Previous Contents

3. The Plug-and-Play (PnP) Solution

3.1 Introduction to PnP

The tern Plug-and-Play (PnP) has various meanings. In the broad sense it is just auto-configuration where one just plugs in a device and it configures itself. In the sense used in this HOWTO, the configuration is only that of configuring PnP resources and letting the device drivers know about it. In a more narrow sense it just setting resources in the hardware devices. It may also mean the PnP specifications which (among other things) specify how PnP resource data is to be read and written to devices (often cards) on the ISA bus. The standard PCI (and not PnP) specifications do the same for the PCI bus.

PnP matches up devices with their device drivers and specifies their communication channels. On the ISA bus, before Plug-and-Play the resources were set on hardware devices by jumpers. Software drivers were assigned resources by configuration files (or the like) or by probing the for the device at addresses where it's expected to reside. The PCI bus was PnP-like from the beginning so it was trivial to implement PnP for this bus. Since the PCI bus specifications don't use the term PnP it's not clear whether or not the PCI bus should be called PnP (but it supports in hardware what today is called PnP).

3.2 How It Works (simplified)

Here's an oversimplified view of how PnP works. The PnP configuration program (perhaps a program in the BIOS) finds all PnP devices and asks each what resources it needs. Then it checks what resources it has to give away. Of course it has reserved resources used by non-PnP (legacy) devices (if it knows about them) and doesn't give any of these reserved resources away. Then it uses some criteria (not specified by PnP specifications) to give out the resources so that there are no conflicts and so that all devices get what they need. It then tells each physical device what resources are assigned to it and the devices set themselves up to use only the assigned resources. Then the device drivers somehow find out what resources their devices use and are thus able to communicate effectively with the devices they control.

For example, suppose a card needs one interrupt (IRQ number) and 1 MB of shared memory. The PnP program reads this request from the card. It then assigns the card IRQ5 and 1 MB of memory addresses space, starting at address 0xe9000000. It's not always this simple as the card may specify that it can only use certain IRQ numbers (ISA only) or that the 1 MB of memory must lie within a certain range of addresses. The details are different for the PCI and ISA buses with more complexity on the ISA bus.

There are some shortcuts that PnP software may use. One is to keep track of how it assigned resources at the last configuration (when the computer was last used) and reuse this. If devices remembered their previous configuration, then there wouldn't be much to do, but they seem to forget their configuration when the power is turned off. Some contain a default configuration (but not necessarily the last one used). Thus a PnP configuration program needs to be run each time the PC is powered on. Also, if a new device has been added, then it needs to be configured. Allocating resources to this new device might involve taking some resources away from an existing device and assigning the existing device alternative resources.

3.3 Starting Up the PC

When the PC is first turned on the BIOS chip runs its program to get the computer started (the first step is to check out the hardware). If the operating system is stored on the hard-drive (as it normally is) then the BIOS must know about the hard-drive. If the hard-drive is PnP then the BIOS may use PnP methods to find it. Also, in order to permit the user to manually configure the BIOS's CMOS and respond to error messages when the computer starts up, a screen (video card) and keyboard are also required. Thus the BIOS must PnP-configure these devices on its own.

Once the BIOS has identified the hard-drive, the video card, and the keyboard it is ready to "boot" (load the operating system from the hard-disk). If you've told the BIOS that you have a PnP operating system, it should boot the PC and let the operating system finish the PnP configuring. Otherwise, a PnP-BIOS will likely try to do the rest of the PnP configuring of devices (but not their drivers).

3.4 Buses

ISA is the old bus of the old IBM PC's while PCI is a newer and faster bus from Intel. Eventually, the ISA bus should become extinct. When it does, there should be almost no PnP problem in Linux provided: 1. the only bus in use is PCI. 2. The BIOS does a good job of PnP configuring it.

The PCI bus was designed for what is today called PnP. It makes it easy (as compared to the ISA bus) to find out how PnP resources have been assigned to hardware devices. To see what has happened look at the /proc/pci "file" (/proc/bus/pnp/devices for kernel 2.2+), the boot-up messages on your display (type dmesg after they disappear), or use pciutils (must have kernel 2.2 or better).

For the ISA bus there is a real problem with implementing PnP since no one had PnP in mind when the ISA bus was designed and there are almost no I/O addresses available for PnP to use for sending configure info to physical device. As a result, the way PnP was shoehorned onto the ISA bus is very complicated. A whole book has been written about it. See PnP Book. Among other things, it requires that each PnP device be assigned a temporary "handle" by the PnP program so that one may address it for PnP configuring. Assigning these "handles" is call "isolation". See Isolation for the complex details.

3.5 Linux Needs to Cope Better with PnP

PnP was invented by Campaq, Intel, and Phoenix. Microsoft has been a leading promoter of it. Linux would have been better off if PnP had never been "invented". Eventually the ISA bus would have become extinct and the PnP-like PCI bus would prevail so that we would have in effect gotten an easy-to-implement PnP. But like it or not, most all ISA hardware today is PnP and Linux has no choice but to deal effectively with PnP. But standard Linux (as of early 1999) makes dealing with PnP complicated (especially on the ISA bus) while the purpose of PnP was to make it simple.

In a sense, Linux is already somewhat PnP for the PCI bus. When the PC starts up you may note from the messages on the screen that some Linux device drivers often find their hardware devices (and the resources the BIOS has assigned them). But there still could be conflicts with the ISA bus.

Linux users should not need to delve into the details of PnP to configure ISA PnP devices as they now need to. One solution would be a standardized version of the Linux kernel that supports Plug-and-Play on both the ISA and PCI buses. A patch to the kernel has been written although most drivers don't support it. It's not part of standard Linux. See Patch Kernel.

3.6 Configuring a PnP BIOS

When the computer is first turned on, the BIOS runs before the operating system is loaded. Newer BIOSs are PnP and will configure some or all of the PnP devices. For most PnP BIOSs there is no way to disable PnP so you have to live with it. Here are some of the choices which may exist in your BIOS's CMOS menu:

Do you have a PnP operating system?

If you say yes, then the PnP BIOS will PnP-configure the hard-drive, video card, and keyboard to make the system bootable. But it will leave it up to the operating system to finish the configuration job. It may do an Isolation on the ISA bus leaving the devices disabled but ready to be configured by the operating system. Unless you are using a special Linux kernel which has been patched to make it PnP you should probably say that you don't have a PnP operating system. If you don't the BIOS might leave the ISA devices it hasn't configured in a disabled state ?? Also PCI devices might not get configured.

If you say no, then the BIOS will do the configuring itself. Unless you have added new PnP devices, it should use the configuration which it has stored in non-volatile memory (ESCD). See The BIOS's ESCD Database If the last session on your computer was with Linux, then there should be no change in configuration. But if the last session was with Windows9x (which are PnP) then Windows could have set up the configuration differently and saved some or all of it in the ESCD. See Using Windows to set ESCD is Problematical.

You can always have isapnp run at the startup of Linux to change the ISA configuration to what you want under Linux. For PCI cards you may try pciutils for PCI and check the configuration in the /proc tree. Some device drivers may have checked the /proc tree (or the equivalent) so they may be configured correctly. Otherwise you may need to make sure that the data in /proc tree is compatible with your Linux configuration files ("setserial", lilo.conf, etc.) for the drivers being used. Note that some "files" in the /proc tree (such as interrupts) only show resources used by currently running processes. See BIOS Configures PnP for more info.

How are resources to be controlled?

This may involve just deciding how to allocate IRQ and DMA resources. If set to "auto", the bios will do the allocation. If set to manual, you manually reserve some IRQ's for use on "legacy" (non-pnp) cards. The BIOS may or may not otherwise know about your legacy cards. The BIOS will only know about your legacy cards if you ran ICU (or the like) under Windows to tell the BIOS about them. If it knows about them, then try using "auto". If it doesn't know about them then manually reserve the IRQ's needed for the legacy ISA cards and let the rest be for the BIOS PnP to allocate.

Reset the configuration?

This will erase the BIOSs data-base of how your PnP devices should be configured as well as the list of how legacy (non-PnP) devices are configured. Never do this unless you are convinced that this data- base is wrong and needs to be remade. It was stated somewhere that you should do this only if you can't get your computer to boot. If the BIOS loses the data on legacy devices, then you'll need to run ICA again under DOS/Windows to reestablish this data.


Next Previous Contents