User guide

144 Enhanced OS-9 for X86 PCAT
1
Installing and Configuring Enhanced OS-9
pci_find_device() - find PCI device
Syntax
#include <pcicnfg.h>
error_code pci_find_device(u_int32 vender_id,
u_int32 device_id, u_int32 index,
u_int8 *bus, u_int8 *dev);
State
System
Description
pci_find_device function() will search the PCI bus for a device with the
same ’vendor_id’ and ’device_id’ passed. If the index is nonzero, then
the device found is based on the index. For example, if index is equal to
one, then the second card found with the same vendor_id’ and
device_id’ on a match is returned.
If a PCI device is found then pci_find_device() will return SUCCESS
and the bus number and device number will be stored where the bus
and dev arguments point respectively. The upper three bits of the
device number specify the function number for multi-function devices.
If no PCI device is found the pci_find_device() function will return
NO_DEVICE.
Header Files
MWOS/SRC/DEFS/HW/pcicnfg.h
Example
#include <const.h>
#include <pcicnfg.h>
#include <stdio.h>
#include <stdlib.h>
main()
{
u_int8 bus, dev;
u_int32 index = 0;
if (pci_find_device(PCI_VENDOR_ID_NCR,
PCI_DEVICE_NCR53C810, index, &bus, &dev) == SUCCESS)
{
printf("NCR53C810 found at bus:%d device:%d function:%d\n",
bus, dev & 0x1f, dev >> 5);