Interrupts, Activating a device – Comtrol eCos User Manual

Page 444

Advertising
background image

Chapter 30. The eCos PCI Library

cyg_bool cyg_pci_allocate_io(

cyg_pci_device *dev_info,

cyg_uint32 bar,

CYG_PCI_ADDRESS32 *base );

The memory bases (in two distinct address spaces) are increased as memory regions are allocated to devices.
Allocation will fail (the function returns false) if the base exceeds the limits of the address space (IO is 1MB,
memory is 2^32 or 2^64 bytes).

These functions can also be called directly by the application/driver if necessary, but this should not be necessary.

The bases are initialized with default values provided by the HAL. It is possible for an application to override these
using the following functions:

void cyg_pci_set_memory_base(

CYG_PCI_ADDRESS64 base );

void cyg_pci_set_io_base( CYG_PCI_ADDRESS32 base );

When a device has been configured, the cyg_pci_device structure will contain the physical address in the CPU’s
address space where the device’s memory regions can be accessed.

This information is provided in

base_map[]

- there is a 32 bit word for each of the device’s BARs. For 32 bit PCI

memory regions, each 32 bit word will be an actual pointer that can be used immediately by the driver: the memory
space will normally be linearly addressable by the CPU.

However, for 64 bit PCI memory regions, some (or all) of the region may be outside of the CPUs address space. In
this case the driver will need to know how to access the region in segments. This functionality may be adopted by
the eCos HAL if deemed useful in the future. The 2GB available on many systems should suffice though.

Interrupts

A device may generate interrupts. The HAL vector associated with a given device on the bus is platform specific.
This function allows a driver to find the actual interrupt vector for a given device:

cyg_bool cyg_pci_translate_interrupt(

cyg_pci_device *dev_info,

CYG_ADDRWORD *vec );

If the function returns false, no interrupts will be generated by the device. If it returns true, the CYG_ADDRWORD
pointed to by vec is updated with the HAL interrupt vector the device will be using. This is how the function is
used in the

pci1

test:

if (cyg_pci_translate_interrupt(&dev_info, &irq))

diag_printf(" Wired to HAL vector %d\n", irq);

else

diag_printf(" Does not generate interrupts.\n");

The application/drive should attach an interrupt handler to a device’s interrupt before activating the device.

Activating a device

When the device has been allocated memory space it can be activated. This is not done by the library since a driver
may have to initialize more state on the device before it can be safely activated.

340

Advertising