intr.h revision 1.12
11.12Srmind/*	$NetBSD: intr.h,v 1.12 2011/02/08 20:20:10 rmind Exp $	*/
21.2Skleink
31.2Skleink/*
41.12Srmind * Copyright (c) 1988 University of Utah.
51.2Skleink * Copyright (c) 1982, 1986, 1990, 1993
61.2Skleink *	The Regents of the University of California.  All rights reserved.
71.3Sagc *
81.3Sagc * This code is derived from software contributed to Berkeley by
91.3Sagc * the Systems Programming Group of the University of Utah Computer
101.3Sagc * Science Department.
111.3Sagc *
121.3Sagc * Redistribution and use in source and binary forms, with or without
131.3Sagc * modification, are permitted provided that the following conditions
141.3Sagc * are met:
151.3Sagc * 1. Redistributions of source code must retain the above copyright
161.3Sagc *    notice, this list of conditions and the following disclaimer.
171.3Sagc * 2. Redistributions in binary form must reproduce the above copyright
181.3Sagc *    notice, this list of conditions and the following disclaimer in the
191.3Sagc *    documentation and/or other materials provided with the distribution.
201.3Sagc * 3. Neither the name of the University nor the names of its contributors
211.3Sagc *    may be used to endorse or promote products derived from this software
221.3Sagc *    without specific prior written permission.
231.3Sagc *
241.3Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251.3Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261.3Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271.3Sagc * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281.3Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291.3Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301.3Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311.3Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321.3Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331.3Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341.3Sagc * SUCH DAMAGE.
351.3Sagc *
361.3Sagc * from: Utah $Hdr: machparam.h 1.16 92/12/20$
371.3Sagc *
381.3Sagc *	from: @(#)param.h	8.1 (Berkeley) 6/10/93
391.3Sagc */
401.2Skleink
411.2Skleink#ifndef _CESFIC_INTR_H_
421.2Skleink#define _CESFIC_INTR_H_
431.2Skleink
441.2Skleink/*
451.2Skleink * spl functions; all but spl0 are done in-line
461.2Skleink */
471.2Skleink#include <machine/psl.h>
481.2Skleink
491.2Skleink#if defined(_KERNEL) && !defined(_LOCORE)
501.2Skleink/* spl0 requires checking for software interrupts */
511.2Skleink#define spl1()  _spl(PSL_S|PSL_IPL1)
521.2Skleink#define spl2()  _spl(PSL_S|PSL_IPL2)
531.2Skleink#define spl3()  _spl(PSL_S|PSL_IPL3)
541.2Skleink#define spl4()  _spl(PSL_S|PSL_IPL4)
551.2Skleink#define spl5()  _spl(PSL_S|PSL_IPL5)
561.2Skleink#define spl6()  _spl(PSL_S|PSL_IPL6)
571.2Skleink#define spl7()  _spl(PSL_S|PSL_IPL7)
581.2Skleink
591.2Skleink/* These spl calls are used by machine-independent code. */
601.9Sad#define splsoftclock()	splraise1()
611.9Sad#define splsoftbio()	splraise1()
621.9Sad#define splsoftnet()	splraise1()
631.9Sad#define splsoftserial()	splraise1()
641.10Stsutsui#define splvm()		splraise4()
651.9Sad#define splsched()	spl6()
661.2Skleink#define splhigh()	spl7()
671.2Skleink
681.2Skleink/* watch out for side effects */
691.2Skleink#define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
701.2Skleink
711.11Sdslint	spl0(void);
721.5Syamt
731.5Syamt#define	IPL_NONE	0
741.5Syamt#define	IPL_SOFTCLOCK	1
751.9Sad#define	IPL_SOFTBIO	1
761.9Sad#define	IPL_SOFTNET	3
771.9Sad#define	IPL_SOFTSERIAL	4
781.9Sad#define	IPL_VM		5
791.9Sad#define	IPL_SCHED	6
801.9Sad#define	IPL_HIGH	7
811.9Sad#define	NIPL		8
821.5Syamt
831.10Stsutsuiextern const uint16_t ipl2psl_table[NIPL];
841.5Syamt
851.5Syamttypedef int ipl_t;
861.5Syamttypedef struct {
871.10Stsutsui	uint16_t _psl;
881.5Syamt} ipl_cookie_t;
891.5Syamt
901.5Syamtstatic inline ipl_cookie_t
911.5Syamtmakeiplcookie(ipl_t ipl)
921.5Syamt{
931.5Syamt
941.10Stsutsui	return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
951.5Syamt}
961.5Syamt
971.5Syamtstatic inline int
981.5Syamtsplraiseipl(ipl_cookie_t icookie)
991.5Syamt{
1001.5Syamt
1011.10Stsutsui	return _splraise(icookie._psl);
1021.5Syamt}
1031.7Stsutsui
1041.7Stsutsui#include <m68k/softintr.h>
1051.7Stsutsui
1061.2Skleink#endif /* _KERNEL && !_LOCORE */
1071.2Skleink
1081.2Skleink#endif /* !_CESFIC_INTR_H_ */
109