RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
irq.h
1/* PCI IRQ Library
2 *
3 * COPYRIGHT (c) 2010 Cobham Gaisler AB.
4 *
5 * The license and distribution terms for this file may be
6 * found in the file LICENSE in this distribution or at
7 * http://www.rtems.org/license/LICENSE.
8 */
9
10/* IRQ handling does not have so much with PCI to do, this library depends
11 * on the BSP to implement shared interrupts.
12 */
13
14#ifndef __PCI_IRQ_H__
15#define __PCI_IRQ_H__
16
17#include <rtems/irq-extension.h>
19
20/*
21 * FIXME: This should be available via the IRQ extensions API.
22 *
23 * https://devel.rtems.org/ticket/3269
24 */
25void BSP_shared_interrupt_clear(int irq);
26void BSP_shared_interrupt_unmask(int irq);
27void BSP_shared_interrupt_mask(int irq);
28
29/* PCI Handler (ISR) called when IRQ is generated by any of the PCI devices
30 * connected to the same PCI IRQ Pin. This has been defined the same way as
31 * rtems_interrupt_handler in order for BSPs to "direct-map" the register
32 * and unregister functions rtems_interrupt_handler_install/remove
33 */
34typedef void (*pci_isr)(void *arg);
35
36/* Get assigned system IRQ to a PCI Device. If no IRQ 0 is returned */
37extern int pci_dev_irq(pci_dev_t dev);
38
39/* Register shared PCI IRQ handler, but does not enable it. The system interrupt
40 * number is read from the PCI board's PCI configuration space header iline
41 * field. The iline field is initialized by the PCI subsystem during start up,
42 * the ipin field is translated into a system IRQ and written to iline. The
43 * board's driver should use the iline field as the irq argument to this
44 * function.
45 *
46 * Arguments
47 * irq System IRQ number, normally taken from the PCI configuration area
48 * isr Function pointer to the ISR
49 * arg Second argument to function isr
50 */
51RTEMS_INLINE_ROUTINE int pci_interrupt_register(int irq, const char *info,
52 pci_isr isr, void *arg)
53{
54 return rtems_interrupt_handler_install(irq, info,
56 arg);
57}
58
59/* Unregister previously registered shared PCI IRQ handler
60 *
61 * Arguments
62 * irq System IRQ number, normally taken from the PCI configuration area
63 * isr Function pointer to the ISR
64 * arg Second argument to function isr
65 */
66RTEMS_INLINE_ROUTINE int pci_interrupt_unregister(int irq, pci_isr isr,
67 void *arg)
68{
69 return rtems_interrupt_handler_remove(irq, isr, arg);
70}
71
72/* Enable shared PCI IRQ handler. This function will unmask the interrupt
73 * controller and mark this interrupt handler ready to handle interrupts. Note
74 * that since it is a shared interrupt handler service the interrupt may
75 * already be enabled, however no calls to this specific handler is made
76 * until it is enabled.
77 *
78 * Arguments
79 * irq System IRQ number, normally taken from the PCI configuration area
80 * isr Function pointer to the ISR
81 * arg Second argument to function isr
82 */
83RTEMS_INLINE_ROUTINE void pci_interrupt_unmask(int irq)
84{
85 BSP_shared_interrupt_unmask(irq);
86}
87
88/* Disable shared PCI IRQ handler. This function will mask the interrupt
89 * controller and mark this interrupt handler not ready to receive interrupts.
90 * Note that since it is a shared interrupt handler service the interrupt may
91 * still be enabled, however no calls to this specific handler is made
92 * while it is disabled.
93 *
94 * Arguments
95 * irq System IRQ number, normally taken from the PCI configuration area
96 * isr Function pointer to the ISR
97 * arg Second argument to function isr
98 */
99RTEMS_INLINE_ROUTINE void pci_interrupt_mask(int irq)
100{
101 BSP_shared_interrupt_mask(irq);
102}
103
104/* Acknowledge the interrupt controller by writing to the interrupt controller.
105 * Note that since it is a shared interrupt handler service, clearing the
106 * interrupt source may affect other ISRs registered to this IRQ.
107 *
108 * Arguments
109 * irq System IRQ number, normally taken from the PCI configuration area
110 * isr Function pointer to the ISR
111 * arg Second argument to function isr
112 */
113RTEMS_INLINE_ROUTINE void pci_interrupt_clear(int irq)
114{
115 BSP_shared_interrupt_clear(irq);
116}
117
118#endif /* !__PCI_IRQ_H__ */
Basic Definitions.
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
rtems_status_code rtems_interrupt_handler_install(rtems_vector_number vector, const char *info, rtems_option options, rtems_interrupt_handler handler, void *arg)
Installs the interrupt handler routine handler for the interrupt vector with number vector.
Definition: irq.c:127
#define RTEMS_INTERRUPT_SHARED
Allows that this interrupt handler may share a common interrupt vector with other handler.
Definition: irq-extension.h:50
rtems_status_code rtems_interrupt_handler_remove(rtems_vector_number vector, rtems_interrupt_handler handler, void *arg)
Removes the interrupt handler routine handler with argument arg for the interrupt vector with number ...
Definition: irq.c:175
Header file for the Interrupt Manager Extension.