
Applied Micro Circuits Corporation
6195 Lusk Blvd., San Diego, CA 92121 (619) 450-9333
15-56
S5933
PCI CONTROLLER
Access to Configuration Space
Each PCI device contains an address space specifi-
cally devoted to PCI buses, used for device identifi-
cation and memory and I/O configuration. A set of six
functions provides access to the PCI device’s Con-
figuration Space. These functions provide for reading
and writing of a byte (8 bits), double-word (16 bits) or
double-word (32 bits) in the Configuration Space. C-
language prototypes for these functions are:
int read_configuration_byte(byte bus_number,
byte device_and_function,
byte register_number,
byte *byte_read);
int read_configuration_word(byte bus_number,
byte device_and_function,
byte register_number,
word *word_read);
int read_configuration_dword(byte bus_number,
byte device_and_function,
byte register_number,
dword *dword_read);
int write_configuration_byte(byte bus_number,
byte device_and_function,
byte register_number,
byte byte_to_write);
int write_configuration_word(byte bus_number,
byte device_and_function,
byte register_number,
word word_to_write);
int write_configuration_dword(byte bus_number,
byte device_and_function,
byte register_number,
dword dword_to_write);
The return code from each of these functions indi-
cates whether the Configuration Space was read or
written successfully, indicated by the return value of
SUCCESSFUL. The function may also return the
value BAD_REGISTER_NUMBER, indicating that a
register number greater than 255 was requested to
be read or written. Finally, a return value of
NOT_SUCCESSFUL indicates a PCI BIOS error has
occurred.
Each of these functions has input parameters of
bus_number and device_and_function. These pa-
rameters MUST be the values returned by the
find_pci_bios() or find_pci_class_code() functions for
the desired device.
Also, each of the functions has an input parameter of
register_number. This number is a number in the
range 0 to 255 indicating which register in the Con-
figuration Space is to be read or written. The pre-
defined register numbers are described in the
Configuration Space section of this appendix.
The read_configuration_byte/word/dword functions
have an output parameter that contains the byte/
word/dword read from the Configuration Space.
As an example, register 0 contains the Vendor ID of
the device and is one word (16 bits) long. To obtain
the Vendor ID from the device, simply use the follow-
ing function call:
The return value from the function MUST be checked
for the value SUCCESSFUL prior to using the
vendor_id value, otherwise the value is invalid.
Obtaining Interrupt Vector
The Interrupt Line Configuration Space register con-
tains the hardware interrupt assigned to the device
by the host computer (if needed). The valid number
in this register is in the range 0 to 15. A value of FFh
indicates that no hardware interrupt is needed by the
device. Multiple devices may be assigned to a single
hardware interrupt by the host computer. Device driv-
ers for PCI devices must determine if the device it is
servicing generated the interrupt and if not, “chain” or
call the previous interrupt handler to handle the inter-
rupt.
The hardware interrupt number can be translated into
a software interrupt number via the following table:
#define PCI_CS_VENDOR_ID 0
int read_configuration_word(bus_number, device_and_function,
PCI_CS_VENDOR_ID, &vendor_id);
Hardware Interrupt
Interrupt Number
IRQ0
08h
IRQ1
09h
IRQ2
0Ah
IRQ3
0Bh
IRQ4
0Ch
IRQ5
0Dh
IRQ6
0Eh
IRQ7
0Fh
IRQ8
70h
IRQ9
71h
IRQ10
72h
IRQ11
73h
IRQ12
74h
IRQ13
75h
IRQ14
76h
IRQ15
77h