intr.h revision 1.10
11.10Sad/* $NetBSD: intr.h,v 1.10 2007/12/03 15:33:49 ad Exp $ */
21.1Snisimura
31.1Snisimura/*-
41.1Snisimura * Copyright (c) 2000 The NetBSD Foundation, Inc.
51.1Snisimura * All rights reserved.
61.1Snisimura *
71.1Snisimura * This code is derived from software contributed to The NetBSD Foundation
81.1Snisimura * by Tohru Nishimura.
91.1Snisimura *
101.1Snisimura * Redistribution and use in source and binary forms, with or without
111.1Snisimura * modification, are permitted provided that the following conditions
121.1Snisimura * are met:
131.1Snisimura * 1. Redistributions of source code must retain the above copyright
141.1Snisimura *    notice, this list of conditions and the following disclaimer.
151.1Snisimura * 2. Redistributions in binary form must reproduce the above copyright
161.1Snisimura *    notice, this list of conditions and the following disclaimer in the
171.1Snisimura *    documentation and/or other materials provided with the distribution.
181.1Snisimura * 3. All advertising materials mentioning features or use of this software
191.1Snisimura *    must display the following acknowledgement:
201.1Snisimura *	This product includes software developed by the NetBSD
211.1Snisimura *	Foundation, Inc. and its contributors.
221.1Snisimura * 4. Neither the name of The NetBSD Foundation nor the names of its
231.1Snisimura *    contributors may be used to endorse or promote products derived
241.1Snisimura *    from this software without specific prior written permission.
251.1Snisimura *
261.1Snisimura * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.1Snisimura * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.1Snisimura * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.1Snisimura * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.1Snisimura * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.1Snisimura * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.1Snisimura * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.1Snisimura * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.1Snisimura * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.1Snisimura * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.1Snisimura * POSSIBILITY OF SUCH DAMAGE.
371.1Snisimura */
381.1Snisimura
391.1Snisimura#ifndef _MACHINE_INTR_H
401.1Snisimura#define _MACHINE_INTR_H
411.1Snisimura
421.4Sjdolecek#ifdef _KERNEL
431.4Sjdolecek
441.1Snisimura/*
451.1Snisimura * spl functions; all but spl0 are done in-line
461.1Snisimura */
471.1Snisimura#include <machine/psl.h>
481.1Snisimura
491.1Snisimura#define splnone()	spl0()
501.10Sad#define splsoftbio()	splraise1()
511.10Sad#define splsoftclock()	splraise1()
521.10Sad#define splsoftnet()	splraise1()
531.10Sad#define splsoftserial()	splraise1()
541.7Stsutsui#define splvm()		spl7()
551.10Sad#define splsched()	spl7()
561.7Stsutsui#define splhigh()	spl7()
571.1Snisimura
581.1Snisimura/* watch out for side effects */
591.1Snisimura#define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
601.1Snisimura
611.1Snisimuraint spl0 __P((void));
621.4Sjdolecek
631.5Syamt#define	IPL_NONE	0
641.5Syamt#define	IPL_SOFTCLOCK	1
651.10Sad#define	IPL_SOFTBIO	2
661.10Sad#define	IPL_SOFTNET	3
671.10Sad#define	IPL_SOFTSERIAL	4
681.10Sad#define	IPL_VM		5
691.10Sad#define	IPL_SCHED	6
701.10Sad#define	IPL_HIGH	7
711.10Sad#define	NIPL		8
721.5Syamt
731.7Stsutsuiextern const int ipl2spl_table[NIPL];
741.5Syamt
751.5Syamttypedef int ipl_t;
761.5Syamttypedef struct {
771.9Sthorpej	uint16_t _spl;
781.5Syamt} ipl_cookie_t;
791.5Syamt
801.5Syamtstatic inline ipl_cookie_t
811.5Syamtmakeiplcookie(ipl_t ipl)
821.5Syamt{
831.5Syamt
841.5Syamt	return (ipl_cookie_t){._spl = ipl2spl_table[ipl]};
851.5Syamt}
861.5Syamt
871.5Syamtstatic inline int
881.5Syamtsplraiseipl(ipl_cookie_t icookie)
891.5Syamt{
901.5Syamt
911.5Syamt	return _splraise(icookie._spl);
921.5Syamt}
931.1Snisimura
941.8Stsutsui#endif /* _KERNEL */
951.8Stsutsui
961.1Snisimura#endif	/* _MACHINE_INTR_H */
97