xref: /minix3/sys/arch/arm/include/arm32/psl.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: psl.h,v 1.20 2014/02/04 18:51:16 matt Exp $	*/
202222606SBen Gras 
302222606SBen Gras /*
402222606SBen Gras  * Copyright (c) 1995 Mark Brinicombe.
502222606SBen Gras  * All rights reserved.
602222606SBen Gras  *
702222606SBen Gras  * Redistribution and use in source and binary forms, with or without
802222606SBen Gras  * modification, are permitted provided that the following conditions
902222606SBen Gras  * are met:
1002222606SBen Gras  * 1. Redistributions of source code must retain the above copyright
1102222606SBen Gras  *    notice, this list of conditions and the following disclaimer.
1202222606SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
1302222606SBen Gras  *    notice, this list of conditions and the following disclaimer in the
1402222606SBen Gras  *    documentation and/or other materials provided with the distribution.
1502222606SBen Gras  * 3. All advertising materials mentioning features or use of this software
1602222606SBen Gras  *    must display the following acknowledgement:
1702222606SBen Gras  *	This product includes software developed by Mark Brinicombe
1802222606SBen Gras  *	for the NetBSD Project.
1902222606SBen Gras  * 4. The name of the company nor the name of the author may be used to
2002222606SBen Gras  *    endorse or promote products derived from this software without specific
2102222606SBen Gras  *    prior written permission.
2202222606SBen Gras  *
2302222606SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
2402222606SBen Gras  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2502222606SBen Gras  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2602222606SBen Gras  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
2702222606SBen Gras  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2802222606SBen Gras  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2902222606SBen Gras  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3002222606SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3102222606SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3202222606SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3302222606SBen Gras  * SUCH DAMAGE.
3402222606SBen Gras  *
3502222606SBen Gras  * RiscBSD kernel project
3602222606SBen Gras  *
3702222606SBen Gras  * psl.h
3802222606SBen Gras  *
3902222606SBen Gras  * spl prototypes.
4002222606SBen Gras  * Eventually this will become a set of defines.
4102222606SBen Gras  *
4202222606SBen Gras  * Created      : 21/07/95
4302222606SBen Gras  */
4402222606SBen Gras 
4502222606SBen Gras #ifndef _ARM_PSL_H_
4602222606SBen Gras #define _ARM_PSL_H_
4702222606SBen Gras #include <machine/intr.h>
4802222606SBen Gras 
4902222606SBen Gras /*
5002222606SBen Gras  * These are the different SPL states
5102222606SBen Gras  *
5202222606SBen Gras  * Each state has an interrupt mask associated with it which
5302222606SBen Gras  * indicate which interrupts are allowed.
5402222606SBen Gras  */
5502222606SBen Gras 
5602222606SBen Gras #define spl0()		splx(IPL_NONE)
5702222606SBen Gras #define splsoftclock()	raisespl(IPL_SOFTCLOCK)
5802222606SBen Gras #define splsoftbio()	raisespl(IPL_SOFTBIO)
5902222606SBen Gras #define splsoftnet()	raisespl(IPL_SOFTNET)
6002222606SBen Gras #define splsoftserial()	raisespl(IPL_SOFTSERIAL)
6102222606SBen Gras #define splvm()		raisespl(IPL_VM)
6202222606SBen Gras #define splsched()	raisespl(IPL_SCHED)
6302222606SBen Gras #define splhigh()	raisespl(IPL_HIGH)
6402222606SBen Gras 
6502222606SBen Gras #define	IPL_SAFEPRI	IPL_NONE		/* for kern_sleepq.c */
6602222606SBen Gras 
6702222606SBen Gras #ifdef _KERNEL
6802222606SBen Gras #ifndef _LOCORE
6902222606SBen Gras int raisespl	(int);
7002222606SBen Gras int lowerspl	(int);
7102222606SBen Gras void splx	(int);
7202222606SBen Gras 
7302222606SBen Gras typedef uint8_t ipl_t;
7402222606SBen Gras typedef struct {
7502222606SBen Gras 	uint8_t _ipl;
7602222606SBen Gras } ipl_cookie_t;
7702222606SBen Gras 
7802222606SBen Gras static inline ipl_cookie_t
makeiplcookie(ipl_t ipl)7902222606SBen Gras makeiplcookie(ipl_t ipl)
8002222606SBen Gras {
8102222606SBen Gras 
8202222606SBen Gras 	return (ipl_cookie_t){._ipl = (uint8_t)ipl};
8302222606SBen Gras }
8402222606SBen Gras 
8502222606SBen Gras static inline int
splraiseipl(ipl_cookie_t icookie)8602222606SBen Gras splraiseipl(ipl_cookie_t icookie)
8702222606SBen Gras {
8802222606SBen Gras 
8902222606SBen Gras 	return raisespl(icookie._ipl);
9002222606SBen Gras }
9102222606SBen Gras #endif /* _LOCORE */
9202222606SBen Gras #endif /* _KERNEL */
9302222606SBen Gras 
9402222606SBen Gras #endif /* _ARM_PSL_H_ */
9502222606SBen Gras /* End of psl.h */
96