1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/* PCI IRQ Library
*
* 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.org/license/LICENSE.
*/
/* IRQ handling does not have so much with PCI to do, this library depends
* on the BSP to implement shared interrupts.
*/
#ifndef __PCI_IRQ_H__
#define __PCI_IRQ_H__
#include <bsp.h>
#include <rtems/irq-extension.h>
#include <rtems/score/basedefs.h>
/* PCI Handler (ISR) called when IRQ is generated by any of the PCI devices
* connected to the same PCI IRQ Pin. This has 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
*/
RTEMS_INLINE_ROUTINE 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
*/
RTEMS_INLINE_ROUTINE 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
*/
RTEMS_INLINE_ROUTINE 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
*/
RTEMS_INLINE_ROUTINE 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
*/
RTEMS_INLINE_ROUTINE void pci_interrupt_clear(int irq)
{
BSP_PCI_shared_interrupt_clear(irq);
}
#endif /* !__PCI_IRQ_H__ */
|