psl.h revision 1.8
11.8Smatt/* $NetBSD: psl.h,v 1.8 2007/02/18 07:13:17 matt Exp $ */ 21.1Sreinoud 31.1Sreinoud/* 41.1Sreinoud * Copyright (c) 1995 Mark Brinicombe. 51.1Sreinoud * All rights reserved. 61.1Sreinoud * 71.1Sreinoud * Redistribution and use in source and binary forms, with or without 81.1Sreinoud * modification, are permitted provided that the following conditions 91.1Sreinoud * are met: 101.1Sreinoud * 1. Redistributions of source code must retain the above copyright 111.1Sreinoud * notice, this list of conditions and the following disclaimer. 121.1Sreinoud * 2. Redistributions in binary form must reproduce the above copyright 131.1Sreinoud * notice, this list of conditions and the following disclaimer in the 141.1Sreinoud * documentation and/or other materials provided with the distribution. 151.1Sreinoud * 3. All advertising materials mentioning features or use of this software 161.1Sreinoud * must display the following acknowledgement: 171.1Sreinoud * This product includes software developed by Mark Brinicombe 181.1Sreinoud * for the NetBSD Project. 191.1Sreinoud * 4. The name of the company nor the name of the author may be used to 201.1Sreinoud * endorse or promote products derived from this software without specific 211.1Sreinoud * prior written permission. 221.1Sreinoud * 231.1Sreinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 241.1Sreinoud * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 251.1Sreinoud * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 261.1Sreinoud * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 271.1Sreinoud * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 281.1Sreinoud * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 291.1Sreinoud * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301.1Sreinoud * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311.1Sreinoud * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321.1Sreinoud * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331.1Sreinoud * SUCH DAMAGE. 341.1Sreinoud * 351.1Sreinoud * RiscBSD kernel project 361.1Sreinoud * 371.1Sreinoud * psl.h 381.1Sreinoud * 391.1Sreinoud * spl prototypes. 401.1Sreinoud * Eventually this will become a set of defines. 411.1Sreinoud * 421.1Sreinoud * Created : 21/07/95 431.1Sreinoud */ 441.1Sreinoud 451.4Sbjh21#ifndef _ARM_PSL_H_ 461.4Sbjh21#define _ARM_PSL_H_ 471.1Sreinoud#include <machine/intr.h> 481.8Smatt#ifndef _LOCORE 491.8Smatt#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS 501.8Smatt#include <arm/softintr.h> 511.8Smatt#endif 521.8Smatt#endif 531.1Sreinoud 541.1Sreinoud/* 551.1Sreinoud * These are the different SPL states 561.1Sreinoud * 571.1Sreinoud * Each state has an interrupt mask associated with it which 581.1Sreinoud * indicate which interrupts are allowed. 591.1Sreinoud */ 601.1Sreinoud 611.1Sreinoud#define _SPL_0 0 621.8Smatt#define _SPL_SOFT 1 631.1Sreinoud#define _SPL_SOFTCLOCK 1 641.1Sreinoud#define _SPL_SOFTNET 2 651.1Sreinoud#define _SPL_BIO 3 661.1Sreinoud#define _SPL_NET 4 671.1Sreinoud#define _SPL_SOFTSERIAL 5 681.1Sreinoud#define _SPL_TTY 6 691.6Sthorpej#define _SPL_VM 7 701.1Sreinoud#define _SPL_AUDIO 8 711.1Sreinoud#define _SPL_CLOCK 9 721.5Srearnsha#define _SPL_STATCLOCK 10 731.5Srearnsha#define _SPL_HIGH 11 741.5Srearnsha#define _SPL_SERIAL 12 751.5Srearnsha#define _SPL_LEVELS 13 761.1Sreinoud 771.1Sreinoud#define spl0() splx(_SPL_0) 781.8Smatt#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS 791.8Smatt#define splsoft() raisespl(_SPL_SOFT) 801.8Smatt#endif 811.1Sreinoud#define splsoftnet() raisespl(_SPL_SOFTNET) 821.1Sreinoud#define spllowersoftclock() lowerspl(_SPL_SOFTCLOCK) 831.1Sreinoud#define splsoftclock() raisespl(_SPL_SOFTCLOCK) 841.1Sreinoud#define splbio() raisespl(_SPL_BIO) 851.1Sreinoud#define splnet() raisespl(_SPL_NET) 861.1Sreinoud#define splsoftserial() raisespl(_SPL_SOFTSERIAL) 871.1Sreinoud#define spltty() raisespl(_SPL_TTY) 881.1Sreinoud#define spllpt() spltty() 891.6Sthorpej#define splvm() raisespl(_SPL_VM) 901.1Sreinoud#define splaudio() raisespl(_SPL_AUDIO) 911.1Sreinoud#define splclock() raisespl(_SPL_CLOCK) 921.5Srearnsha#define splstatclock() raisespl(_SPL_STATCLOCK) 931.1Sreinoud#define splserial() raisespl(_SPL_SERIAL) 941.1Sreinoud#define splhigh() raisespl(_SPL_HIGH) 951.1Sreinoud 961.1Sreinoud#define splsched() splhigh() 971.1Sreinoud#define spllock() splhigh() 981.1Sreinoud 991.1Sreinoud#ifdef _KERNEL 1001.1Sreinoud#ifndef _LOCORE 1011.1Sreinoudint raisespl __P((int)); 1021.1Sreinoudint lowerspl __P((int)); 1031.1Sreinoudint splx __P((int)); 1041.1Sreinoud 1051.8Smatt#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS 1061.8Smattvoid _setsoftintr (int si); 1071.8Smatt#else 1081.1Sreinoudvoid setsoftast __P((void)); 1091.1Sreinoudvoid setsoftclock __P((void)); 1101.1Sreinoudvoid setsoftnet __P((void)); 1111.1Sreinoudvoid setsoftserial __P((void)); 1121.1Sreinoudvoid setsoftintr __P((u_int intrmask)); 1131.8Smatt#endif 1141.1Sreinoud 1151.1Sreinoudextern int current_spl_level; 1161.1Sreinoud 1171.2Stoshiiextern u_int spl_masks[_SPL_LEVELS + 1]; 1181.1Sreinoudextern u_int spl_smasks[_SPL_LEVELS]; 1191.7Syamt 1201.7Syamttypedef int ipl_t; 1211.7Syamttypedef struct { 1221.7Syamt int _spl; 1231.7Syamt} ipl_cookie_t; 1241.7Syamt 1251.7Syamtint ipl_to_spl(ipl_t); 1261.7Syamt 1271.7Syamtstatic inline ipl_cookie_t 1281.7Syamtmakeiplcookie(ipl_t ipl) 1291.7Syamt{ 1301.7Syamt 1311.7Syamt return (ipl_cookie_t){._spl = ipl_to_spl(ipl)}; 1321.7Syamt} 1331.7Syamt 1341.7Syamtstatic inline int 1351.7Syamtsplraiseipl(ipl_cookie_t icookie) 1361.7Syamt{ 1371.7Syamt 1381.7Syamt return raisespl(icookie._spl); 1391.7Syamt} 1401.1Sreinoud#endif /* _LOCORE */ 1411.1Sreinoud#endif /* _KERNEL */ 1421.1Sreinoud 1431.4Sbjh21#endif /* _ARM_PSL_H_ */ 1441.1Sreinoud/* End of psl.h */ 145