intr.h revision 1.4 1 1.4 thorpej /* $NetBSD: intr.h,v 1.4 2000/08/22 19:46:31 thorpej Exp $ */
2 1.1 wdk
3 1.1 wdk /*
4 1.1 wdk * Copyright (c) 1998 Jonathan Stone. All rights reserved.
5 1.1 wdk *
6 1.1 wdk * Redistribution and use in source and binary forms, with or without
7 1.1 wdk * modification, are permitted provided that the following conditions
8 1.1 wdk * are met:
9 1.1 wdk * 1. Redistributions of source code must retain the above copyright
10 1.1 wdk * notice, this list of conditions and the following disclaimer.
11 1.1 wdk * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 wdk * notice, this list of conditions and the following disclaimer in the
13 1.1 wdk * documentation and/or other materials provided with the distribution.
14 1.1 wdk * 3. All advertising materials mentioning features or use of this software
15 1.1 wdk * must display the following acknowledgement:
16 1.1 wdk * This product includes software developed by Jonathan Stone for
17 1.1 wdk * the NetBSD Project.
18 1.1 wdk * 4. The name of the author may not be used to endorse or promote products
19 1.1 wdk * derived from this software without specific prior written permission.
20 1.1 wdk *
21 1.1 wdk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 wdk * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 wdk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 wdk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 wdk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 wdk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 wdk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 wdk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 wdk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 wdk * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 wdk */
32 1.1 wdk
33 1.1 wdk #ifndef _MACHINE_INTR_H_
34 1.1 wdk #define _MACHINE_INTR_H_
35 1.1 wdk
36 1.1 wdk #define IPL_NONE 0 /* disable only this interrupt */
37 1.1 wdk #define IPL_BIO 1 /* disable block I/O interrupts */
38 1.1 wdk #define IPL_NET 2 /* disable network interrupts */
39 1.1 wdk #define IPL_TTY 3 /* disable terminal interrupts */
40 1.1 wdk #define IPL_CLOCK 4 /* disable clock interrupts */
41 1.1 wdk #define IPL_STATCLOCK 5 /* disable profiling interrupts */
42 1.1 wdk #define IPL_SERIAL 6 /* disable serial hardware interrupts */
43 1.1 wdk #define IPL_HIGH 7 /* disable all interrupts */
44 1.1 wdk
45 1.1 wdk #define IPL_SOFTSERIAL 0 /* serial software interrupts */
46 1.1 wdk #define IPL_SOFTNET 1 /* network software interrupts */
47 1.1 wdk #define IPL_SOFTCLOCK 2 /* clock software interrupts */
48 1.1 wdk #define IPL_NSOFT 3
49 1.1 wdk
50 1.1 wdk #define IPL_SOFTNAMES { \
51 1.1 wdk "serial", \
52 1.1 wdk "net", \
53 1.1 wdk "clock", \
54 1.1 wdk }
55 1.1 wdk
56 1.1 wdk #ifdef _KERNEL
57 1.1 wdk #ifndef _LOCORE
58 1.1 wdk #include <mips/cpuregs.h>
59 1.1 wdk
60 1.1 wdk extern int _splraise __P((int));
61 1.1 wdk extern int _spllower __P((int));
62 1.1 wdk extern int _splset __P((int));
63 1.1 wdk extern int _splget __P((void));
64 1.1 wdk extern void _splnone __P((void));
65 1.1 wdk extern void _setsoftintr __P((int));
66 1.1 wdk extern void _clrsoftintr __P((int));
67 1.1 wdk
68 1.1 wdk /*
69 1.1 wdk * software simulated interrupt
70 1.1 wdk */
71 1.1 wdk #define SIR_NET 0x01
72 1.1 wdk #define SIR_SERIAL 0x02
73 1.1 wdk
74 1.1 wdk #define setsoft(x) do { \
75 1.1 wdk extern u_int ssir; \
76 1.1 wdk int s; \
77 1.1 wdk \
78 1.1 wdk s = splhigh(); \
79 1.1 wdk ssir |= (x); \
80 1.1 wdk _setsoftintr(MIPS_SOFT_INT_MASK_1); \
81 1.1 wdk splx(s); \
82 1.1 wdk } while (0)
83 1.1 wdk
84 1.1 wdk #define setsoftclock() _setsoftintr(MIPS_SOFT_INT_MASK_0)
85 1.1 wdk #define setsoftnet() setsoft(SIR_NET)
86 1.1 wdk #define setsoftserial() setsoft(SIR_SERIAL)
87 1.1 wdk
88 1.1 wdk /*
89 1.1 wdk * nesting interrupt masks.
90 1.1 wdk */
91 1.1 wdk #define MIPS_INT_MASK_SPL_SOFT0 MIPS_SOFT_INT_MASK_0
92 1.1 wdk #define MIPS_INT_MASK_SPL_SOFT1 (MIPS_SOFT_INT_MASK_1|MIPS_INT_MASK_SPL_SOFT0)
93 1.1 wdk #define MIPS_INT_MASK_SPL0 (MIPS_INT_MASK_0|MIPS_INT_MASK_SPL_SOFT1)
94 1.1 wdk #define MIPS_INT_MASK_SPL1 (MIPS_INT_MASK_1|MIPS_INT_MASK_SPL0)
95 1.1 wdk #define MIPS_INT_MASK_SPL2 (MIPS_INT_MASK_2|MIPS_INT_MASK_SPL1)
96 1.1 wdk #define MIPS_INT_MASK_SPL3 (MIPS_INT_MASK_3|MIPS_INT_MASK_SPL2)
97 1.1 wdk #define MIPS_INT_MASK_SPL4 (MIPS_INT_MASK_4|MIPS_INT_MASK_SPL3)
98 1.1 wdk #define MIPS_INT_MASK_SPL5 (MIPS_INT_MASK_5|MIPS_INT_MASK_SPL4)
99 1.1 wdk
100 1.1 wdk #define spl0() (void)_spllower(0)
101 1.1 wdk #define splx(s) (void)_splset(s)
102 1.1 wdk #define splbio() _splraise(MIPS_INT_MASK_SPL1)
103 1.1 wdk #define splnet() _splraise(MIPS_INT_MASK_SPL0)
104 1.1 wdk #define spltty() _splraise(MIPS_INT_MASK_SPL0)
105 1.1 wdk #define splimp() _splraise(MIPS_INT_MASK_SPL0)
106 1.1 wdk #define splclock() _splraise(MIPS_INT_MASK_SPL2)
107 1.1 wdk #define splstatclock() _splraise(MIPS_INT_MASK_SPL2)
108 1.1 wdk #define splhigh() _splraise(MIPS_INT_MASK_SPL2)
109 1.3 thorpej #define splsched() splhigh()
110 1.4 thorpej #define spllock() splhigh()
111 1.1 wdk
112 1.1 wdk #define splsoftclock() _splraise(MIPS_INT_MASK_SPL_SOFT0)
113 1.1 wdk #define splsoftnet() _splraise(MIPS_INT_MASK_SPL_SOFT1)
114 1.1 wdk #define spllowersoftclock() _spllower(MIPS_INT_MASK_SPL_SOFT0)
115 1.1 wdk
116 1.2 wdk struct intrhandler {
117 1.2 wdk int (*func) __P((void *));
118 1.2 wdk void *arg;
119 1.2 wdk };
120 1.2 wdk extern struct intrhandler intrtab[];
121 1.2 wdk
122 1.2 wdk #define SYS_INTR_LEVEL0 0
123 1.2 wdk #define SYS_INTR_LEVEL1 1
124 1.2 wdk #define SYS_INTR_LEVEL2 2
125 1.2 wdk #define SYS_INTR_LEVEL3 3
126 1.2 wdk #define SYS_INTR_LEVEL4 4
127 1.2 wdk #define SYS_INTR_LEVEL5 5
128 1.2 wdk #define SYS_INTR_SCSI 6
129 1.2 wdk #define SYS_INTR_TIMER 7
130 1.2 wdk #define SYS_INTR_ETHER 8
131 1.2 wdk #define SYS_INTR_SCC0 9
132 1.2 wdk #define SYS_INTR_FDC 10
133 1.1 wdk
134 1.2 wdk #define MAX_INTR_COOKIES 16
135 1.2 wdk
136 1.2 wdk #define CALL_INTR(lev) ((*intrtab[lev].func)(intrtab[lev].arg))
137 1.1 wdk
138 1.1 wdk #endif /* !_LOCORE */
139 1.1 wdk #endif /* _KERNEL */
140 1.1 wdk #endif /* _MACHINE_INTR_H_ */
141