os161-1.99
 All Data Structures
spl.h
00001 /*
00002  * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
00003  *      The President and Fellows of Harvard College.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  */
00029 
00030 #ifndef _SPL_H_
00031 #define _SPL_H_
00032 
00033 #include <cdefs.h>
00034 
00035 /*
00036  * Machine-independent interface to interrupt enable/disable.
00037  *
00038  * "spl" stands for "set priority level", and was originally the name of
00039  * a VAX assembler instruction.
00040  *
00041  * The idea is that one can block less important interrupts while
00042  * processing them, but still allow more urgent interrupts to interrupt
00043  * that processing.
00044  *
00045  * Ordinarily there would be a whole bunch of defined interrupt
00046  * priority levels and functions for setting them - spltty(),
00047  * splbio(), etc., etc. But we don't support interrupt priorities in
00048  * OS/161, so there are only three:
00049  *
00050  *      spl0()       sets IPL to 0, enabling all interrupts.
00051  *      splhigh()    sets IPL to the highest value, disabling all interrupts.
00052  *      splx(s)      sets IPL to S, enabling whatever state S represents.
00053  *
00054  * All three return the old interrupt state. Thus, these are commonly used
00055  * as follows:
00056  *
00057  *      int s = splhigh();
00058  *      [ code ]
00059  *      splx(s);
00060  *
00061  * Note that these functions only affect interrupts on the current
00062  * processor.
00063  */
00064 
00065 int spl0(void);
00066 int splhigh(void);
00067 int splx(int);
00068 
00069 /*
00070  * Integer interrupt priority levels.
00071  */
00072 #define IPL_NONE   0
00073 #define IPL_HIGH   1
00074 
00075 /*
00076  * Lower-level functions for explicitly raising and lowering
00077  * particular interrupt levels. These are used by splx() and by the
00078  * spinlock code.
00079  *
00080  * A previous setting of OLDIPL is cancelled and replaced with NEWIPL.
00081  *
00082  * For splraise, NEWIPL > OLDIPL, and for spllower, NEWIPL < OLDIPL.
00083  */
00084 void splraise(int oldipl, int newipl);
00085 void spllower(int oldipl, int newipl);
00086 
00087 ////////////////////////////////////////////////////////////
00088 
00089 /* Inlining support - for making sure an out-of-line copy gets built */
00090 #ifndef SPL_INLINE
00091 #define SPL_INLINE INLINE
00092 #endif
00093 
00094 SPL_INLINE
00095 int
00096 spl0(void)
00097 {
00098         return splx(IPL_NONE);
00099 }
00100 
00101 SPL_INLINE
00102 int
00103 splhigh(void)
00104 {
00105         return splx(IPL_HIGH);
00106 }
00107 
00108 
00109 #endif /* _SPL_H_ */
 All Data Structures