Pci library api, Definitions, Types and data structures – Comtrol eCos User Manual
Page 446: Functions

Chapter 30. The eCos PCI Library
PCI Library API
The PCI library provides the following routines and types for accessing the PCI configuration space.
The API for the PCI library is found in the header file
<
cyg/io/pci.h
>
.
Definitions
The header file contains definitions for the common configuration structure offsets and specimen values for device,
vendor and class code.
Types and data structures
The following types are defined:
typedef CYG_WORD32 cyg_pci_device_id;
This is comprised of the bus number, device number and functional unit numbers packed into a single
word. The macro
CYG_PCI_DEV_MAKE_ID()
, in conjunction with the
CYG_PCI_DEV_MAKE_DEVFN()
macro, may be used to construct a device id from the bus, device and functional unit numbers. Similarly
the
macros
CYG_PCI_DEV_GET_BUS()
,
CYG_PCI_DEV_GET_DEVFN()
,
CYG_PCI_DEV_GET_DEV()
,
and
CYG_PCI_DEV_GET_FN()
may be used to extract the constituent parts of a device id. It should not be necessary to
use these macros under normal circumstances. The following code fragment demonstrates how these macros may
be used:
// Create a packed representation of device 1, function 0
cyg_uint8 devfn = CYG_PCI_DEV_MAKE_DEVFN(1,0);
// Create a packed devid for that device on bus 2
cyg_pci_device_id devid = CYG_PCI_DEV_MAKE_ID(2, devfn);
diag_printf("bus %d, dev %d, func %d\n",
CYG_PCI_DEV_GET_BUS(devid),
CYG_PCI_DEV_GET_DEV(CYG_PCI_DEV_GET_DEVFN(devid)),
CYG_PCI_DEV_GET_FN(CYG_PCI_DEV_GET_DEVFN(devid));
typedef struct cyg_pci_device;
This
structure
is
used
to
contain
data
read
from
a
PCI
device’s
configuration
header
by
cyg_pci_get_device_info()
. It is also used to record the resource allocations made to the device.
typedef CYG_WORD64 CYG_PCI_ADDRESS64;
typedef CYG_WORD32 CYG_PCI_ADDRESS32;
Pointers in the PCI address space are 32 bit (IO space) or 32/64 bit (memory space). In most platform and device
configurations all of PCI memory will be linearly addressable using only 32 bit pointers as read from
base_map[]
.
The 64 bit type is used to allow handling 64 bit devices in the future, should it be necessary, without changing the
library’s API.
342