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