PCI BUS family
PCI MiniPCI CardBus Express Card
32 bit bus, 33 or 66 MHz Smaller slot in laptops External card slot in laptops Replaces CardBus in recent laptops

PIX Extended (PCIX) PCI Express (PCIe or PCIE) PCI Express Mini Card
Wider slot than PCI, 64 bit, but Current generation of PCI. Serial instead of parallel Replaces MiniPCI in recent laptops
can accept a standard PCI card

PCI device types
Network cards (wired or wireless)
SCSI adapters
Bus controllers: USB, PCMCIA, I2C, FireWire, IDE
Graphics and video cards
Sound cards

*PCI device list
root@Heartsun root# uname -a
Linux Heartsun 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux

root@Heartsun root# lspci
00:00.0 Host bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corp. 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corp. 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0f.0 VGA compatible controller: VMWare Inc: Unknown device 0405
00:10.0 SCSI storage controller: BusLogic BT-946C (BA80C30) MultiMaster 10 (rev 01)
00:11.0 Ethernet controller: Advanced Micro Devices AMD 79c970 PCnet32 LANCE (rev 10)
00:12.0 Ethernet controller: Advanced Micro Devices AMD 79c970 PCnet32 LANCE (rev 10)

root@Heartsun root# lspci -tv
-00-+-00.0 Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX Host bridge
+-01.0-01--
+-07.0 Intel Corp. 82371AB/EB/MB PIIX4 ISA
+-07.1 Intel Corp. 82371AB/EB/MB PIIX4 IDE
+-07.3 Intel Corp. 82371AB/EB/MB PIIX4 ACPI
+-0f.0 VMWare Inc: Unknown device 0405
+-10.0 BusLogic BT-946C (BA80C30) MultiMaster 10
+-11.0 Advanced Micro Devices AMD 79c970 PCnet32 LANCE
\-12.0 Advanced Micro Devices AMD 79c970 PCnet32 LANCE

PCI device configuration
Standard information found in PCI configurations:
Offset 0: Vendor Id
Offset 2: Device Id
Offset 10: Class Id (network, display, bridge...)
Offsets 16 to 39: Base Address Registers (BAR) 0 to 6
Offset 44: Subvendor Id
Offset 46: Subdevice Id
Offsets 64 and up: up to the device manufacturer
Kernel sources: these offsets are defined in include/linux/pci_regs.h

root@Heartsun root# lspci -x
00:00.0 Host bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00: 86 80 90 71 06 00 10 02 01 00 00 06 00 00 00 00
10: 08 00 00 e8 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 ad 15 76 19
30: 00 00 00 00 a0 00 00 00 00 00 00 00 00 00 00 00

00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00: 86 80 91 71 1f 01 20 02 01 00 04 06 00 00 01 00
10: 00 00 00 00 00 00 00 00 00 01 01 40 f0 00 a0 02
20: f0 ff 00 00 f0 ff 00 00 00 00 00 00 00 00 00 00
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00

00:07.0 ISA bridge: Intel Corp. 82371AB/EB/MB PIIX4 ISA (rev 08)
00: 86 80 10 71 07 00 80 02 08 00 01 06 00 00 80 00
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 ad 15 76 19
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00:07.1 IDE interface: Intel Corp. 82371AB/EB/MB PIIX4 IDE (rev 01)
00: 86 80 11 71 05 00 80 02 01 8a 01 01 00 40 00 00
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 91 14 00 00 00 00 00 00 00 00 00 00 ad 15 76 19
30: 00 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 00

00:07.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 08)
00: 86 80 13 71 01 00 80 02 08 00 80 06 00 00 80 00
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 ad 15 76 19
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00:0f.0 VGA compatible controller: VMWare Inc: Unknown device 0405
00: ad 15 05 04 03 00 90 02 00 00 00 03 08 40 00 00
10: 81 14 00 00 00 00 00 f0 00 00 00 ec 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 ad 15 05 04
30: 00 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 00

