]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/cpu_data.h
97fb613de3df5a6525ce5c18c819b82fe6c8aae4
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
31 #include <mach_assert.h>
35 #include <kern/assert.h>
36 #include <kern/kern_types.h>
45 * Everyone within the osfmk part of the kernel can use the fast
46 * inline versions of these routines. Everyone outside, must call
49 extern thread_t __inline__
current_thread_fast(void);
50 extern thread_t __inline__
current_thread_fast(void)
53 register int idx
= (int)&((cpu_data_t
*)0)->active_thread
;
55 __asm__
volatile (" movl %%gs:(%1),%0" : "=r" (ct
) : "r" (idx
));
60 #define current_thread() current_thread_fast()
62 extern int __inline__
get_preemption_level(void);
63 extern void __inline__
disable_preemption(void);
64 extern void __inline__
enable_preemption(void);
65 extern void __inline__
enable_preemption_no_check(void);
66 extern void __inline__
mp_disable_preemption(void);
67 extern void __inline__
mp_enable_preemption(void);
68 extern void __inline__
mp_enable_preemption_no_check(void);
69 extern int __inline__
get_simple_lock_count(void);
70 extern int __inline__
get_interrupt_level(void);
72 extern int __inline__
get_preemption_level(void)
74 register int idx
= (int)&((cpu_data_t
*)0)->preemption_level
;
77 __asm__
volatile (" movl %%gs:(%1),%0" : "=r" (pl
) : "r" (idx
));
82 extern void __inline__
disable_preemption(void)
85 extern void _disable_preemption(void);
87 _disable_preemption();
88 #else /* MACH_ASSERT */
89 register int idx
= (int)&((cpu_data_t
*)0)->preemption_level
;
91 __asm__
volatile (" incl %%gs:(%0)" : : "r" (idx
));
92 #endif /* MACH_ASSERT */
95 extern void __inline__
enable_preemption(void)
98 extern void _enable_preemption(void);
100 assert(get_preemption_level() > 0);
101 _enable_preemption();
102 #else /* MACH_ASSERT */
103 extern void kernel_preempt_check (void);
104 register int idx
= (int)&((cpu_data_t
*)0)->preemption_level
;
105 register void (*kpc
)(void)= kernel_preempt_check
;
107 __asm__
volatile ("decl %%gs:(%0); jne 1f; \
110 : "r" (idx
), "r" (kpc
)
111 : "%eax", "%ecx", "%edx", "cc", "memory");
112 #endif /* MACH_ASSERT */
115 extern void __inline__
enable_preemption_no_check(void)
118 extern void _enable_preemption_no_check(void);
120 assert(get_preemption_level() > 0);
121 _enable_preemption_no_check();
122 #else /* MACH_ASSERT */
123 register int idx
= (int)&((cpu_data_t
*)0)->preemption_level
;
125 __asm__
volatile ("decl %%gs:(%0)"
129 #endif /* MACH_ASSERT */
132 extern void __inline__
mp_disable_preemption(void)
135 disable_preemption();
136 #endif /* NCPUS > 1 */
139 extern void __inline__
mp_enable_preemption(void)
143 #endif /* NCPUS > 1 */
146 extern void __inline__
mp_enable_preemption_no_check(void)
149 enable_preemption_no_check();
150 #endif /* NCPUS > 1 */
153 extern int __inline__
get_simple_lock_count(void)
155 register int idx
= (int)&((cpu_data_t
*)0)->simple_lock_count
;
158 __asm__
volatile (" movl %%gs:(%1),%0" : "=r" (pl
) : "r" (idx
));
163 extern int __inline__
get_interrupt_level(void)
165 register int idx
= (int)&((cpu_data_t
*)0)->interrupt_level
;
168 __asm__
volatile (" movl %%gs:(%1),%0" : "=r" (pl
) : "r" (idx
));
179 #else /* !defined(__GNUC__) */
181 #endif /* defined(__GNUC__) */
183 #endif /* I386_CPU_DATA */