intr.h revision 1.14 1 1.14 tsutsui /* $NetBSD: intr.h,v 1.14 2003/10/25 04:07:28 tsutsui Exp $ */
2 1.1 tsubai
3 1.13 tsutsui /*-
4 1.13 tsutsui * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 1.13 tsutsui * All rights reserved.
6 1.13 tsutsui *
7 1.13 tsutsui * This code is derived from software contributed to The NetBSD Foundation
8 1.13 tsutsui * by Jason R. Thorpe.
9 1.1 tsubai *
10 1.1 tsubai * Redistribution and use in source and binary forms, with or without
11 1.1 tsubai * modification, are permitted provided that the following conditions
12 1.1 tsubai * are met:
13 1.1 tsubai * 1. Redistributions of source code must retain the above copyright
14 1.1 tsubai * notice, this list of conditions and the following disclaimer.
15 1.1 tsubai * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 tsubai * notice, this list of conditions and the following disclaimer in the
17 1.1 tsubai * documentation and/or other materials provided with the distribution.
18 1.1 tsubai * 3. All advertising materials mentioning features or use of this software
19 1.1 tsubai * must display the following acknowledgement:
20 1.13 tsutsui * This product includes software developed by the NetBSD
21 1.13 tsutsui * Foundation, Inc. and its contributors.
22 1.13 tsutsui * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.13 tsutsui * contributors may be used to endorse or promote products derived
24 1.13 tsutsui * from this software without specific prior written permission.
25 1.1 tsubai *
26 1.13 tsutsui * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.13 tsutsui * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.13 tsutsui * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.13 tsutsui * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.13 tsutsui * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.13 tsutsui * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.13 tsutsui * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.13 tsutsui * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.13 tsutsui * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.13 tsutsui * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.13 tsutsui * POSSIBILITY OF SUCH DAMAGE.
37 1.1 tsubai */
38 1.1 tsubai
39 1.1 tsubai #ifndef _MACHINE_INTR_H_
40 1.1 tsubai #define _MACHINE_INTR_H_
41 1.1 tsubai
42 1.4 tsubai #define IPL_NONE 0 /* disable only this interrupt */
43 1.13 tsutsui
44 1.13 tsutsui #define IPL_SOFT 1 /* generic software interrupts (SI 0) */
45 1.13 tsutsui #define IPL_SOFTCLOCK 2 /* clock software interrupts (SI 0) */
46 1.13 tsutsui #define IPL_SOFTNET 3 /* network software interrupts (SI 1) */
47 1.13 tsutsui #define IPL_SOFTSERIAL 4 /* serial software interrupts (SI 1) */
48 1.13 tsutsui
49 1.13 tsutsui #define IPL_BIO 5 /* disable block I/O interrupts */
50 1.13 tsutsui #define IPL_NET 6 /* disable network interrupts */
51 1.13 tsutsui #define IPL_TTY 7 /* disable terminal interrupts */
52 1.13 tsutsui #define IPL_SERIAL 7 /* disable serial hardware interrupts */
53 1.13 tsutsui #define IPL_CLOCK 8 /* disable clock interrupts */
54 1.13 tsutsui #define IPL_STATCLOCK 8 /* disable profiling interrupts */
55 1.13 tsutsui #define IPL_HIGH 8 /* disable all interrupts */
56 1.13 tsutsui
57 1.13 tsutsui #define _IPL_NSOFT 4
58 1.13 tsutsui #define _IPL_N 9
59 1.13 tsutsui
60 1.13 tsutsui #define _IPL_SI0_FIRST IPL_SOFT
61 1.13 tsutsui #define _IPL_SI0_LAST IPL_SOFTCLOCK
62 1.13 tsutsui
63 1.13 tsutsui #define _IPL_SI1_FIRST IPL_SOFTNET
64 1.13 tsutsui #define _IPL_SI1_LAST IPL_SOFTSERIAL
65 1.13 tsutsui
66 1.13 tsutsui #define IPL_SOFTNAMES { \
67 1.13 tsutsui "misc", \
68 1.13 tsutsui "clock", \
69 1.13 tsutsui "net", \
70 1.13 tsutsui "serial", \
71 1.13 tsutsui }
72 1.2 tsubai
73 1.4 tsubai #ifdef _KERNEL
74 1.2 tsubai #ifndef _LOCORE
75 1.13 tsutsui
76 1.12 tsutsui #include <sys/device.h>
77 1.13 tsutsui
78 1.13 tsutsui extern const u_int32_t ipl_sr_bits[_IPL_N];
79 1.2 tsubai
80 1.4 tsubai extern int _splraise __P((int));
81 1.4 tsubai extern int _spllower __P((int));
82 1.4 tsubai extern int _splset __P((int));
83 1.4 tsubai extern int _splget __P((void));
84 1.4 tsubai extern void _splnone __P((void));
85 1.4 tsubai extern void _setsoftintr __P((int));
86 1.4 tsubai extern void _clrsoftintr __P((int));
87 1.4 tsubai
88 1.13 tsutsui #define splhigh() _splraise(ipl_sr_bits[IPL_HIGH])
89 1.4 tsubai #define spl0() (void)_spllower(0)
90 1.4 tsubai #define splx(s) (void)_splset(s)
91 1.13 tsutsui #define splbio() _splraise(ipl_sr_bits[IPL_BIO])
92 1.13 tsutsui #define splnet() _splraise(ipl_sr_bits[IPL_NET])
93 1.13 tsutsui #define spltty() _splraise(ipl_sr_bits[IPL_TTY])
94 1.13 tsutsui #define splserial() _splraise(ipl_sr_bits[IPL_SERIAL])
95 1.13 tsutsui #define splvm() spltty()
96 1.13 tsutsui #define splclock() _splraise(ipl_sr_bits[IPL_CLOCK])
97 1.13 tsutsui #define splstatclock() splclock()
98 1.13 tsutsui
99 1.13 tsutsui #define splsched() splclock()
100 1.13 tsutsui #define spllock() splhigh()
101 1.13 tsutsui
102 1.13 tsutsui #define splsoft() _splraise(ipl_sr_bits[IPL_SOFT])
103 1.13 tsutsui #define splsoftclock() _splraise(ipl_sr_bits[IPL_SOFTCLOCK])
104 1.13 tsutsui #define splsoftnet() _splraise(ipl_sr_bits[IPL_SOFTNET])
105 1.13 tsutsui #define splsoftserial() _splraise(ipl_sr_bits[IPL_SOFTSERIAL])
106 1.13 tsutsui
107 1.13 tsutsui #define spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK])
108 1.12 tsutsui
109 1.12 tsutsui struct newsmips_intrhand {
110 1.12 tsutsui LIST_ENTRY(newsmips_intrhand) ih_q;
111 1.12 tsutsui struct evcnt intr_count;
112 1.12 tsutsui int (*ih_func)(void *);
113 1.12 tsutsui void *ih_arg;
114 1.12 tsutsui u_int ih_level;
115 1.12 tsutsui u_int ih_mask;
116 1.12 tsutsui u_int ih_priority;
117 1.12 tsutsui };
118 1.12 tsutsui
119 1.12 tsutsui struct newsmips_intr {
120 1.12 tsutsui LIST_HEAD(,newsmips_intrhand) intr_q;
121 1.12 tsutsui };
122 1.1 tsubai
123 1.13 tsutsui #include <mips/softintr.h>
124 1.13 tsutsui
125 1.1 tsubai /*
126 1.1 tsubai * Index into intrcnt[], which is defined in locore
127 1.1 tsubai */
128 1.13 tsutsui #define SERIAL0_INTR 0
129 1.13 tsutsui #define SERIAL1_INTR 1
130 1.13 tsutsui #define SERIAL2_INTR 2
131 1.13 tsutsui #define LANCE_INTR 3
132 1.13 tsutsui #define SCSI_INTR 4
133 1.13 tsutsui #define ERROR_INTR 5
134 1.13 tsutsui #define HARDCLOCK_INTR 6
135 1.13 tsutsui #define FPU_INTR 7
136 1.13 tsutsui #define SLOT1_INTR 8
137 1.13 tsutsui #define SLOT2_INTR 9
138 1.13 tsutsui #define SLOT3_INTR 10
139 1.13 tsutsui #define FLOPPY_INTR 11
140 1.13 tsutsui #define STRAY_INTR 12
141 1.1 tsubai
142 1.2 tsubai extern u_int intrcnt[];
143 1.1 tsubai
144 1.2 tsubai /* handle i/o device interrupts */
145 1.13 tsutsui #ifdef news3400
146 1.13 tsutsui void news3400_intr __P((u_int, u_int, u_int, u_int));
147 1.13 tsutsui #endif
148 1.13 tsutsui #ifdef news5000
149 1.13 tsutsui void news5000_intr __P((u_int, u_int, u_int, u_int));
150 1.13 tsutsui #endif
151 1.14 tsutsui extern void (*hardware_intr) __P((u_int, u_int, u_int, u_int));
152 1.5 tsubai
153 1.14 tsutsui extern void (*enable_intr) __P((void));
154 1.14 tsutsui extern void (*disable_intr) __P((void));
155 1.14 tsutsui extern void (*enable_timer) __P((void));
156 1.4 tsubai
157 1.2 tsubai #endif /* !_LOCORE */
158 1.4 tsubai #endif /* _KERNEL */
159 1.1 tsubai #endif /* _MACHINE_INTR_H_ */
160