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