root/kern/include/spl.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. spl0
  2. splhigh

   1 /*
   2  * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
   3  *      The President and Fellows of Harvard College.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. Neither the name of the University nor the names of its contributors
  14  *    may be used to endorse or promote products derived from this software
  15  *    without specific prior written permission.
  16  *
  17  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27  * SUCH DAMAGE.
  28  */
  29 
  30 #ifndef _SPL_H_
  31 #define _SPL_H_
  32 
  33 #include <cdefs.h>
  34 
  35 /*
  36  * Machine-independent interface to interrupt enable/disable.
  37  *
  38  * "spl" stands for "set priority level", and was originally the name of
  39  * a VAX assembler instruction.
  40  *
  41  * The idea is that one can block less important interrupts while
  42  * processing them, but still allow more urgent interrupts to interrupt
  43  * that processing.
  44  *
  45  * Ordinarily there would be a whole bunch of defined interrupt
  46  * priority levels and functions for setting them - spltty(),
  47  * splbio(), etc., etc. But we don't support interrupt priorities in
  48  * OS/161, so there are only three:
  49  *
  50  *      spl0()       sets IPL to 0, enabling all interrupts.
  51  *      splhigh()    sets IPL to the highest value, disabling all interrupts.
  52  *      splx(s)      sets IPL to S, enabling whatever state S represents.
  53  *
  54  * All three return the old interrupt state. Thus, these are commonly used
  55  * as follows:
  56  *
  57  *      int s = splhigh();
  58  *      [ code ]
  59  *      splx(s);
  60  *
  61  * Note that these functions only affect interrupts on the current
  62  * processor.
  63  */
  64 
  65 int spl0(void);
  66 int splhigh(void);
  67 int splx(int);
  68 
  69 /*
  70  * Integer interrupt priority levels.
  71  */
  72 #define IPL_NONE   0
  73 #define IPL_HIGH   1
  74 
  75 /*
  76  * Lower-level functions for explicitly raising and lowering
  77  * particular interrupt levels. These are used by splx() and by the
  78  * spinlock code.
  79  *
  80  * A previous setting of OLDIPL is cancelled and replaced with NEWIPL.
  81  *
  82  * For splraise, NEWIPL > OLDIPL, and for spllower, NEWIPL < OLDIPL.
  83  */
  84 void splraise(int oldipl, int newipl);
  85 void spllower(int oldipl, int newipl);
  86 
  87 ////////////////////////////////////////////////////////////
  88 
  89 /* Inlining support - for making sure an out-of-line copy gets built */
  90 #ifndef SPL_INLINE
  91 #define SPL_INLINE INLINE
  92 #endif
  93 
  94 SPL_INLINE
  95 int
  96 spl0(void)
  97 {
  98         return splx(IPL_NONE);
  99 }
 100 
 101 SPL_INLINE
 102 int
 103 splhigh(void)
 104 {
 105         return splx(IPL_HIGH);
 106 }
 107 
 108 
 109 #endif /* _SPL_H_ */

/* [<][>][^][v][top][bottom][index][help] */