diff options
author | Daniel Hellstrom <daniel@gaisler.com> | 2011-11-28 10:11:10 +0100 |
---|---|---|
committer | Daniel Hellstrom <daniel@gaisler.com> | 2015-04-17 01:10:15 +0200 |
commit | a31845f7f9b4770cf9ddd8b6820641d2f4f4c1da (patch) | |
tree | 0d7f215ec45d7c4cf6f1293af72ece2fbde1ddc3 /cpukit/libpci/pci/irq.h | |
parent | leon3,ngmp: simplify cpucounter initialization (diff) | |
download | rtems-a31845f7f9b4770cf9ddd8b6820641d2f4f4c1da.tar.bz2 |
LIBPCI: added PCI layer to cpukit/libpci
Diffstat (limited to '')
-rw-r--r-- | cpukit/libpci/pci/irq.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/cpukit/libpci/pci/irq.h b/cpukit/libpci/pci/irq.h new file mode 100644 index 0000000000..2dacadf4c4 --- /dev/null +++ b/cpukit/libpci/pci/irq.h @@ -0,0 +1,105 @@ +/* PCI IRQ Library + * + * IRQ handling does not have so much with PCI to do, this library depends + * on the BSP to implement shared interrupts. + * + * COPYRIGHT (c) 2010. + * Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifndef __PCI_IRQ_H__ +#define __PCI_IRQ_H__ + +#include <bsp.h> + +/* PCI Handler (ISR) called when IRQ is generated by any of the PCI devices + * connected to the same PCI IRQ Pin. This is been defined the same way as + * rtems_interrupt_handler in order for BSPs to "direct-map" the register + * and unregister functions rtems_interrupt_handler_install/remove + */ +typedef void (*pci_isr)(void *arg); + +/* Get assigned system IRQ to a PCI Device. If no IRQ 0 is returned */ +extern int pci_dev_irq(pci_dev_t dev); + +/* Register shared PCI IRQ handler, but does not enable it. The system interrupt + * number is read from the PCI board's PCI configuration space header iline + * field. The iline field is initialized by the PCI subsystem during start up, + * the ipin field is translated into a system IRQ and written to iline. The + * board's driver should use the iline field as the irq argument to this + * function. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +static inline int pci_interrupt_register(int irq, const char *info, + pci_isr isr, void *arg) +{ + return BSP_PCI_shared_interrupt_register(irq, info, isr, arg); +} + +/* Unregister previously registered shared PCI IRQ handler + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +static inline int pci_interrupt_unregister(int irq, pci_isr isr, void *arg) +{ + return BSP_PCI_shared_interrupt_unregister(irq, isr, arg); +} + +/* Enable shared PCI IRQ handler. This function will unmask the interrupt + * controller and mark this interrupt handler ready to handle interrupts. Note + * that since it is a shared interrupt handler service the interrupt may + * already be enabled, however no calls to this specific handler is made + * until it is enabled. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +static inline void pci_interrupt_unmask(int irq) +{ + BSP_PCI_shared_interrupt_unmask(irq); +} + +/* Disable shared PCI IRQ handler. This function will mask the interrupt + * controller and mark this interrupt handler not ready to receive interrupts. + * Note that since it is a shared interrupt handler service the interrupt may + * still be enabled, however no calls to this specific handler is made + * while it is disabled. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +static inline void pci_interrupt_mask(int irq) +{ + BSP_PCI_shared_interrupt_mask(irq); +} + +/* Acknowledge the interrupt controller by writing to the interrupt controller. + * Note that since it is a shared interrupt handler service, clearing the + * interrupt source may affect other ISRs registered to this IRQ. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +static inline void pci_interrupt_clear(int irq) +{ + BSP_PCI_shared_interrupt_clear(irq); +} + +#endif /* !__PCI_IRQ_H__ */ |