intr.h revision 1.7
11.7Stsutsui/*	$NetBSD: intr.h,v 1.7 2007/03/05 13:06:44 tsutsui 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	splsoft()	splraise1()
991.2Skleink#define splsoftclock()	splsoft()
1001.2Skleink#define splsoftnet()	splsoft()
1011.5Syamt#define splbio()	_splraise(ipl2spl_table[IPL_BIO])
1021.5Syamt#define splnet()	_splraise(ipl2spl_table[IPL_NET])
1031.5Syamt#define spltty()	_splraise(ipl2spl_table[IPL_TTY])
1041.5Syamt#define splvm()		_splraise(ipl2spl_table[IPL_VM])
1051.2Skleink#define splclock()	spl6()
1061.2Skleink#define splstatclock()	spl6()
1071.2Skleink#define splhigh()	spl7()
1081.2Skleink#define splsched()	spl7()
1091.2Skleink#define spllock()	spl7()
1101.2Skleink
1111.2Skleink/* watch out for side effects */
1121.2Skleink#define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
1131.2Skleink
1141.2Skleinkint	spl0 __P((void));
1151.5Syamt
1161.5Syamt#define	IPL_NONE	0
1171.5Syamt#define	IPL_SOFTCLOCK	1
1181.5Syamt#define	IPL_SOFTNET	2
1191.7Stsutsui#define	IPL_SOFTSERIAL	3
1201.7Stsutsui#define	IPL_SOFT	4
1211.7Stsutsui#define	IPL_BIO		5
1221.7Stsutsui#define	IPL_NET		6
1231.7Stsutsui#define	IPL_TTY		7
1241.7Stsutsui#define	IPL_VM		8
1251.7Stsutsui#define	IPL_CLOCK	9
1261.7Stsutsui#define	IPL_STATCLOCK	10
1271.7Stsutsui#define	IPL_SCHED	11
1281.7Stsutsui#define	IPL_HIGH	12
1291.7Stsutsui#define	IPL_LOCK	13
1301.7Stsutsui#define	NIPL		14
1311.5Syamt
1321.7Stsutsuiextern int ipl2spl_table[NIPL];
1331.5Syamt
1341.5Syamttypedef int ipl_t;
1351.5Syamttypedef struct {
1361.5Syamt	int _ipl;
1371.5Syamt} ipl_cookie_t;
1381.5Syamt
1391.5Syamtstatic inline ipl_cookie_t
1401.5Syamtmakeiplcookie(ipl_t ipl)
1411.5Syamt{
1421.5Syamt
1431.5Syamt	return (ipl_cookie_t){._ipl = ipl};
1441.5Syamt}
1451.5Syamt
1461.5Syamtstatic inline int
1471.5Syamtsplraiseipl(ipl_cookie_t icookie)
1481.5Syamt{
1491.5Syamt
1501.5Syamt	return _splraise(ipl2spl_table[icookie._ipl]);
1511.5Syamt}
1521.7Stsutsui
1531.7Stsutsui#include <m68k/softintr.h>
1541.7Stsutsui
1551.2Skleink#endif /* _KERNEL && !_LOCORE */
1561.2Skleink
1571.2Skleink#endif /* !_CESFIC_INTR_H_ */
158