Copyright (c) Hyperion Entertainment and contributors.
PCI
Contents
Introduction
Many Amiga computers utilitize the PCI (Peripheral Component Interconnect) local bus standard. Many more support the PCI Express (Peripheral Component Interconnect Express) local bus standard. No matther which flavour of PCI is in use, the pci interface is the way to utilize them.
The Interface and its Functions
Expansion Library contains the "pci" interface. Therefore, you must first open Expansion Library and then obtain the pci interface in order to access the methods. The "pci" interface has methods to find a specific device or allocate resource ranges for a device that has not been configured yet.
Device addressing is done entirely through an abstract interface. There is no bus/device/function number. Instead, a device is represented by means of a library-exported interface of type "pci_device", represented by an interface structure PCIDevice.
Device Access
You access a PCI device by first finding it with the FindDevice() function. Once a device has been located a device driver must also lock the device for as long as it is in use.
Obtaining Base Address Registers (BARs)
Each PCI device has a set of up to 6 BARs (Base Address Registers). These can be accessed either by reading from config space, which would involve additional calculation required on the user's side, or by using the GetResourceRange() method of the pci_device. GetResourceRange() returns a read-only pointer to a read-only structure containing information about a specific BAR, including its classification into memory or I/O space, prefetchability, etc. The pointer must be freed with FreeResourceRange() when you are done accessing it.
A common error has crept into many AmigaOS device drivers when using the GetResourceRange() method. The error is rather subtle and only makes a different when the
Here is the correct way to obtain the PCI base address assuming the