intr.h revision 1.1.2.2 1 1.1.2.2 skrll /* $NetBSD: intr.h,v 1.1.2.2 2004/10/19 15:56:37 skrll Exp $ */
2 1.1.2.2 skrll
3 1.1.2.2 skrll /*
4 1.1.2.2 skrll * Copyright (c) 2001, 2003 Wasabi Systems, Inc.
5 1.1.2.2 skrll * All rights reserved.
6 1.1.2.2 skrll *
7 1.1.2.2 skrll * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.1.2.2 skrll *
9 1.1.2.2 skrll * Redistribution and use in source and binary forms, with or without
10 1.1.2.2 skrll * modification, are permitted provided that the following conditions
11 1.1.2.2 skrll * are met:
12 1.1.2.2 skrll * 1. Redistributions of source code must retain the above copyright
13 1.1.2.2 skrll * notice, this list of conditions and the following disclaimer.
14 1.1.2.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.2.2 skrll * notice, this list of conditions and the following disclaimer in the
16 1.1.2.2 skrll * documentation and/or other materials provided with the distribution.
17 1.1.2.2 skrll * 3. All advertising materials mentioning features or use of this software
18 1.1.2.2 skrll * must display the following acknowledgement:
19 1.1.2.2 skrll * This product includes software developed for the NetBSD Project by
20 1.1.2.2 skrll * Wasabi Systems, Inc.
21 1.1.2.2 skrll * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.1.2.2 skrll * or promote products derived from this software without specific prior
23 1.1.2.2 skrll * written permission.
24 1.1.2.2 skrll *
25 1.1.2.2 skrll * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.1.2.2 skrll * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1.2.2 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1.2.2 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.1.2.2 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1.2.2 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1.2.2 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1.2.2 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1.2.2 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1.2.2 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1.2.2 skrll * POSSIBILITY OF SUCH DAMAGE.
36 1.1.2.2 skrll */
37 1.1.2.2 skrll
38 1.1.2.2 skrll #ifndef _IYONIX_INTR_H_
39 1.1.2.2 skrll #define _IYONIX_INTR_H_
40 1.1.2.2 skrll
41 1.1.2.2 skrll #ifdef _KERNEL
42 1.1.2.2 skrll
43 1.1.2.2 skrll /* Interrupt priority "levels". */
44 1.1.2.2 skrll #define IPL_NONE 0 /* nothing */
45 1.1.2.2 skrll #define IPL_SOFT 1 /* generic software interrupts */
46 1.1.2.2 skrll #define IPL_SOFTCLOCK 2 /* software clock interrupt */
47 1.1.2.2 skrll #define IPL_SOFTNET 3 /* software network interrupt */
48 1.1.2.2 skrll #define IPL_BIO 4 /* block I/O */
49 1.1.2.2 skrll #define IPL_NET 5 /* network */
50 1.1.2.2 skrll #define IPL_SOFTSERIAL 6 /* software serial interrupt */
51 1.1.2.2 skrll #define IPL_TTY 7 /* terminals */
52 1.1.2.2 skrll #define IPL_VM 8 /* memory allocation */
53 1.1.2.2 skrll #define IPL_AUDIO 9 /* audio device */
54 1.1.2.2 skrll #define IPL_CLOCK 10 /* clock interrupt */
55 1.1.2.2 skrll #define IPL_STATCLOCK 11 /* statistics clock interrupt */
56 1.1.2.2 skrll #define IPL_HIGH 12 /* everything */
57 1.1.2.2 skrll #define IPL_SERIAL 13 /* serial device */
58 1.1.2.2 skrll
59 1.1.2.2 skrll #define NIPL 14
60 1.1.2.2 skrll
61 1.1.2.2 skrll /* Interrupt sharing types. */
62 1.1.2.2 skrll #define IST_NONE 0 /* none */
63 1.1.2.2 skrll #define IST_PULSE 1 /* pulsed */
64 1.1.2.2 skrll #define IST_EDGE 2 /* edge-triggered */
65 1.1.2.2 skrll #define IST_LEVEL 3 /* level-triggered */
66 1.1.2.2 skrll
67 1.1.2.2 skrll #define IST_LEVEL_LOW IST_LEVEL
68 1.1.2.2 skrll #define IST_LEVEL_HIGH 4
69 1.1.2.2 skrll #define IST_EDGE_FALLING IST_EDGE
70 1.1.2.2 skrll #define IST_EDGE_RISING 5
71 1.1.2.2 skrll #define IST_EDGE_BOTH 6
72 1.1.2.2 skrll
73 1.1.2.2 skrll #define __NEWINTR /* enables new hooks in cpu_fork()/cpu_switch() */
74 1.1.2.2 skrll
75 1.1.2.2 skrll #ifndef _LOCORE
76 1.1.2.2 skrll
77 1.1.2.2 skrll #include <sys/device.h>
78 1.1.2.2 skrll #include <sys/queue.h>
79 1.1.2.2 skrll
80 1.1.2.2 skrll #if defined(_LKM)
81 1.1.2.2 skrll
82 1.1.2.2 skrll int _splraise(int);
83 1.1.2.2 skrll int _spllower(int);
84 1.1.2.2 skrll void splx(int);
85 1.1.2.2 skrll void _setsoftintr(int);
86 1.1.2.2 skrll
87 1.1.2.2 skrll #else /* _LKM */
88 1.1.2.2 skrll
89 1.1.2.2 skrll #include "opt_arm_intr_impl.h"
90 1.1.2.2 skrll
91 1.1.2.2 skrll #if defined(ARM_INTR_IMPL)
92 1.1.2.2 skrll
93 1.1.2.2 skrll /*
94 1.1.2.2 skrll * Each board needs to define the following functions:
95 1.1.2.2 skrll *
96 1.1.2.2 skrll * int _splraise(int);
97 1.1.2.2 skrll * int _spllower(int);
98 1.1.2.2 skrll * void splx(int);
99 1.1.2.2 skrll * void _setsoftintr(int);
100 1.1.2.2 skrll *
101 1.1.2.2 skrll * These may be defined as functions, static __inline functions, or macros,
102 1.1.2.2 skrll * but there must be a _spllower() and splx() defined as functions callable
103 1.1.2.2 skrll * from assembly language (for cpu_switch()). However, since it's quite
104 1.1.2.2 skrll * useful to be able to inline splx(), you could do something like the
105 1.1.2.2 skrll * following:
106 1.1.2.2 skrll *
107 1.1.2.2 skrll * in <boardtype>_intr.h:
108 1.1.2.2 skrll * static __inline int
109 1.1.2.2 skrll * boardtype_splx(int spl)
110 1.1.2.2 skrll * {...}
111 1.1.2.2 skrll *
112 1.1.2.2 skrll * #define splx(nspl) boardtype_splx(nspl)
113 1.1.2.2 skrll * ...
114 1.1.2.2 skrll * and in boardtype's machdep code:
115 1.1.2.2 skrll *
116 1.1.2.2 skrll * ...
117 1.1.2.2 skrll * #undef splx
118 1.1.2.2 skrll * int
119 1.1.2.2 skrll * splx(int spl)
120 1.1.2.2 skrll * {
121 1.1.2.2 skrll * return boardtype_splx(spl);
122 1.1.2.2 skrll * }
123 1.1.2.2 skrll */
124 1.1.2.2 skrll
125 1.1.2.2 skrll #include ARM_INTR_IMPL
126 1.1.2.2 skrll
127 1.1.2.2 skrll #else /* ARM_INTR_IMPL */
128 1.1.2.2 skrll
129 1.1.2.2 skrll #error ARM_INTR_IMPL not defined.
130 1.1.2.2 skrll
131 1.1.2.2 skrll #endif /* ARM_INTR_IMPL */
132 1.1.2.2 skrll
133 1.1.2.2 skrll #endif /* _LKM */
134 1.1.2.2 skrll
135 1.1.2.2 skrll #define splhigh() _splraise(IPL_HIGH)
136 1.1.2.2 skrll #define splsoft() _splraise(IPL_SOFT)
137 1.1.2.2 skrll #define splsoftclock() _splraise(IPL_SOFTCLOCK)
138 1.1.2.2 skrll #define splsoftnet() _splraise(IPL_SOFTNET)
139 1.1.2.2 skrll #define splbio() _splraise(IPL_BIO)
140 1.1.2.2 skrll #define splnet() _splraise(IPL_NET)
141 1.1.2.2 skrll #define spltty() _splraise(IPL_TTY)
142 1.1.2.2 skrll #define splvm() _splraise(IPL_VM)
143 1.1.2.2 skrll #define splaudio() _splraise(IPL_AUDIO)
144 1.1.2.2 skrll #define splclock() _splraise(IPL_CLOCK)
145 1.1.2.2 skrll #define splstatclock() _splraise(IPL_STATCLOCK)
146 1.1.2.2 skrll #define splserial() _splraise(IPL_SERIAL)
147 1.1.2.2 skrll
148 1.1.2.2 skrll #define spl0() _spllower(IPL_NONE)
149 1.1.2.2 skrll #define spllowersoftclock() _spllower(IPL_SOFTCLOCK)
150 1.1.2.2 skrll
151 1.1.2.2 skrll #define splsched() splhigh()
152 1.1.2.2 skrll #define spllock() splhigh()
153 1.1.2.2 skrll
154 1.1.2.2 skrll /* Use generic software interrupt support. */
155 1.1.2.2 skrll #include <arm/softintr.h>
156 1.1.2.2 skrll
157 1.1.2.2 skrll #endif /* ! _LOCORE */
158 1.1.2.2 skrll
159 1.1.2.2 skrll #endif /* _KERNEL */
160 1.1.2.2 skrll
161 1.1.2.2 skrll #endif /* _IYONIX_INTR_H_ */
162