intr.h revision 1.14
11.14Sriastrad/* $NetBSD: intr.h,v 1.14 2023/07/11 10:47:24 riastradh 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.14Sriastrad#ifndef _LOCORE 501.14Sriastrad 511.14Sriastradtypedef struct { 521.14Sriastrad uint16_t _psl; 531.14Sriastrad} ipl_cookie_t; 541.14Sriastrad 551.14Sriastrad#endif 561.14Sriastrad 571.2Skleink#if defined(_KERNEL) && !defined(_LOCORE) 581.2Skleink/* spl0 requires checking for software interrupts */ 591.2Skleink#define spl1() _spl(PSL_S|PSL_IPL1) 601.2Skleink#define spl2() _spl(PSL_S|PSL_IPL2) 611.2Skleink#define spl3() _spl(PSL_S|PSL_IPL3) 621.2Skleink#define spl4() _spl(PSL_S|PSL_IPL4) 631.2Skleink#define spl5() _spl(PSL_S|PSL_IPL5) 641.2Skleink#define spl6() _spl(PSL_S|PSL_IPL6) 651.2Skleink#define spl7() _spl(PSL_S|PSL_IPL7) 661.2Skleink 671.2Skleink/* These spl calls are used by machine-independent code. */ 681.9Sad#define splsoftclock() splraise1() 691.9Sad#define splsoftbio() splraise1() 701.9Sad#define splsoftnet() splraise1() 711.9Sad#define splsoftserial() splraise1() 721.10Stsutsui#define splvm() splraise4() 731.9Sad#define splsched() spl6() 741.2Skleink#define splhigh() spl7() 751.2Skleink 761.2Skleink/* watch out for side effects */ 771.2Skleink#define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) 781.2Skleink 791.11Sdslint spl0(void); 801.5Syamt 811.5Syamt#define IPL_NONE 0 821.5Syamt#define IPL_SOFTCLOCK 1 831.9Sad#define IPL_SOFTBIO 1 841.9Sad#define IPL_SOFTNET 3 851.9Sad#define IPL_SOFTSERIAL 4 861.9Sad#define IPL_VM 5 871.9Sad#define IPL_SCHED 6 881.9Sad#define IPL_HIGH 7 891.9Sad#define NIPL 8 901.5Syamt 911.10Stsutsuiextern const uint16_t ipl2psl_table[NIPL]; 921.5Syamt 931.5Syamttypedef int ipl_t; 941.5Syamt 951.5Syamtstatic inline ipl_cookie_t 961.5Syamtmakeiplcookie(ipl_t ipl) 971.5Syamt{ 981.5Syamt 991.10Stsutsui return (ipl_cookie_t){._psl = ipl2psl_table[ipl]}; 1001.5Syamt} 1011.5Syamt 1021.5Syamtstatic inline int 1031.5Syamtsplraiseipl(ipl_cookie_t icookie) 1041.5Syamt{ 1051.5Syamt 1061.10Stsutsui return _splraise(icookie._psl); 1071.5Syamt} 1081.7Stsutsui 1091.2Skleink#endif /* _KERNEL && !_LOCORE */ 1101.2Skleink 1111.2Skleink#endif /* !_CESFIC_INTR_H_ */ 112