[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?

Thanks in advance!

yuan