## The PCI42 Sample

The PCI42 Sample accompanies Chapter 7 and illustrates how to write a driver for a programmed I/O (PIO) PCI device.

The sample includes four components:

- PCI42.SYS (SYS subdirectory) is a WDM driver for a simulated device based on the AMCC S5933 chip.
- S5933DK1.SYS (S5933DK1 subdirectory) is a WDM driver for the ISA card that comes with the development kit for the AMCC S5933 chip.
- ADDONSIM.EXE (ADDONSIM subdirectory) is a Win32 console program that interacts with the S5933DK1 ISA card as part of the test procedure.
- TEST.EXE (TEST subdirectory) is a Win32 console program that interacts with the PCI42 device to perform a test.

### Building PCI42

To build PCI42.SYS or S5933DK1.SYS, follow the general instructions for building a WDM sample. The Microsoft Visual C++ project files are named PCI42.DSP in the SYS subdirectory and S5933DK1.DSP in the S5933DK1 subdirectory, respectively.

To build ADDONSIM.EXE or TEST.EXE, follow the general instructions for building user-mode programs. The Microsoft Visual C++ project files are named ADDONSIM.DSP in the ADDONSIM subdirectory and TEST.DSP in the TEST subdirectory, respectively.

### Testing PCI42

To test this sample, you’ll need the S5933DK1 development kit from Applied Micro Circuits Corporation (AMCC). The kit includes a PCI card and an ISA card that connects to the PCI card via a ribbon cable. You’ll obviously need a computer with a free PCI slot and a free ISA slot to install both these components.

First install the S5933DK1 driver (only). Follow the general instructions for using FastInst in Windows XP or Windows 98/Me. The INF file is named S5933DK1.INF and is in the S5933DK1 subdirectory. The ISA card requires I/O port addresses 300-33F and 718-71F. If you have other hardware at these addresses, you’ll need to disable or remove that hardware.

After installing the ISA card driver, you’ll need to restart the computer. Take the opportunity to power down so you can install both cards. Remove J4 from the PCI card to force the card to identify itself using default values (Vendor 10E8, Device 4750). During restart, the PnP Manager will detect the PCI card and prompt you for a driver. You want to direct the installer to the SYS subdirectory for this sample, where PCI42.INF provides instructions for installing the PCI42 driver.

If you want to test PCI42 after running some other driver on the development board, use the Device Manager to update the driver and point it specifically to the PCI42\SYS subdirectory.

Open two command prompts and execute the TEST.EXE and ADDONSIM.EXE programs from the TEST\DEBUG and ADDONSIM\DEBUG subdirectories simultaneously. It doesn’t matter which one you start first. ADDONSIM will write some data to the ISA card, and TEST will read the same data from the PCI card.

Testing Note for Windows 98/Me:I found that Windows 98, Second Edition, keeps removing the ISA card from the configuration when I restart. This behavior is wrong, of course, and seems to occur because of a conflict between the I/O addresses needed by the ISA card and a sound card on the computer. To test in this environment, I therefore found it necessary to use the Add New Hardware wizard to reinstall the S5933DK1 driver in each new session and to ignore the direction to reboot the computer at the end of the reinstallation process.

### What to look for

ReadWrite.cpp in the sys directory is the point of this sample. This file contains the routines that are used to perform I/O to a PIO (programmed I/O) device. I suggest you begin by reading StartDevice. Move on to the I/O path, which includes DispatchReadWrite, StartIo, OnInterrupt, and DpcForIsr.