Peripheral Component Interconnect
Aus Lowlevel
Version vom 18. Januar 2009, 19:20 Uhr von MNemo (Diskussion | Beiträge) (→Aufbau des Konfigurations-Adressraum)
Peripheral Component Interconnect (kurz PCI) ist ein Bus zur leichten Verbindung von Peripheriegeräten mit der CPU.
Inhaltsverzeichnis
- 1 Konfigurations-Register
- 2 Classcodes
- 2.1 Class 0x00 - Pre 2.0
- 2.2 Class 0x01 - Massenspeicher
- 2.3 Class 0x02 - Netzwerk-Controller
- 2.4 Class 0x03 - Bildschirm-Controller
- 2.5 Class 0x04 - Multimedia-Geräte
- 2.6 Class 0x05 - Speicher-Controller
- 2.7 Class 0x06 - Bridge-Geräte
- 2.8 Class 0x07 - Controller zur einfachen Kommunikation
- 2.9 Class 0x08 - System-Peripherie
- 2.10 Class 0x09 - Input-Geräte
- 2.11 Class 0x0A - Docking-Stationen
- 2.12 Class 0x0B - Processors
- 2.13 Class 0x0C - Seriell-Bus-Controller
- 2.14 Class 0x0D - Wireless-Controller
- 3 Weblinks
Konfigurations-Register
Jedes PCI-Gerät besitzt ein Konfigurations-Register, welches 256 Byte groß ist. Gelesen und beschrieben wird es 32bit-weise mithilfe eines Adress-I/O-Ports (0xCF8) und eines Daten-I/O-Ports (0xCFC).
Aufbau des Adress-I/O-Ports
| 31 | 30-24 | 23-16 | 15-11 | 10-8 | 7-0 |
|---|---|---|---|---|---|
| Enable Bit | Reserviert | Busnummer | Gerätenummer | Funktionsnummer | Registernummer |
Aufbau des Konfigurations-Adressraum
| Register | 31-24 | 23-16 | 15-8 | 7-0 |
|---|---|---|---|---|
| 0x00 | Device ID | Vendor ID | ||
| 0x04 | Status | Command | ||
| 0x08 | Classcode | Revision ID | ||
| 0x0C | BIST | Header Type | Latency Timer | Cache Line Size |
Die ersten 16 Byte sind für alle PCI-Geräte gleich.
- Classcode ist noch einmal geteilt. Die oberen 8 Bit repräsentieren die Base Class. Die mittleren 8 Bit stehen für die Subclass und die unter 8 Bit für das Programming Interface.
- Header Type spezifiziert den Inhalt der Register 0x10-0x3C, wobei Bit 7 angibt ob es sich um ein Multifunction-Device handelt oder nicht.
Header Type Kurze Beschreibung 0x00 Standard 0x01 PCI/PCI-Bridge 0x02 CardBus-Bridge
Header Type 0x00
| Register | 31-24 | 23-16 | 15-8 | 7-0 |
|---|---|---|---|---|
| 0x10 | Base Address 0 (BAR0) | |||
| 0x14 | Base Address 1 (BAR1) | |||
| 0x18 | Base Address 2 (BAR2) | |||
| 0x1C | Base Address 3 (BAR3) | |||
| 0x20 | Base Address 4 (BAR4) | |||
| 0x24 | Base Address 5 (BAR5) | |||
| 0x28 | Cardbus CIS Pointer | |||
| 0x2C | Subsystem ID | Subsystem Vendor ID | ||
| 0x30 | Expansion ROM base address | |||
| 0x34 | Reserviert | |||
| 0x38 | ||||
| 0x3C | Max Latency | Min Grant | Interrupt Pin | Interrupt Line |
Header Type 0x01
| Register | 31-24 | 23-16 | 15-8 | 7-0 |
|---|---|---|---|---|
| 0x10 | Reserviert | |||
| 0x14 | ||||
| 0x18 | Secondary latency timer | Subordinate bus № | Secondary bus № | Primary bus № |
| 0x1C | Secondary Status | I/O Limit | I/O base | |
| 0x20 | Memory limit | Memory base | ||
| 0x24 | Prefetchable memory limit | Prefetchable memory base | ||
| 0x28 | Prefetchable base upper 32 bits | |||
| 0x2C | Prefetchable limit upper 32 bits | |||
| 0x30 | I/O limit upper 16 bits | I/O base upper 16 bits | ||
| 0x34 | Reserviert | Capabilities pointer | ||
| 0x38 | Reserviert | |||
| 0x3C | Bridge control | Interrupt pin | Interrupt line | |
Codebeispiel
<c>
- define PCI_CONFIG_DATA 0xCFC
- define PCI_CONFIG_ADDRESS 0xCF8
/**
* Liest ein Dword aus einem PCI-Konfigurations-Register * @param bus Bus * @param dev Gerät * @param func Funktion * @param offset Registernummer * @return Register content */
int pci_config_readd(int bus,int dev,int func,int offset) {
int val; int address = 0x80000000|(bus<<16)|(dev<<11)|(func<<8)|(offset&0xFC); outl(PCI_CONFIG_ADDRESS,address); val = inl(PCI_CONFIG_DATA); return val;
}
/**
* Schreibt ein Dword in in ein PCI-Konfigurations-Register * @param bus Bus * @param dev Gerät * @param func Funktion * @param offset Registernummer * @param val Wert zum Schreiben */
void pci_config_writed(int bus,int dev,int func,int offset,int val) {
int address = 0x80000000|(bus<<16)|(dev<<11)|(func<<8)|(offset&0xFC); outl(PCI_CONFIG_ADDRESS,address); outl(PCI_CONFIG_DATA,val);
} </c>
Classcodes
| Class | Beschreibung |
|---|---|
| 0x00 | Alle Geräte die gebaut wurden bevor Classcodes eingeführt wurden |
| 0x01 | Massenspeicher |
| 0x02 | Netzwerk-Controller |
| 0x03 | Bildschirm-Controller |
| 0x04 | Multimedia-Geräte |
| 0x05 | Speicher-Controller |
| 0x06 | Bridge-Geräte |
| 0x07 | Controller zur einfachen Kommunikation |
| 0x08 | System-Peripherie |
| 0x09 | Input-Geräte |
| 0x0A | Docking-Stationen |
| 0x0B | Prozessoren |
| 0x0C | Seriell-Bus-Controller |
| 0x0D | Wireless-Controller |
| 0x0E-0xFE | Reserviert |
| 0xFF | Sonstige |
Class 0x00 - Pre 2.0
| Subclass | Beschreibung |
|---|---|
| 0x00 | Alle nicht-VGA-Geräte |
| 0x01 | VGA-Geräte |
Class 0x01 - Massenspeicher
| Subclass | Beschreibung |
|---|---|
| 0x00 | SCSI |
| 0x01 | IDE |
| 0x02 | Floppy |
| 0x03 | IPI |
| 0x04 | RAID |
| 0x05 | ATA Controller (mit DMA) |
| 0x80 | Anderer Massenspeicher |
Class 0x02 - Netzwerk-Controller
| Subclass | Beschreibung |
|---|---|
| 0x00 | Ethernet |
| 0x01 | Token Ring |
| 0x02 | FDDI |
| 0x03 | ATM |
| 0x80 | Anderer Netzwerk-Controller |
Class 0x03 - Bildschirm-Controller
| Subclass | Beschreibung |
|---|---|
| 0x00 | VGA-Kompatibel |
| 0x01 | XGA |
| 0x80 | Anderer Bildschirm-Controller |
Class 0x04 - Multimedia-Geräte
| Subclass | Beschreibung |
|---|---|
| 0x00 | Video-Gerät |
| 0x01 | Audio-Gerät |
| 0x80 | Anderes Multimedia-Gerät |
Class 0x05 - Speicher-Controller
| Subclass | Beschreibung |
|---|---|
| 0x00 | RAM |
| 0x01 | Flash-Speicher |
| 0x80 | Anderer Speicher |
Class 0x06 - Bridge-Geräte
| Subclass | Beschreibung |
|---|---|
| 0x00 | Host/PCI-Bridge |
| 0x01 | PCI/ISA-Bridge |
| 0x02 | PCI/EISA-Bridge |
| 0x03 | PCI/MicroChannel-Bridge |
| 0x04 | PCI/PCI-Bridge |
| 0x05 | PCI/PCMCIA-Bridge |
| 0x06 | PCI/NuBus-Bridge |
| 0x07 | PCI/CardBus-Bridge |
| 0x09 | Semitransparente PCI/PCI-Bridge |
| 0x0A | InfiniBand/PCI-Brige |
| 0x80 | Anderer Bridge-Typ |
Class 0x07 - Controller zur einfachen Kommunikation
| Subclass | Beschreibung |
|---|---|
| 0x00 | Serielle Schnittstelle |
| 0x01 | Parallelport |
| 0x04 | GPIB (IEEE488.1/2) Controller |
| 0x05 | SmartCard |
| 0x80 | Andere |
Class 0x08 - System-Peripherie
| Subclass | Beschreibung |
|---|---|
| 0x00 | Programmable Interrupt Controller |
| 0x01 | Direct Memory Access |
| 0x02 | Timer |
| 0x03 | Realtime Clock |
| 0x80 | Andere System-Peripherie |
Class 0x09 - Input-Geräte
| Subclass | Beschreibung |
|---|---|
| 0x00 | Tastatur |
| 0x01 | Digitizer (Stift) |
| 0x02 | Maus |
| 0x80 | Anderes Input-Gerät |
Class 0x0A - Docking-Stationen
| Subclass | Beschreibung |
|---|---|
| 0x00 | Normale Docking-Station |
| 0x80 | Andere Docking-Station |
Class 0x0B - Processors
| Subclass | Beschreibung |
|---|---|
| 0x00 | 386 |
| 0x01 | 486 |
| 0x02 | Pentium |
| 0x10 | Alpha |
| 0x20 | PowerPC |
| 0x40 | Co-Processor |
Class 0x0C - Seriell-Bus-Controller
| Subclass | Beschreibung |
|---|---|
| 0x00 | Firewire (IEEE 1394) |
| 0x01 | ACCESS-Bus |
| 0x02 | SSA (Serial Storage Architecture) |
| 0x03 | USB (Universal Serial Bus) |
Class 0x0D - Wireless-Controller
| Subclass | Beschreibung |
|---|---|
| 0x11 | Bluetooth |
| 0x12 | Broadband |
Weblinks
- Linux PCI ID Repositorium - Enthält viele VendorIDs und die dazugehörigen DeviceIDs