intr.h revision 1.10
11.10Stsutsui/*	$NetBSD: intr.h,v 1.10 2008/06/22 16:34:15 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.9Sad#define splsoftclock()	splraise1()
991.9Sad#define splsoftbio()	splraise1()
1001.9Sad#define splsoftnet()	splraise1()
1011.9Sad#define splsoftserial()	splraise1()
1021.10Stsutsui#define splvm()		splraise4()
1031.9Sad#define splsched()	spl6()
1041.2Skleink#define splhigh()	spl7()
1051.2Skleink
1061.2Skleink/* watch out for side effects */
1071.2Skleink#define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
1081.2Skleink
1091.2Skleinkint	spl0 __P((void));
1101.5Syamt
1111.5Syamt#define	IPL_NONE	0
1121.5Syamt#define	IPL_SOFTCLOCK	1
1131.9Sad#define	IPL_SOFTBIO	1
1141.9Sad#define	IPL_SOFTNET	3
1151.9Sad#define	IPL_SOFTSERIAL	4
1161.9Sad#define	IPL_VM		5
1171.9Sad#define	IPL_SCHED	6
1181.9Sad#define	IPL_HIGH	7
1191.9Sad#define	NIPL		8
1201.5Syamt
1211.10Stsutsuiextern const uint16_t ipl2psl_table[NIPL];
1221.5Syamt
1231.5Syamttypedef int ipl_t;
1241.5Syamttypedef struct {
1251.10Stsutsui	uint16_t _psl;
1261.5Syamt} ipl_cookie_t;
1271.5Syamt
1281.5Syamtstatic inline ipl_cookie_t
1291.5Syamtmakeiplcookie(ipl_t ipl)
1301.5Syamt{
1311.5Syamt
1321.10Stsutsui	return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
1331.5Syamt}
1341.5Syamt
1351.5Syamtstatic inline int
1361.5Syamtsplraiseipl(ipl_cookie_t icookie)
1371.5Syamt{
1381.5Syamt
1391.10Stsutsui	return _splraise(icookie._psl);
1401.5Syamt}
1411.7Stsutsui
1421.7Stsutsui#include <m68k/softintr.h>
1431.7Stsutsui
1441.2Skleink#endif /* _KERNEL && !_LOCORE */
1451.2Skleink
1461.2Skleink#endif /* !_CESFIC_INTR_H_ */
147