
Applied Micro Circuits Corporation
6195 Lusk Blvd., San Diego, CA 92121 (619) 450-9333
15-55
PCI CONTROLLER
S5933
The second output parameter, device_and_function,
indicates the Device Number in the upper 5 bits and
the Function Number in the lower 3 bits. The
bus_number and device_and_function values re-
turned from this function must be used to access the
PCI device via the PCI BIOS function calls.
Putting It All Together
Code Segment 1 determines if the PCI BIOS is
present and, if so, determines if a PCI device with
AMCC’s Vendor ID and a Device ID of zero exists.
An appropriate message is displayed at each stage
of the program fragment.
Note that the fragment shows NULL pointers as pa-
rameters to the pci_bios_present function. Each of
the functions in the library has the feature of allowing
a NULL pointer to be passed, indicating that the pa-
rameter is not needed and therefore is not assigned
to any variable.
For specific sub-class codes and register-level pro-
gramming interfaces, see PCI LOCAL BUS SPECI-
FICATION (or Section 3.6 of this manual).
The final input parameter, index, is a number in the
range 0 to N indicating which device of a specific
class code to be found. For example, if there are two
devices with the same Class Code, an index value of
zero would locate the first device and an index value
of one would locate the second value. An index value
of two returns a code of DEVICE_NOT_FOUND.
The first output parameter, bus_number, is a number
in the range 0 to 255 indicating which PCI bus the
device is located on.
int bios_present;
/* TRUE if PCI BIOS found */
byte bus;
/* Bus number of device */
byte device_and_function;
/* Device Number bits 7-3, Function bits 2-0 */
/* Determine if PCI BIOS present */
if (pci_bios_present(NULL, NULL, NULL) == SUCCESSFUL) {
bios_present = TRUE;
}
else {
printf(“PCI BIOS not present\n”);
bios_present = FALSE;
}
if (bios_present) {
/* Locate AMCC Vendor ID and Device ID of 0 */
if (find_pci_device(0,0x10e8,0,&bus,&device_and_function) == SUCCESSFUL) {
printf(“AMCC Device found: bus = %d device = %d function = %d\n”,
bus, (device_and_function >> 3), (device_and_function & 0x7));
}
else {
printf(“Device not found!!!\n”);
}
Code Segment 1