]> git.saurik.com Git - apple/xnu.git/blob - pexpert/i386/pe_spl.c
xnu-344.49.tar.gz
[apple/xnu.git] / pexpert / i386 / pe_spl.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 #include <pexpert/protos.h>
26
27
28 typedef unsigned long spl_t;
29
30 spl_t PE_set_spl(spl_t x);
31
32 spl_t splhi() { return PE_set_spl(8); }
33 spl_t splhigh() { return PE_set_spl(8); }
34 spl_t splclock() { return PE_set_spl(8); }
35 spl_t splvm() { return PE_set_spl(8); }
36 spl_t splsched() { return PE_set_spl(8); }
37 spl_t splimp() { return PE_set_spl(6); }
38 void splx(spl_t x) { (void) PE_set_spl(x); }
39 spl_t splnet() { return PE_set_spl(6); }
40 void spllo() { (void) PE_set_spl(0); }
41 spl_t spl1() { return PE_set_spl(1); }
42 spl_t spl2() { return PE_set_spl(2); }
43 spl_t spl3() { return PE_set_spl(3); }
44 spl_t spl4() { return PE_set_spl(4); }
45 spl_t spl5() { return PE_set_spl(5); }
46 spl_t spl6() { return PE_set_spl(6); }
47 spl_t splbio() { return PE_set_spl(5); }
48 spl_t spltty() { return PE_set_spl(6); }
49
50 spl_t sploff() { return PE_set_spl(8); }
51 void splon(spl_t x) { (void) PE_set_spl(x); }
52
53 spl_t PE_set_spl(spl_t lvl)
54 {
55 spl_t old_level;
56 int mycpu;
57
58
59 __asm__ volatile("cli");
60
61 mycpu = cpu_number();
62 old_level = cpu_data[mycpu].spl_level;
63 cpu_data[mycpu].spl_level = lvl ;
64
65 if (!lvl) __asm__ volatile("sti");
66
67 return old_level;
68 }
69
70 void PE_set_spl_no_interrupt(spl_t lvl)
71 {
72 int mycpu;
73
74 __asm__ volatile("cli");
75
76 mycpu = cpu_number();
77 cpu_data[mycpu].spl_level = lvl ;
78
79 return;
80 }
81