intr.h revision 1.20.8.1 1 1.20.8.1 jmcneill /* $NetBSD: intr.h,v 1.20.8.1 2007/12/09 19:35:49 jmcneill 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.20.8.1 jmcneill #define IPL_SOFTCLOCK 1 /* clock software interrupts (SI 0) */
44 1.20.8.1 jmcneill #define IPL_SOFTBIO 1 /* bio software interrupts (SI 0) */
45 1.20.8.1 jmcneill #define IPL_SOFTNET 2 /* network software interrupts (SI 1) */
46 1.20.8.1 jmcneill #define IPL_SOFTSERIAL 2 /* serial software interrupts (SI 1) */
47 1.20.8.1 jmcneill #define IPL_VM 3
48 1.20.8.1 jmcneill #define IPL_SCHED 4 /* disable clock interrupts */
49 1.20.8.1 jmcneill #define IPL_HIGH 4 /* disable all interrupts */
50 1.13 tsutsui
51 1.20.8.1 jmcneill #define _IPL_N 5
52 1.13 tsutsui
53 1.20.8.1 jmcneill #define _IPL_SI0_FIRST IPL_SOFTCLOCK
54 1.20.8.1 jmcneill #define _IPL_SI0_LAST IPL_SOFTBIO
55 1.13 tsutsui
56 1.13 tsutsui #define _IPL_SI1_FIRST IPL_SOFTNET
57 1.13 tsutsui #define _IPL_SI1_LAST IPL_SOFTSERIAL
58 1.13 tsutsui
59 1.4 tsubai #ifdef _KERNEL
60 1.2 tsubai #ifndef _LOCORE
61 1.13 tsutsui
62 1.12 tsutsui #include <sys/device.h>
63 1.20 tsutsui #include <mips/locore.h>
64 1.13 tsutsui
65 1.15 tsutsui extern const uint32_t ipl_sr_bits[_IPL_N];
66 1.2 tsubai
67 1.4 tsubai #define spl0() (void)_spllower(0)
68 1.4 tsubai #define splx(s) (void)_splset(s)
69 1.13 tsutsui
70 1.13 tsutsui #define splsoft() _splraise(ipl_sr_bits[IPL_SOFT])
71 1.13 tsutsui
72 1.18 yamt typedef int ipl_t;
73 1.18 yamt typedef struct {
74 1.18 yamt ipl_t _sr;
75 1.18 yamt } ipl_cookie_t;
76 1.18 yamt
77 1.18 yamt static inline ipl_cookie_t
78 1.18 yamt makeiplcookie(ipl_t ipl)
79 1.18 yamt {
80 1.18 yamt
81 1.18 yamt return (ipl_cookie_t){._sr = ipl_sr_bits[ipl]};
82 1.18 yamt }
83 1.18 yamt
84 1.18 yamt static inline int
85 1.18 yamt splraiseipl(ipl_cookie_t icookie)
86 1.18 yamt {
87 1.18 yamt
88 1.18 yamt return _splraise(icookie._sr);
89 1.18 yamt }
90 1.18 yamt
91 1.18 yamt #include <sys/spl.h>
92 1.18 yamt
93 1.12 tsutsui struct newsmips_intrhand {
94 1.12 tsutsui LIST_ENTRY(newsmips_intrhand) ih_q;
95 1.12 tsutsui struct evcnt intr_count;
96 1.12 tsutsui int (*ih_func)(void *);
97 1.12 tsutsui void *ih_arg;
98 1.12 tsutsui u_int ih_level;
99 1.12 tsutsui u_int ih_mask;
100 1.12 tsutsui u_int ih_priority;
101 1.12 tsutsui };
102 1.12 tsutsui
103 1.12 tsutsui struct newsmips_intr {
104 1.12 tsutsui LIST_HEAD(,newsmips_intrhand) intr_q;
105 1.12 tsutsui };
106 1.1 tsubai
107 1.1 tsubai /*
108 1.1 tsubai * Index into intrcnt[], which is defined in locore
109 1.1 tsubai */
110 1.13 tsutsui #define SERIAL0_INTR 0
111 1.13 tsutsui #define SERIAL1_INTR 1
112 1.13 tsutsui #define SERIAL2_INTR 2
113 1.13 tsutsui #define LANCE_INTR 3
114 1.13 tsutsui #define SCSI_INTR 4
115 1.13 tsutsui #define ERROR_INTR 5
116 1.13 tsutsui #define HARDCLOCK_INTR 6
117 1.13 tsutsui #define FPU_INTR 7
118 1.13 tsutsui #define SLOT1_INTR 8
119 1.13 tsutsui #define SLOT2_INTR 9
120 1.13 tsutsui #define SLOT3_INTR 10
121 1.13 tsutsui #define FLOPPY_INTR 11
122 1.13 tsutsui #define STRAY_INTR 12
123 1.1 tsubai
124 1.2 tsubai extern u_int intrcnt[];
125 1.1 tsubai
126 1.2 tsubai /* handle i/o device interrupts */
127 1.13 tsutsui #ifdef news3400
128 1.16 tsutsui void news3400_intr(uint32_t, uint32_t, uint32_t, uint32_t);
129 1.13 tsutsui #endif
130 1.13 tsutsui #ifdef news5000
131 1.16 tsutsui void news5000_intr(uint32_t, uint32_t, uint32_t, uint32_t);
132 1.13 tsutsui #endif
133 1.16 tsutsui extern void (*hardware_intr)(uint32_t, uint32_t, uint32_t, uint32_t);
134 1.5 tsubai
135 1.15 tsutsui extern void (*enable_intr)(void);
136 1.15 tsutsui extern void (*disable_intr)(void);
137 1.15 tsutsui extern void (*enable_timer)(void);
138 1.4 tsubai
139 1.2 tsubai #endif /* !_LOCORE */
140 1.4 tsubai #endif /* _KERNEL */
141 1.1 tsubai #endif /* _MACHINE_INTR_H_ */
142