bb59490279e38a549c862874f1490af0e9263bbb
2 * Copyright (c) 1996-1999 University of Utah and the Flux Group.
5 * This file is part of the Flux OSKit. The OSKit is free software, also known
6 * as "open source;" you can redistribute it and/or modify it under the terms
7 * of the GNU General Public License (GPL), version 2, as published by the Free
8 * Software Foundation (FSF). To explore alternate licensing terms, contact
9 * the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271.
11 * The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GPL for more details. You should have
14 * received a copy of the GPL along with the OSKit; see the file COPYING. If
15 * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
18 * Copyright (c) 1993 The Regents of the University of California.
19 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * 3. All advertising materials mentioning features or use of this software
30 * must display the following acknowledgement:
31 * This product includes software developed by the University of
32 * California, Berkeley and its contributors.
33 * 4. Neither the name of the University nor the names of its contributors
34 * may be used to endorse or promote products derived from this software
35 * without specific prior written permission.
37 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
38 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 #ifndef _MACHINE_IPL_H_
52 #define _MACHINE_IPL_H_
54 #include <machine/ipl.h> /* XXX "machine" means cpu for i386 */
57 * Software interrupt bit numbers in priority order. The priority only
58 * determines which swi will be dispatched next; a higher priority swi
59 * may be dispatched when a nested h/w interrupt handler returns.
61 #define SWI_TTY (NHWI + 0)
62 #define SWI_NET (NHWI + 1)
67 * Corresponding interrupt-pending bits for ipending.
69 #define SWI_TTY_PENDING (1 << SWI_TTY)
70 #define SWI_NET_PENDING (1 << SWI_NET)
71 #define SWI_CLOCK_PENDING (1 << SWI_CLOCK)
72 #define SWI_AST_PENDING (1 << SWI_AST)
75 * Corresponding interrupt-disable masks for cpl. The ordering is now by
76 * inclusion (where each mask is considered as a set of bits). Everything
77 * except SWI_AST_MASK includes SWI_CLOCK_MASK so that softclock() doesn't
78 * run while other swi handlers are running and timeout routines can call
79 * swi handlers. Everything includes SWI_AST_MASK so that AST's are masked
80 * until just before return to user mode. SWI_TTY_MASK includes SWI_NET_MASK
81 * in case tty interrupts are processed at splsofttty() for a tty that is in
82 * SLIP or PPP line discipline (this is weaker than merging net_imask with
83 * tty_imask in isa.c - splimp() must mask hard and soft tty interrupts, but
84 * spltty() apparently only needs to mask soft net interrupts).
86 #define SWI_TTY_MASK (SWI_TTY_PENDING | SWI_CLOCK_MASK | SWI_NET_MASK)
87 #define SWI_NET_MASK (SWI_NET_PENDING | SWI_CLOCK_MASK)
88 #define SWI_CLOCK_MASK (SWI_CLOCK_PENDING | SWI_AST_MASK)
89 #define SWI_AST_MASK SWI_AST_PENDING
90 #define SWI_MASK (~HWI_MASK)
95 extern unsigned oskit_freebsd_cpl
;
96 extern unsigned oskit_freebsd_ipending
;
98 #define GENERIC_SPL(you_name_it) \
99 static __inline int spl##you_name_it(void) \
102 osenv_intr_disable(); \
103 t = oskit_freebsd_cpl; \
104 oskit_freebsd_cpl = 1; \
116 * this is used to reduce the clock spl to a softclock spl before
117 * calling the softclock handler directly. It will never call splx!
119 #define splsoftclock() 0
121 static __inline
void splx(int x
)
124 oskit_freebsd_cpl
= 0;
129 /* for code from NetBSD */
130 #define spl0() splx(0)
132 #define setsoftclock() (oskit_freebsd_ipending |= SWI_CLOCK_PENDING)
133 #define setsofttty() (oskit_freebsd_ipending |= SWI_TTY_PENDING)
135 #define schedsofttty() (oskit_freebsd_ipending |= SWI_TTY_PENDING)
138 * functions to save and restore the current cpl
140 static __inline
void save_cpl(unsigned *x
)
142 *x
= oskit_freebsd_cpl
;
145 static __inline
void restore_cpl(unsigned x
)
147 oskit_freebsd_cpl
= x
;
153 extern unsigned bio_imask
; /* group of interrupts masked with splbio() */
154 extern unsigned cpl
; /* current priority level mask */
155 extern volatile unsigned idelayed
; /* interrupts to become pending */
156 extern volatile unsigned ipending
; /* active interrupts masked by cpl */
157 extern unsigned net_imask
; /* group of interrupts masked with splimp() */
158 extern unsigned stat_imask
; /* interrupts masked with splstatclock() */
159 extern unsigned tty_imask
; /* group of interrupts masked with spltty() */
162 * ipending has to be volatile so that it is read every time it is accessed
163 * in splx() and spl0(), but we don't want it to be read nonatomically when
164 * it is changed. Pretending that ipending is a plain int happens to give
165 * suitable atomic code for "ipending |= constant;".
167 #define setdelayed() (*(unsigned *)&ipending |= loadandclear(&idelayed))
168 #define setsoftast() (*(unsigned *)&ipending |= SWI_AST_PENDING)
169 #define setsoftclock() (*(unsigned *)&ipending |= SWI_CLOCK_PENDING)
170 #define setsoftnet() (*(unsigned *)&ipending |= SWI_NET_PENDING)
171 #define setsofttty() (*(unsigned *)&ipending |= SWI_TTY_PENDING)
173 #define schedsofttty() (*(unsigned *)&idelayed |= SWI_TTY_PENDING)
177 static int splhigh() { return 0; }
178 static int splimp() { return 0; }
179 static int splnet() { return 0; }
180 static int splx(x
) { return 0; }
181 static int splclock() { return 0; }
183 #elif defined(__GNUC__)
185 void splz
__P((void));
187 #define GENSPL(name, set_cpl) \
188 static __inline int name(void) \
192 __asm __volatile("" : : : "memory"); \
198 GENSPL(splbio
, cpl
|= bio_imask
)
199 GENSPL(splclock
, cpl
= HWI_MASK
| SWI_MASK
)
200 GENSPL(splhigh
, cpl
= HWI_MASK
| SWI_MASK
)
201 GENSPL(splimp
, cpl
|= net_imask
)
202 GENSPL(splnet
, cpl
|= SWI_NET_MASK
)
203 GENSPL(splsoftclock
, cpl
= SWI_CLOCK_MASK
)
204 GENSPL(splsofttty
, cpl
|= SWI_TTY_MASK
)
205 GENSPL(splstatclock
, cpl
|= stat_imask
)
206 GENSPL(spltty
, cpl
|= tty_imask
)
212 if (ipending
& ~SWI_AST_MASK
)
224 #endif /* __GNUC__ */
229 #endif /* !_MACHINE_IPL_H_ */