intr.h revision 1.5
11.5Syamt/* $NetBSD: intr.h,v 1.5 2006/12/21 15:55:23 yamt 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.1Snisimura#define spllowersoftclock() spl1() 511.1Snisimura#define splsoftclock() splraise1() 521.1Snisimura#define splsoftnet() splraise1() 531.1Snisimura#define splbio() spl2() 541.1Snisimura#define splnet() spl3() 551.1Snisimura#define spltty() spl6() 561.1Snisimura#define splclock() spl5() 571.1Snisimura#define splstatclock() spl5() 581.1Snisimura#define splvm() spl7() 591.1Snisimura#define splhigh() spl7() 601.1Snisimura#define splsched() spl7() 611.2Sthorpej#define spllock() spl7() 621.1Snisimura 631.1Snisimura/* watch out for side effects */ 641.1Snisimura#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) 651.1Snisimura 661.1Snisimuraint spl0 __P((void)); 671.4Sjdolecek 681.5Syamt#define IPL_NONE 0 691.5Syamt#define IPL_SOFTCLOCK 1 701.5Syamt#define IPL_SOFTNET 2 711.5Syamt#define IPL_BIO 3 721.5Syamt#define IPL_NET 4 731.5Syamt#define IPL_CLOCK 5 741.5Syamt#define IPL_STATCLOCK 6 751.5Syamt#define IPL_TTY 7 761.5Syamt#define IPL_VM 8 771.5Syamt#define IPL_SCHED 9 781.5Syamt#define IPL_HIGH 10 791.5Syamt#define IPL_LOCK 11 801.5Syamt#define NIPLS 12 811.5Syamt 821.5Syamtextern const int ipl2spl_table[NIPLS]; 831.5Syamt 841.5Syamttypedef int ipl_t; 851.5Syamttypedef struct { 861.5Syamt int _spl; 871.5Syamt} ipl_cookie_t; 881.5Syamt 891.5Syamtstatic inline ipl_cookie_t 901.5Syamtmakeiplcookie(ipl_t ipl) 911.5Syamt{ 921.5Syamt 931.5Syamt return (ipl_cookie_t){._spl = ipl2spl_table[ipl]}; 941.5Syamt} 951.5Syamt 961.5Syamtstatic inline int 971.5Syamtsplraiseipl(ipl_cookie_t icookie) 981.5Syamt{ 991.5Syamt 1001.5Syamt return _splraise(icookie._spl); 1011.5Syamt} 1021.1Snisimura#endif /* _KERNEL */ 1031.1Snisimura 1041.1Snisimura#endif /* _MACHINE_INTR_H */ 105