Re: [ntdev]How to make a pci device work.

> Hi, all.

I wonder how the OS initialize a pci device during Startup. I mean, the
OS can find the pci device and allocate all the resources it requires, but
how does the OS write these resouces into the device’s pci-configuration
header. I would like to know the sequence in which the OS write the
registers of pci-configuration to make it run.
Can anybody help me?

Quite a big question. By default on an x86 machine all PCI devices present
at boot time have their configurations setup by the BIOS. In Windows 2000
terms I think this is called the boot configuration. When the Windows 2000
PCI bus driver starts up it walks the PCI bus it is responsible for and builds
a PDO for each logical PCI device. Eventually device drivers are started for
each device found (or new device drivers are installed). Before the
IRP_MN_START_DEVICE PnP IRP is sent the Bus driver is given an opportunity to
reassign the device resources (typically Win2k uses the boot resources). If
the device configuration is changed here then the PCI bus driver will rewrite
the device configuration here.

This is a very quick overview which skips over a lot of detail. For more
information on how a bus driver works in general check out the toaster sample
in the XP or W2k DDK (The XP one is better). For more information on how PCI
resource bars work the PCI Bus Specifications are the best place to look.