intr.h revision 1.5
11.5Syamt/*	$NetBSD: intr.h,v 1.5 2006/12/21 15:55:22 yamt Exp $	*/
21.2Skleink
31.2Skleink/*
41.2Skleink * Copyright (c) 1982, 1986, 1990, 1993
51.2Skleink *	The Regents of the University of California.  All rights reserved.
61.3Sagc *
71.3Sagc * This code is derived from software contributed to Berkeley by
81.3Sagc * the Systems Programming Group of the University of Utah Computer
91.3Sagc * Science Department.
101.3Sagc *
111.3Sagc * Redistribution and use in source and binary forms, with or without
121.3Sagc * modification, are permitted provided that the following conditions
131.3Sagc * are met:
141.3Sagc * 1. Redistributions of source code must retain the above copyright
151.3Sagc *    notice, this list of conditions and the following disclaimer.
161.3Sagc * 2. Redistributions in binary form must reproduce the above copyright
171.3Sagc *    notice, this list of conditions and the following disclaimer in the
181.3Sagc *    documentation and/or other materials provided with the distribution.
191.3Sagc * 3. Neither the name of the University nor the names of its contributors
201.3Sagc *    may be used to endorse or promote products derived from this software
211.3Sagc *    without specific prior written permission.
221.3Sagc *
231.3Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.3Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.3Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.3Sagc * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.3Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.3Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.3Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.3Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.3Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.3Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.3Sagc * SUCH DAMAGE.
341.3Sagc *
351.3Sagc * from: Utah $Hdr: machparam.h 1.16 92/12/20$
361.3Sagc *
371.3Sagc *	from: @(#)param.h	8.1 (Berkeley) 6/10/93
381.3Sagc */
391.3Sagc/*
401.3Sagc * Copyright (c) 1988 University of Utah.
411.2Skleink *
421.2Skleink * This code is derived from software contributed to Berkeley by
431.2Skleink * the Systems Programming Group of the University of Utah Computer
441.2Skleink * Science Department.
451.2Skleink *
461.2Skleink * Redistribution and use in source and binary forms, with or without
471.2Skleink * modification, are permitted provided that the following conditions
481.2Skleink * are met:
491.2Skleink * 1. Redistributions of source code must retain the above copyright
501.2Skleink *    notice, this list of conditions and the following disclaimer.
511.2Skleink * 2. Redistributions in binary form must reproduce the above copyright
521.2Skleink *    notice, this list of conditions and the following disclaimer in the
531.2Skleink *    documentation and/or other materials provided with the distribution.
541.2Skleink * 3. All advertising materials mentioning features or use of this software
551.2Skleink *    must display the following acknowledgement:
561.2Skleink *	This product includes software developed by the University of
571.2Skleink *	California, Berkeley and its contributors.
581.2Skleink * 4. Neither the name of the University nor the names of its contributors
591.2Skleink *    may be used to endorse or promote products derived from this software
601.2Skleink *    without specific prior written permission.
611.2Skleink *
621.2Skleink * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
631.2Skleink * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
641.2Skleink * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
651.2Skleink * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
661.2Skleink * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
671.2Skleink * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
681.2Skleink * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
691.2Skleink * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
701.2Skleink * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
711.2Skleink * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
721.2Skleink * SUCH DAMAGE.
731.2Skleink *
741.2Skleink * from: Utah $Hdr: machparam.h 1.16 92/12/20$
751.2Skleink *
761.2Skleink *	from: @(#)param.h	8.1 (Berkeley) 6/10/93
771.2Skleink */
781.2Skleink
791.2Skleink#ifndef _CESFIC_INTR_H_
801.2Skleink#define _CESFIC_INTR_H_
811.2Skleink
821.2Skleink/*
831.2Skleink * spl functions; all but spl0 are done in-line
841.2Skleink */
851.2Skleink#include <machine/psl.h>
861.2Skleink
871.2Skleink#if defined(_KERNEL) && !defined(_LOCORE)
881.2Skleink/* spl0 requires checking for software interrupts */
891.2Skleink#define spl1()  _spl(PSL_S|PSL_IPL1)
901.2Skleink#define spl2()  _spl(PSL_S|PSL_IPL2)
911.2Skleink#define spl3()  _spl(PSL_S|PSL_IPL3)
921.2Skleink#define spl4()  _spl(PSL_S|PSL_IPL4)
931.2Skleink#define spl5()  _spl(PSL_S|PSL_IPL5)
941.2Skleink#define spl6()  _spl(PSL_S|PSL_IPL6)
951.2Skleink#define spl7()  _spl(PSL_S|PSL_IPL7)
961.2Skleink
971.2Skleink/* These spl calls are used by machine-independent code. */
981.2Skleink#define	spllowersoftclock() spl1()
991.2Skleink#define	splsoft()	splraise1()
1001.2Skleink#define splsoftclock()	splsoft()
1011.2Skleink#define splsoftnet()	splsoft()
1021.5Syamt#define splbio()	_splraise(ipl2spl_table[IPL_BIO])
1031.5Syamt#define splnet()	_splraise(ipl2spl_table[IPL_NET])
1041.5Syamt#define spltty()	_splraise(ipl2spl_table[IPL_TTY])
1051.5Syamt#define splvm()		_splraise(ipl2spl_table[IPL_VM])
1061.2Skleink#define splclock()	spl6()
1071.2Skleink#define splstatclock()	spl6()
1081.2Skleink#define splhigh()	spl7()
1091.2Skleink#define splsched()	spl7()
1101.2Skleink#define spllock()	spl7()
1111.2Skleink
1121.2Skleink/* watch out for side effects */
1131.2Skleink#define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
1141.2Skleink
1151.2Skleinkint	spl0 __P((void));
1161.5Syamt
1171.5Syamt#define	IPL_NONE	0
1181.5Syamt#define	IPL_SOFTCLOCK	1
1191.5Syamt#define	IPL_SOFTNET	2
1201.5Syamt#define	IPL_BIO		3
1211.5Syamt#define	IPL_NET		4
1221.5Syamt#define	IPL_TTY		5
1231.5Syamt#define	IPL_VM		6
1241.5Syamt#define	IPL_CLOCK	7
1251.5Syamt#define	IPL_STATCLOCK	8
1261.5Syamt#define	IPL_SCHED	9
1271.5Syamt#define	IPL_HIGH	10
1281.5Syamt#define	IPL_LOCK	11
1291.5Syamt#define	NIPLS		12
1301.5Syamt
1311.5Syamtextern int ipl2spl_table[NIPLS];
1321.5Syamt
1331.5Syamttypedef int ipl_t;
1341.5Syamttypedef struct {
1351.5Syamt	int _ipl;
1361.5Syamt} ipl_cookie_t;
1371.5Syamt
1381.5Syamtstatic inline ipl_cookie_t
1391.5Syamtmakeiplcookie(ipl_t ipl)
1401.5Syamt{
1411.5Syamt
1421.5Syamt	return (ipl_cookie_t){._ipl = ipl};
1431.5Syamt}
1441.5Syamt
1451.5Syamtstatic inline int
1461.5Syamtsplraiseipl(ipl_cookie_t icookie)
1471.5Syamt{
1481.5Syamt
1491.5Syamt	return _splraise(ipl2spl_table[icookie._ipl]);
1501.5Syamt}
1511.2Skleink#endif /* _KERNEL && !_LOCORE */
1521.2Skleink
1531.2Skleink#endif /* !_CESFIC_INTR_H_ */
154