Peripheral Component Interconnect — Änderungen 2583 → 2585

Zeile 1: Zeile 1:
−
Peripheral Component Interconnect (kurz PCI) ist ein Bus zur leichten Verbindung Peripheriegeräten mit mit der CPU.
+
Peripheral Component Interconnect (kurz PCI) ist ein Bus zur leichten Verbindung von Peripheriegeräten mit mit der CPU.
  
 
== Konfigurations-Register ==
 
== Konfigurations-Register ==
−
Jedes PCI-Gerät besitzt ein Konfigurations-Register, das 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).
+
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 ===
 
=== Aufbau des Adress-I/O-Ports ===
Zeile 49: Zeile 49:
 
|}
 
|}
 
<br />
 
<br />
 +
 +
=== 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>