Plug-and-Play Hardware
Chances are, you or someone you know has had to deal with plug-and-play (PnP) hardware. These devices are just like “legacy” devices, except they have no jumpers to configure the resources (i.e., IRQs, DMAs and I/O addresses). PnP cards expect the computer, either the BIOS or the operating system, to find and configure the card. It's an excellent idea, but why?
Most Linux users enjoy configuring their computers—getting their hands dirty working with the hardware. On the other side of the coin is the user who expects his computer to turn on in the morning and be ready for him to complete his work without intervention by him. This type of user will also add hardware to his computer, but does not want to spend time finding free resources and setting them. PnP hardware is ideal for him.
This user can purchase a plug-and-play device, put it in his computer, and the configuration is done automatically. This idea of automatic configuration was designed into the PCI bus, the newer of the common busses. Unfortunately, most users still rely on the standard architecture defined by the industry; that is, the ISA bus. It works well, but still has its limitations. Most notably, plug-and-play was not considered when ISA was designed.
The designers of the plug-and-play standard decided to extend plug-and-play to ISA devices. Wouldn't it be nice to have some sort of detection and configuration scheme to find these devices and set them up for the user? Think how easy computers would be! So, the designers set up a scheme to find ISA cards and configure them to the jumpered resources on the card. Hardware vendors loved the idea and decided to cooperate by suggesting the removal of all the jumpers.
Now we have a fully functional plug-and-play system for the ISA bus, right? Well, not exactly. It still has a way to go before it is all the way out the door. PCI architecture will take over in the next few years before plug-and-play ISA works without any problems. For now, we have to work with these plug-and-play ISA devices while mourning the loss of our beloved jumpers.
PnP ISA devices can be used in several ways under Linux. The kernel can find and configure them before loading any other drivers. This method sometimes fails to find all devices and to initialize the devices. It also requires patching the kernel with one of the PnP add-ons.
Another way, which I recommend, is to use an initialization program at the user level. You create a configuration file with your devices and specify the resources each device is to use. Then, this file is read by an initialization utility that configures the devices. However, this method does require the drivers for these devices to be compiled as kernel modules.
I have tried a couple of these user-level configuration programs, and the one I have found to be the easiest and most reliable is the isapnptools package. This program is designed to work on systems with or without a PnP-compatible BIOS. It will not interfere with “legacy” ISA devices either (devices with jumpers); at least, I have not had that problem.
As an example, I will configure a PnP sound card and load the driver for it. I will assume you can install the card and you have a working knowledge of Linux. Here's a basic overview of the setup process:
getting the isapnptools package
dumping all possible values
choosing your resources
testing the configuration
compiling the kernel driver
enabling the device at bootup
Most of the latest Linux distributions come with the isapnptools package. However, you may want to grab the latest version from the isapnptools web page, http://www.roestock.demon.co.uk/isapnptools/. At the time of this writing, the latest version is 1.17.
After downloading the file, extract the contents and compile it. Some systems may require editing the Makefile. Check the included INSTALL file for more information. As root, I used the following commands to compile and install the package:
tar xvzf isapnptools-1.17.tar.gz cd isapnptools-1.17 make make install (as root)
The installation will create the isapnp and pnpdump programs along with their accompanying man pages and sample configuration file.
After you've compiled and installed isapnptools, it is time to configure your devices. This is done by creating a configuration file explaining the device(s) and which resources it will use. The great thing about isapnptools is that it will build this file for you. Then you go in and play “multiple choice” (as the author puts it).
To create the configuration file, run the pnpdump program. It scans for all ISA plug-and-play devices and all possible configurations. These values are dumped to standard out (STDOUT) in the file format needed. Here is the command I use to create the file as root:
/sbin/pnpdump > /etc/isapnp.conf
Listing 1. Confuguration File Start
The program failed on me a few times, but that was mainly due to other system errors. You should now have a configuration file in /etc if you used my command. The beginning of the file should look something like Listing 1. The rest of the configuration file will contain sections for the different devices it found. Now you need to choose which resources the device will use.
The configuration file may seem a bit confusing at first, but it needs only a little deciphering. The basic layout for a device section is shown in Listing 2. By default, a listing of all possible resources for that device will be within the device section. Basically, just uncomment the lines for the resources the device will use. The lines are commented with # marks.
Editing this file requires knowing a bit about the device to be configured. Typically, the user manual for the device will list which resources are required to use the device. In my case, with the Sound Blaster AWE32, I needed a Base I/O address, one IRQ, an 8-bit DMA channel, a 16-bit DMA channel and a MIDI synthesizer I/O address. Other resources are on my card, but I am not using them in this example.
The example device section in Listing 2 shows the resources I chose for my card. I chose 0x0220 for the Base I/O address, 5 for the IRQ channel, 1 for the 8-bit DMA channel, 5 for the 16-bit DMA channel and 0x0330 for the MIDI I/O.
Note that the I/O addresses are called IO 0 and IO 1, and the DMA channels are called DMA 0 and DMA 1. This may make it a little difficult to map the right values to the 8-bit DMA and 16-bit DMA. However, if you read your configuration file after running pnpdump and look at the default resource settings in the user manual for your device, you can easily match things up.
In my case, I know DMA 0 corresponds to the 8-bit DMA because only the 8-bit DMA can have a value of 1. So, the other setting must be the 16-bit DMA channel. The same goes for the IO settings; IO 0 must be the Base I/O address, because the MIDI I/O address can never be 0x0220.
Once you have uncommented the lines you need, make sure the (ACT Y) line is uncommented; otherwise, your device will not be configured.
You have now passed the hard part of PnP configuration under Linux. It is a good idea to test your PnP configuration before going any further. You want to make sure isapnp can properly initialize the card with the resources you have set. Assuming isapnp is in /sbin, execute this command to test your configuration:
/sbin/isapnp /etc/isapnp.conf
If there are no error messages, your configuration should work fine. If you do get resource conflict errors, now would be a good time to go back and edit that configuration file. It is better to get it working now than have to fool with it later. Play around with the resource settings until you find those that don't produce errors when you test the configuration.
Now we are ready for the fun part. Most Linux distributions will come with the various device drivers compiled as modules. Refer to the kernel documentation for more information about modules. Basically, a module is just a device driver that can be added to an already-running kernel. This provides a lot of flexibility for the user, and it is modules that allow us to use PnP devices.
PnP devices must be initialized before the driver can be loaded, so using modules is a necessity. They are the only part of the kernel that can be loaded after the kernel boots.
Your distribution may already include a module for the device you want to use. In the case of sound cards, you might be compiling one from scratch. In my example, I use a Sound Blaster AWE32. The device driver included with my distribution is /lib/modules/2.0.35/misc/sound.o.
If you must recompile, be sure to set any resources for the driver according to those set in the isapnp.conf file. You can always pass the resource values when loading the module, but having the default ones is always nice.
To load the driver for my PnP sound card, I did this:
/sbin/isapnp /etc/isapnp.conf /sbin/modprobe sound.o io=0x0220 irq=5 dma=1\ dma1=5
If all goes well, you should have a driver loaded and working with that device. Check to make sure the module is loaded by typing:
/sbin/lsmodIf this is a sound card, try playing sound files. For network cards, try bringing up the device with ifconfig. At this point the device should be working.
Now that you have your PnP card working under Linux, wouldn't it be great if those devices were set up automatically at boot time? I added the above two lines to my /etc/rc.d/rc.local file, so that my sound driver is loaded each time I boot the system.
This example used what I view as the most common plug-and-play situation when using Linux—a sound card. Other PnP devices exist, such as modems and network cards. The same technique can be applied to those cards as well.
David Cantrell is a Computer Science undergraduate at the Georgia Institute of Technology. He has been using Linux since 1997. David spends a lot of time at his computer, but also enjoys visiting his favorite Mexican restaurant and midnight movies. He enjoys water skiing, backpacking and watching “The Simpsons”. He can be reached via e-mail at david@burdell.org.