Xenomai  3.1
intr.h
1 /*
2  * Copyright (C) 2001,2002,2003 Philippe Gerum <rpm@xenomai.org>.
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 #ifndef _COBALT_KERNEL_INTR_H
20 #define _COBALT_KERNEL_INTR_H
21 
22 #include <linux/spinlock.h>
23 #include <cobalt/kernel/stat.h>
24 
30 /* Possible return values of a handler. */
31 #define XN_IRQ_NONE 0x1
32 #define XN_IRQ_HANDLED 0x2
33 #define XN_IRQ_STATMASK (XN_IRQ_NONE|XN_IRQ_HANDLED)
34 #define XN_IRQ_PROPAGATE 0x100
35 #define XN_IRQ_DISABLE 0x200
36 
37 /* Init flags. */
38 #define XN_IRQTYPE_SHARED 0x1
39 #define XN_IRQTYPE_EDGE 0x2
40 
41 /* Status bits. */
42 #define XN_IRQSTAT_ATTACHED 0
43 #define _XN_IRQSTAT_ATTACHED (1 << XN_IRQSTAT_ATTACHED)
44 #define XN_IRQSTAT_DISABLED 1
45 #define _XN_IRQSTAT_DISABLED (1 << XN_IRQSTAT_DISABLED)
46 
47 struct xnintr;
48 struct xnsched;
49 
50 typedef int (*xnisr_t)(struct xnintr *intr);
51 
52 typedef void (*xniack_t)(unsigned irq, void *arg);
53 
54 struct xnirqstat {
56  xnstat_counter_t hits;
58  xnstat_exectime_t account;
60  xnstat_exectime_t sum;
61 };
62 
63 struct xnintr {
64 #ifdef CONFIG_XENO_OPT_SHIRQ
65 
66  struct xnintr *next;
67 #endif
68 
69  unsigned int unhandled;
71  xnisr_t isr;
73  void *cookie;
75  unsigned long status;
77  int flags;
79  unsigned int irq;
81  xniack_t iack;
83  const char *name;
85  raw_spinlock_t lock;
86 #ifdef CONFIG_XENO_OPT_STATS_IRQS
87 
88  struct xnirqstat *stats;
89 #endif
90 };
91 
92 struct xnintr_iterator {
93  int cpu;
94  unsigned long hits;
95  xnticks_t exectime_period;
96  xnticks_t account_period;
97  xnticks_t exectime_total;
98  int list_rev;
99  struct xnintr *prev;
100 };
101 
102 int xnintr_mount(void);
103 
104 void xnintr_core_clock_handler(void);
105 
106 void xnintr_host_tick(struct xnsched *sched);
107 
108 void xnintr_init_proc(void);
109 
110 void xnintr_cleanup_proc(void);
111 
112  /* Public interface. */
113 
114 int xnintr_init(struct xnintr *intr,
115  const char *name,
116  unsigned irq,
117  xnisr_t isr,
118  xniack_t iack,
119  int flags);
120 
121 void xnintr_destroy(struct xnintr *intr);
122 
123 int xnintr_attach(struct xnintr *intr,
124  void *cookie);
125 
126 void xnintr_detach(struct xnintr *intr);
127 
128 void xnintr_enable(struct xnintr *intr);
129 
130 void xnintr_disable(struct xnintr *intr);
131 
132 void xnintr_affinity(struct xnintr *intr,
133  cpumask_t cpumask);
134 
135 #ifdef CONFIG_XENO_OPT_STATS_IRQS
136 extern struct xnintr nktimer;
137 
138 int xnintr_query_init(struct xnintr_iterator *iterator);
139 
140 int xnintr_get_query_lock(void);
141 
142 void xnintr_put_query_lock(void);
143 
144 int xnintr_query_next(int irq, struct xnintr_iterator *iterator,
145  char *name_buf);
146 
147 #else /* !CONFIG_XENO_OPT_STATS_IRQS */
148 
149 static inline int xnintr_query_init(struct xnintr_iterator *iterator)
150 {
151  return 0;
152 }
153 
154 static inline int xnintr_get_query_lock(void)
155 {
156  return 0;
157 }
158 
159 static inline void xnintr_put_query_lock(void) {}
160 #endif /* !CONFIG_XENO_OPT_STATS_IRQS */
161 
164 #endif /* !_COBALT_KERNEL_INTR_H */
void xnintr_enable(struct xnintr *intr)
Enable an interrupt line.
Definition: intr.c:929
void xnintr_detach(struct xnintr *intr)
Detach an interrupt descriptor.
Definition: intr.c:902
void xnintr_disable(struct xnintr *intr)
Disable an interrupt line.
Definition: intr.c:961
int xnintr_init(struct xnintr *intr, const char *name, unsigned int irq, xnisr_t isr, xniack_t iack, int flags)
Initialize an interrupt descriptor.
Definition: intr.c:769
Scheduling information structure.
Definition: sched.h:58
void xnintr_affinity(struct xnintr *intr, cpumask_t cpumask)
Set processor affinity of interrupt.
Definition: intr.c:1002
int xnintr_attach(struct xnintr *intr, void *cookie)
Attach an interrupt descriptor.
Definition: intr.c:849
void xnintr_destroy(struct xnintr *intr)
Destroy an interrupt descriptor.
Definition: intr.c:810