Xenomai API  2.6.5
intr.h
1 /*
2  * @note Copyright (C) 2001,2002,2003 Philippe Gerum <[email protected]>.
3  *
4  * Xenomai is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  *
9  * Xenomai is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Xenomai; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  *
19  * \ingroup intr
20  */
21 
22 #ifndef _XENO_NUCLEUS_INTR_H
23 #define _XENO_NUCLEUS_INTR_H
24 
25 /* Possible return values of ISR. */
26 #define XN_ISR_NONE 0x1
27 #define XN_ISR_HANDLED 0x2
28 /* Additional bits. */
29 #define XN_ISR_PROPAGATE 0x100
30 #define XN_ISR_NOENABLE 0x200
31 #define XN_ISR_BITMASK (~0xff)
32 
33 /* Creation flags. */
34 #define XN_ISR_SHARED 0x1
35 #define XN_ISR_EDGE 0x2
36 
37 /* Operational flags. */
38 #define XN_ISR_ATTACHED 0x10000
39 
40 #if defined(__KERNEL__) || defined(__XENO_SIM__)
41 
42 #include <nucleus/types.h>
43 #include <nucleus/stat.h>
44 
45 struct xnsched;
46 
47 typedef struct xnintr {
48 
49 #ifdef CONFIG_XENO_OPT_SHIRQ
50  struct xnintr *next; /* !< Next object in the IRQ-sharing chain. */
51 #endif /* CONFIG_XENO_OPT_SHIRQ */
52 
53  unsigned unhandled; /* !< Number of consequent unhandled interrupts */
54 
55  xnisr_t isr; /* !< Interrupt service routine. */
56 
57  void *cookie; /* !< User-defined cookie value. */
58 
59  xnflags_t flags; /* !< Creation flags. */
60 
61  unsigned irq; /* !< IRQ number. */
62 
63  xniack_t iack; /* !< Interrupt acknowledge routine. */
64 
65  const char *name; /* !< Symbolic name. */
66 
67  struct {
68  xnstat_counter_t hits; /* !< Number of handled receipts since attachment. */
69  xnstat_exectime_t account; /* !< Runtime accounting entity */
70  xnstat_exectime_t sum; /* !< Accumulated accounting entity */
71  } stat[XNARCH_NR_CPUS];
72 
73 } xnintr_t;
74 
75 typedef struct xnintr_iterator {
76 
77  int cpu; /* !< Current CPU in iteration. */
78 
79  unsigned long hits; /* !< Current hit counter. */
80 
81  xnticks_t exectime_period; /* !< Used CPU time in current accounting period. */
82 
83  xnticks_t account_period; /* !< Length of accounting period. */
84 
85  xnticks_t exectime_total; /* !< Overall CPU time consumed. */
86 
87  int list_rev; /* !< System-wide xnintr list revision (internal use). */
88 
89  xnintr_t *prev; /* !< Previously visited xnintr object (internal use). */
90 
91 } xnintr_iterator_t;
92 
93 extern xnintr_t nkclock;
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98 
99 int xnintr_mount(void);
100 
101 void xnintr_clock_handler(void);
102 
103 void xnintr_host_tick(struct xnsched *sched);
104 
105 void xnintr_init_proc(void);
106 
107 void xnintr_cleanup_proc(void);
108 
109  /* Public interface. */
110 
111 int xnintr_init(xnintr_t *intr,
112  const char *name,
113  unsigned irq,
114  xnisr_t isr,
115  xniack_t iack,
116  xnflags_t flags);
117 
118 int xnintr_destroy(xnintr_t *intr);
119 
120 int xnintr_attach(xnintr_t *intr,
121  void *cookie);
122 
123 int xnintr_detach(xnintr_t *intr);
124 
125 int xnintr_enable(xnintr_t *intr);
126 
127 int xnintr_disable(xnintr_t *intr);
128 
129 void xnintr_affinity(xnintr_t *intr,
130  xnarch_cpumask_t cpumask);
131 
132 int xnintr_query_init(xnintr_iterator_t *iterator);
133 
134 int xnintr_query_next(int irq, xnintr_iterator_t *iterator,
135  char *name_buf);
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif /* __KERNEL__ || __XENO_SIM__ */
142 
143 #endif /* !_XENO_NUCLEUS_INTR_H */
int xnintr_enable(xnintr_t *intr)
Enable an interrupt object.
Definition: intr.c:833
Scheduling information structure.
Definition: sched.h:66
int xnintr_init(xnintr_t *intr, const char *name, unsigned irq, xnisr_t isr, xniack_t iack, xnflags_t flags)
Initialize an interrupt object.
Definition: intr.c:620
int xnintr_disable(xnintr_t *intr)
Disable an interrupt object.
Definition: intr.c:865
int xnintr_attach(xnintr_t *intr, void *cookie)
Attach an interrupt object.
Definition: intr.c:714
int xnintr_detach(xnintr_t *intr)
Detach an interrupt object.
Definition: intr.c:780
int xnintr_destroy(xnintr_t *intr)
Destroy an interrupt object.
Definition: intr.c:669
void xnintr_affinity(xnintr_t *intr, xnarch_cpumask_t cpumask)
Set interrupt's processor affinity.
Definition: intr.c:892