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