Chapter 30. the ecos pci library, Pci library, Pci overview – Comtrol eCos User Manual

Page 441: Initializing the bus, The ecos pci library, Scanning for devices

Advertising
background image

Chapter 30. The eCos PCI Library

The PCI library is an optional part of eCos, and is only applicable to some platforms.

PCI Library

The eCos PCI library provides the following functionality:

1. Scan the PCI bus for specific devices or devices of a certain class.

2. Read and change generic PCI information.

3. Read and change device-specific PCI information.

4. Allocate PCI memory and IO space to devices.

5. Translate a device’s PCI interrupts to equivalent HAL vectors.

Example code fragments are from the pci1 test (see

io/pci/

<

release

>

/tests/pci1.c

).

All of the functions described below are declared in the header file

<

cyg/io/pci.h

>

which all clients of the PCI

library should include.

PCI Overview

The PCI bus supports several address spaces: memory, IO, and configuration. All PCI devices must support manda-
tory configuration space registers. Some devices may also present IO mapped and/or memory mapped resources.
Before devices on the bus can be used, they must be configured. Basically, configuration will assign PCI IO and/or
memory address ranges to each device and then enable that device. All PCI devices have a unique address in con-
figuration space. This address is comprised of a bus number, a device number, and a function number. Special
devices called bridges are used to connect two PCI busses together. The PCI standard supports up to 255 busses
with each bus having up to 32 devices and each device having up to 8 functions.

The environment in which a platform operates will dictate if and how eCos should configure devices on the PCI
bus. If the platform acts as a host on a single PCI bus, then devices may be configured individually from the relevant
device driver. If the platform is not the primary host, such as a PCI card plugged into a PC, configuration of PCI
devices may be left to the PC BIOS. If PCI-PCI bridges are involved, configuration of all devices is best done all
at once early in the boot process. This is because all devices on the secondary side of a bridge must be evaluated
for their IO and memory space requirements before the bridge can be configured.

Initializing the bus

The PCI bus needs to be initialized before it can be used. This only needs to be done once - some HALs may do it
as part of the platform initialization procedure, other HALs may leave it to the application or device drivers to do
it. The following function will do the initialization only once, so it’s safe to call from multiple drivers:

void cyg_pci_init( void );

337

Advertising