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.com/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 <bsp.h> |
---|
18 | #include <rtems/irq-extension.h> |
---|
19 | #include <rtems/score/basedefs.h> |
---|
20 | |
---|
21 | /* PCI Handler (ISR) called when IRQ is generated by any of the PCI devices |
---|
22 | * connected to the same PCI IRQ Pin. This has been defined the same way as |
---|
23 | * rtems_interrupt_handler in order for BSPs to "direct-map" the register |
---|
24 | * and unregister functions rtems_interrupt_handler_install/remove |
---|
25 | */ |
---|
26 | typedef void (*pci_isr)(void *arg); |
---|
27 | |
---|
28 | /* Get assigned system IRQ to a PCI Device. If no IRQ 0 is returned */ |
---|
29 | extern int pci_dev_irq(pci_dev_t dev); |
---|
30 | |
---|
31 | /* Register shared PCI IRQ handler, but does not enable it. The system interrupt |
---|
32 | * number is read from the PCI board's PCI configuration space header iline |
---|
33 | * field. The iline field is initialized by the PCI subsystem during start up, |
---|
34 | * the ipin field is translated into a system IRQ and written to iline. The |
---|
35 | * board's driver should use the iline field as the irq argument to this |
---|
36 | * function. |
---|
37 | * |
---|
38 | * Arguments |
---|
39 | * irq System IRQ number, normally taken from the PCI configuration area |
---|
40 | * isr Function pointer to the ISR |
---|
41 | * arg Second argument to function isr |
---|
42 | */ |
---|
43 | RTEMS_INLINE_ROUTINE int pci_interrupt_register(int irq, const char *info, |
---|
44 | pci_isr isr, void *arg) |
---|
45 | { |
---|
46 | return BSP_PCI_shared_interrupt_register(irq, info, isr, arg); |
---|
47 | } |
---|
48 | |
---|
49 | /* Unregister previously registered shared PCI IRQ handler |
---|
50 | * |
---|
51 | * Arguments |
---|
52 | * irq System IRQ number, normally taken from the PCI configuration area |
---|
53 | * isr Function pointer to the ISR |
---|
54 | * arg Second argument to function isr |
---|
55 | */ |
---|
56 | RTEMS_INLINE_ROUTINE int pci_interrupt_unregister(int irq, pci_isr isr, |
---|
57 | void *arg) |
---|
58 | { |
---|
59 | return BSP_PCI_shared_interrupt_unregister(irq, isr, arg); |
---|
60 | } |
---|
61 | |
---|
62 | /* Enable shared PCI IRQ handler. This function will unmask the interrupt |
---|
63 | * controller and mark this interrupt handler ready to handle interrupts. Note |
---|
64 | * that since it is a shared interrupt handler service the interrupt may |
---|
65 | * already be enabled, however no calls to this specific handler is made |
---|
66 | * until it is enabled. |
---|
67 | * |
---|
68 | * Arguments |
---|
69 | * irq System IRQ number, normally taken from the PCI configuration area |
---|
70 | * isr Function pointer to the ISR |
---|
71 | * arg Second argument to function isr |
---|
72 | */ |
---|
73 | RTEMS_INLINE_ROUTINE void pci_interrupt_unmask(int irq) |
---|
74 | { |
---|
75 | BSP_PCI_shared_interrupt_unmask(irq); |
---|
76 | } |
---|
77 | |
---|
78 | /* Disable shared PCI IRQ handler. This function will mask the interrupt |
---|
79 | * controller and mark this interrupt handler not ready to receive interrupts. |
---|
80 | * Note that since it is a shared interrupt handler service the interrupt may |
---|
81 | * still be enabled, however no calls to this specific handler is made |
---|
82 | * while it is disabled. |
---|
83 | * |
---|
84 | * Arguments |
---|
85 | * irq System IRQ number, normally taken from the PCI configuration area |
---|
86 | * isr Function pointer to the ISR |
---|
87 | * arg Second argument to function isr |
---|
88 | */ |
---|
89 | RTEMS_INLINE_ROUTINE void pci_interrupt_mask(int irq) |
---|
90 | { |
---|
91 | BSP_PCI_shared_interrupt_mask(irq); |
---|
92 | } |
---|
93 | |
---|
94 | /* Acknowledge the interrupt controller by writing to the interrupt controller. |
---|
95 | * Note that since it is a shared interrupt handler service, clearing the |
---|
96 | * interrupt source may affect other ISRs registered to this IRQ. |
---|
97 | * |
---|
98 | * Arguments |
---|
99 | * irq System IRQ number, normally taken from the PCI configuration area |
---|
100 | * isr Function pointer to the ISR |
---|
101 | * arg Second argument to function isr |
---|
102 | */ |
---|
103 | RTEMS_INLINE_ROUTINE void pci_interrupt_clear(int irq) |
---|
104 | { |
---|
105 | BSP_PCI_shared_interrupt_clear(irq); |
---|
106 | } |
---|
107 | |
---|
108 | #endif /* !__PCI_IRQ_H__ */ |
---|