1.\" $OpenBSD: spl.9,v 1.7 2000/11/09 01:23:10 aaron Exp $ 2.\" $NetBSD: spl.9,v 1.1 1997/03/11 06:15:05 mikel Exp $ 3.\" 4.\" Copyright (c) 1997 Michael Long. 5.\" Copyright (c) 1997 Jonathan Stone. 6.\" All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. All advertising materials mentioning features or use of this software 17.\" must display the following acknowledgement: 18.\" This product includes software developed by Michael Long. 19.\" 4. The name of the author may not be used to endorse or promote products 20.\" derived from this software without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32.\" 33.Dd March 11, 1997 34.Dt SPL 9 35.Os 36.Sh NAME 37.Nm spl 38.Nd modify system interrupt priority level 39.Sh SYNOPSIS 40.Fd #include <machine/intr.h> 41.Ft int 42.Fn splhigh void 43.Ft int 44.Fn splserial void 45.Ft int 46.Fn splsched void 47.Ft int 48.Fn splclock void 49.Ft int 50.Fn splstatclock void 51.Ft int 52.Fn splimp void 53.Ft int 54.Fn spltty void 55.Ft int 56.Fn splsofttty void 57.Ft int 58.Fn splnet void 59.Ft int 60.Fn splbio void 61.Ft int 62.Fn splsoftnet void 63.Ft int 64.Fn splsoftclock void 65.Ft int 66.Fn spllowersoftclock void 67.Ft int 68.Fn spl0 void 69.Ft void 70.Fn splx "int s" 71.Sh DESCRIPTION 72These functions raise and lower the system priority level. 73They are used by kernel code to block interrupts with priority less 74than or equal to the named level (i.e., 75.Fn spltty 76blocks interrupts of priority less than or equal to 77.Dv IPL_TTY ) . 78The code may then safely access variables and data structures which 79are used by kernel code that runs at an equal or lower priority level. 80.Pp 81A 82.Nm 83function exists for each distinct priority level which can exist in 84the system. 85These macros and the corresponding priority levels are 86used for various defined purposes, and may be divided into two main 87types: hard and soft. 88Hard interrupts are generated by hardware 89devices, while soft interrupts are generated by callouts and called 90from the kernel's periodic timer interrupt service routine. 91.Pp 92In order of highest to lowest priority, the priority-raising macros 93are: 94.Bl -tag -width splsoftclockXX 95.It Fn splhigh 96blocks all hard and soft interrupts. 97It is used for code that cannot 98tolerate any interrupts, like hardware context switching code and the 99.Xr ddb 4 100in-kernel debugger. 101.It Fn splserial 102blocks hard interrupts from serial interfaces. 103Code running at this level may not access the tty subsystem. 104.It Fn splsched 105blocks interrupts that may access scheduler data structures. 106Code running at or above this level may not call 107.Fn sleep , 108.Fn tsleep , 109or 110.Fn wakeup , 111nor may it post signals. 112.It Fn splclock 113blocks the hardware clock interrupt. 114It is used by 115.Fn hardclock 116to update kernel and process times, and must be used by any other code 117that accesses time-related data. 118.It Fn splstatclock 119blocks the hardware statistics clock interrupt. 120It is used by 121.Fn statclock 122to update kernel profiling and other statistics, and must be used by 123any code that accesses that data. 124This level is identical to 125.Fn splclock 126if there is no separate statistics clock. 127.It Fn splimp 128blocks hard interrupts from all devices that are allowed to use the 129kernel 130.Xr malloc 9 . 131That includes all disk, network, and tty device interrupts. 132.It Fn spltty 133blocks hard interrupts from TTY devices. 134.It Fn splsofttty 135blocks soft interrupts generated by serial devices. 136.It Fn splnet 137blocks hard interrupts from network interfaces. 138.It Fn splbio 139blocks hard interrupts from disks and other mass-storage devices. 140.It Fn splsoftnet 141blocks soft network interrupts. 142.It Fn splsoftclock 143blocks soft clock interrupts. 144.El 145.Pp 146Two macros lower the system priority level. 147They are: 148.Bl -tag -width spllowersoftclockXX 149.It Fn spllowersoftclock 150unblocks all interrupts but the soft clock interrupt. 151.It Fn spl0 152unblocks all interrupts. 153.El 154.Pp 155The 156.Fn splx 157macro restores the system priority level to the one encoded in 158.Fa s , 159which must be a value previously returned by one of the other 160.Nm 161macros. 162