Resource allocation – Comtrol eCos User Manual

Page 448

Advertising
background image

Chapter 30. The eCos PCI Library

device’s configuration space. If the device has not been enabled, then this function will also fetch the size and type
information from the base address registers and place it in the

base_size[]

array.

void cyg_pci_set_device_info ( cyg_pci_device_id devid,

cyg_pci_device *dev_info );

This function sets the PCI configuration information for the device indicated in

devid

. Only the configuration

space registers that are writable are actually written. Once all the fields have been written, the device info will be
read back into

*dev_info

, so that it reflects the true state of the hardware.

void cyg_pci_read_config_uint8(

cyg_pci_device_id devid,

cyg_uint8 offset, cyg_uint8 *val );

void cyg_pci_read_config_uint16( cyg_pci_device_id devid,

cyg_uint8 offset, cyg_uint16 *val );

void cyg_pci_read_config_uint32( cyg_pci_device_id devid,

cyg_uint8 offset, cyg_uint32 *val );

These functions read registers of the appropriate size from the configuration space of the given device. They
should mainly be used to access registers that are device specific. General PCI registers are best accessed through

cyg_pci_get_device_info()

.

void cyg_pci_write_config_uint8(

cyg_pci_device_id devid,

cyg_uint8 offset, cyg_uint8 val );

void cyg_pci_write_config_uint16( cyg_pci_device_id devid,

cyg_uint8 offset, cyg_uint16 val );

void cyg_pci_write_config_uint32( cyg_pci_device_id devid,

cyg_uint8 offset, cyg_uint32 val );

These functions write registers of the appropriate size to the configuration space of the given device. They
should mainly be used to access registers that are device specific. General PCI registers are best accessed
through

cyg_pci_get_device_info()

. Writing the general registers this way may render the contents of a

cyg_pci_device structure invalid.

Resource allocation

These routines allocate memory and I/O space to PCI devices.

cyg_bool cyg_pci_configure_device( cyg_pci_device *dev_info )

Allocate memory and IO space to all base address registers using the current memory and IO base addresses
in the library. The allocated base addresses, translated into directly usable values, will be put into the matching

base_map[]

entries in

*dev_info

. If

*dev_info

does not contain valid

base_size[]

entries, then the result

is

false

. This function will also call

cyg_pci_translate_interrupt()

to put the interrupt vector into the HAL

vector entry.

cyg_bool cyg_pci_configure_bus( cyg_uint8 bus, cyg_uint8 *next_bus )

Allocate memory and IO space to all base address registers on all devices on the given bus and all subordinate
busses. If a PCI-PCI bridge is found on

bus

, this function will call itself recursively in order to configure the bus

on the other side of the bridge. Because of the nature of bridge devices, all devices on the secondary side of a bridge
must be allocated memory and IO space before the memory and IO windows on the bridge device can be properly
configured. The

next_bus

argument points to the bus number to assign to the next subordinate bus found. The

344

Advertising