00:10.0 SCSI storage controller: BusLogic BT-946C (BA80C30) MultiMaster 10 (rev 01)
00: 4b 10 40 10 03 00 80 02 01 00 00 01 00 40 00 00
10: 61 10 00 00 00 00 80 ec 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 4b 10 40 10
30: 00 00 00 00 00 00 00 00 00 00 00 00 0b 01 06 ff

00:11.0 Ethernet controller: Advanced Micro Devices AMD 79c970 PCnet32 LANCE (rev 10)
00: 22 10 00 20 07 00 80 02 10 00 00 02 00 40 00 00
10: 81 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 22 10 00 20
30: 00 00 00 00 00 00 00 00 00 00 00 00 09 01 06 ff

00:12.0 Ethernet controller: Advanced Micro Devices AMD 79c970 PCnet32 LANCE (rev 10)
00: 22 10 00 20 07 00 80 02 10 00 00 02 00 40 00 00
10: 01 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 22 10 00 20
30: 00 00 00 00 00 00 00 00 00 00 00 00 0a 01 06 ff

PCI Boot Time
When power is applied to a PCI device, the hardware remains inactive. In other words, the device responds only to configuration transactions. At power on, the device has no memory and no I/O ports mapped in the computer’s address space; every other device-specific feature, such as interrupt reporting, is disabled as well. Fortunately, very PCI motherboard is equipped with PCI-aware firmware, called the BIOS, NVRAM, or PROM, depending on the platform. The firmware offers access to the device configuration address space by reading and writing registers in the PCI controller.

At system boot, the firmware (or the Linux kernel, if so configured) performs configuration transactions with every PCI peripheral in order to allocate a safe place for each address region it offers. By the time a device driver accesses the device, its memory and I/O regions have already been mapped into the processor’s address space. The driver can change this default assignment, but it never needs to do that.

How to make PCI Hotplug and module system know exact device
This pcideviceid structure needs to be exported to user space to allow the hotplug and module loading systems know what module works with what hardware devices.
The macro MODULEDEVICETABLE accomplishes this. An example is: MODULEDEVICETABLE(pci, i810ids);This statement creates a local variable called modpcidevicetable that points to the list of struct pcideviceid. Later in the kernel build process, the depmod program searches all modules for the symbol modpcidevicetable. If that symbol is found, it pulls the data out of the module and adds it to the file /lib/modules/ KERNELVERSION/modules.pcimap. After depmod completes, all PCI devices that are supported by modules in the kernel are listed, along with their module names, in that file. When the kernel tells the hotplug system that a new PCI device has been found, the hotplug system uses the modules.pcimap file to find the proper driver to load.

Registering a PCI Driver
const char *name;
The name of the driver. It must be unique among all PCI drivers in the kernel and is normally set to the same name as the module name of the driver. It shows up in sysfs under /sys/bus/pci/drivers/ when the driver is in the kernel.

const struct pcideviceid *id_table;
Pointer to the struct pcideviceid table described earlier in this chapter.

int (probe) (struct pcidev dev, const struct pcidevice_id *id);
Pointer to the probe function in the PCI driver. This function is called by the PCI core when it has a struct pcidev that it thinks this driver wants to control. A pointer to the struct pcideviceid that the PCI core used to make this decision is also passed to this function. If the PCI driver claims the struct pcidev that is passed to it, it should initialize the device properly and return 0. If the driver does not want to claim the device, or an error occurs, it should return a negative error value. More details about this function follow later in this chapter.

void (remove) (struct pci_dev dev);
Pointer to the function that the PCI core calls when the struct pci_dev is being removed from the system, or when the PCI driver is being unloaded from the kernel. More details about this function follow later in this chapter.

int (suspend) (struct pci_dev dev, u32 state);
Pointer to the function that the PCI core calls when the struct pci_dev is being suspended. The suspend state is passed in the state variable. This function is optional; a driver does not have to provide it.

int (resume) (struct pci_dev dev);
Pointer to the function that the PCI core calls when the struct pci_dev is being resumed. It is always called after suspend has been called. This function is optional; a driver does not have to provide it.

Last edited Aug 28, 2009 at 1:56 PM by webexpert21, version 4

Comments

No comments yet.