1 /* $NetBSD: intr.h,v 1.13 2011/12/22 15:06:17 tsutsui Exp $ */ 2 3 /* 4 * Copyright (c) 1988 University of Utah. 5 * Copyright (c) 1982, 1986, 1990, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * the Systems Programming Group of the University of Utah Computer 10 * Science Department. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: Utah $Hdr: machparam.h 1.16 92/12/20$ 37 * 38 * from: @(#)param.h 8.1 (Berkeley) 6/10/93 39 */ 40 41 #ifndef _CESFIC_INTR_H_ 42 #define _CESFIC_INTR_H_ 43 44 /* 45 * spl functions; all but spl0 are done in-line 46 */ 47 #include <machine/psl.h> 48 49 #if defined(_KERNEL) && !defined(_LOCORE) 50 /* spl0 requires checking for software interrupts */ 51 #define spl1() _spl(PSL_S|PSL_IPL1) 52 #define spl2() _spl(PSL_S|PSL_IPL2) 53 #define spl3() _spl(PSL_S|PSL_IPL3) 54 #define spl4() _spl(PSL_S|PSL_IPL4) 55 #define spl5() _spl(PSL_S|PSL_IPL5) 56 #define spl6() _spl(PSL_S|PSL_IPL6) 57 #define spl7() _spl(PSL_S|PSL_IPL7) 58 59 /* These spl calls are used by machine-independent code. */ 60 #define splsoftclock() splraise1() 61 #define splsoftbio() splraise1() 62 #define splsoftnet() splraise1() 63 #define splsoftserial() splraise1() 64 #define splvm() splraise4() 65 #define splsched() spl6() 66 #define splhigh() spl7() 67 68 /* watch out for side effects */ 69 #define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) 70 71 int spl0(void); 72 73 #define IPL_NONE 0 74 #define IPL_SOFTCLOCK 1 75 #define IPL_SOFTBIO 1 76 #define IPL_SOFTNET 3 77 #define IPL_SOFTSERIAL 4 78 #define IPL_VM 5 79 #define IPL_SCHED 6 80 #define IPL_HIGH 7 81 #define NIPL 8 82 83 extern const uint16_t ipl2psl_table[NIPL]; 84 85 typedef int ipl_t; 86 typedef struct { 87 uint16_t _psl; 88 } ipl_cookie_t; 89 90 static inline ipl_cookie_t 91 makeiplcookie(ipl_t ipl) 92 { 93 94 return (ipl_cookie_t){._psl = ipl2psl_table[ipl]}; 95 } 96 97 static inline int 98 splraiseipl(ipl_cookie_t icookie) 99 { 100 101 return _splraise(icookie._psl); 102 } 103 104 #endif /* _KERNEL && !_LOCORE */ 105 106 #endif /* !_CESFIC_INTR_H_ */ 107