1*8cd0a7d1Schristos /* $NetBSD: psl.h,v 1.21 2016/01/23 21:39:18 christos Exp $ */
2c1f753f9Sreinoud
3c1f753f9Sreinoud /*
4c1f753f9Sreinoud * Copyright (c) 1995 Mark Brinicombe.
5c1f753f9Sreinoud * All rights reserved.
6c1f753f9Sreinoud *
7c1f753f9Sreinoud * Redistribution and use in source and binary forms, with or without
8c1f753f9Sreinoud * modification, are permitted provided that the following conditions
9c1f753f9Sreinoud * are met:
10c1f753f9Sreinoud * 1. Redistributions of source code must retain the above copyright
11c1f753f9Sreinoud * notice, this list of conditions and the following disclaimer.
12c1f753f9Sreinoud * 2. Redistributions in binary form must reproduce the above copyright
13c1f753f9Sreinoud * notice, this list of conditions and the following disclaimer in the
14c1f753f9Sreinoud * documentation and/or other materials provided with the distribution.
15c1f753f9Sreinoud * 3. All advertising materials mentioning features or use of this software
16c1f753f9Sreinoud * must display the following acknowledgement:
17c1f753f9Sreinoud * This product includes software developed by Mark Brinicombe
18c1f753f9Sreinoud * for the NetBSD Project.
19c1f753f9Sreinoud * 4. The name of the company nor the name of the author may be used to
20c1f753f9Sreinoud * endorse or promote products derived from this software without specific
21c1f753f9Sreinoud * prior written permission.
22c1f753f9Sreinoud *
23c1f753f9Sreinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24c1f753f9Sreinoud * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25c1f753f9Sreinoud * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26c1f753f9Sreinoud * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27c1f753f9Sreinoud * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28c1f753f9Sreinoud * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29c1f753f9Sreinoud * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30c1f753f9Sreinoud * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31c1f753f9Sreinoud * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32c1f753f9Sreinoud * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33c1f753f9Sreinoud * SUCH DAMAGE.
34c1f753f9Sreinoud *
35c1f753f9Sreinoud * RiscBSD kernel project
36c1f753f9Sreinoud *
37c1f753f9Sreinoud * psl.h
38c1f753f9Sreinoud *
39c1f753f9Sreinoud * spl prototypes.
40c1f753f9Sreinoud * Eventually this will become a set of defines.
41c1f753f9Sreinoud *
42c1f753f9Sreinoud * Created : 21/07/95
43c1f753f9Sreinoud */
44c1f753f9Sreinoud
45630f137aSbjh21 #ifndef _ARM_PSL_H_
46630f137aSbjh21 #define _ARM_PSL_H_
47c1f753f9Sreinoud #include <machine/intr.h>
48c1f753f9Sreinoud
49c1f753f9Sreinoud /*
50c1f753f9Sreinoud * These are the different SPL states
51c1f753f9Sreinoud *
52c1f753f9Sreinoud * Each state has an interrupt mask associated with it which
53c1f753f9Sreinoud * indicate which interrupts are allowed.
54c1f753f9Sreinoud */
55c1f753f9Sreinoud
56825088edSmatt #define spl0() splx(IPL_NONE)
57825088edSmatt #define splsoftclock() raisespl(IPL_SOFTCLOCK)
58825088edSmatt #define splsoftbio() raisespl(IPL_SOFTBIO)
59825088edSmatt #define splsoftnet() raisespl(IPL_SOFTNET)
60825088edSmatt #define splsoftserial() raisespl(IPL_SOFTSERIAL)
61825088edSmatt #define splvm() raisespl(IPL_VM)
62825088edSmatt #define splsched() raisespl(IPL_SCHED)
63825088edSmatt #define splhigh() raisespl(IPL_HIGH)
64c1f753f9Sreinoud
65f96ef7b3Smatt #define IPL_SAFEPRI IPL_NONE /* for kern_sleepq.c */
66f96ef7b3Smatt
67c1f753f9Sreinoud #ifdef _KERNEL
68c1f753f9Sreinoud #ifndef _LOCORE
69*8cd0a7d1Schristos #include <sys/types.h>
70*8cd0a7d1Schristos
710c0de807Smatt int raisespl (int);
720c0de807Smatt int lowerspl (int);
739a28c06bSnonaka void splx (int);
74c1f753f9Sreinoud
75d1d10b58Sthorpej typedef uint8_t ipl_t;
768bf76628Syamt typedef struct {
77825088edSmatt uint8_t _ipl;
788bf76628Syamt } ipl_cookie_t;
798bf76628Syamt
808bf76628Syamt static inline ipl_cookie_t
makeiplcookie(ipl_t ipl)818bf76628Syamt makeiplcookie(ipl_t ipl)
828bf76628Syamt {
838bf76628Syamt
84825088edSmatt return (ipl_cookie_t){._ipl = (uint8_t)ipl};
858bf76628Syamt }
868bf76628Syamt
878bf76628Syamt static inline int
splraiseipl(ipl_cookie_t icookie)888bf76628Syamt splraiseipl(ipl_cookie_t icookie)
898bf76628Syamt {
908bf76628Syamt
91825088edSmatt return raisespl(icookie._ipl);
928bf76628Syamt }
93c1f753f9Sreinoud #endif /* _LOCORE */
94c1f753f9Sreinoud #endif /* _KERNEL */
95c1f753f9Sreinoud
96630f137aSbjh21 #endif /* _ARM_PSL_H_ */
97c1f753f9Sreinoud /* End of psl.h */
98