]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/AT386/mp/mp.h
84339bfcfbe7963055d17577609c84b8fca91f57
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@
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
58 #include <platforms.h>
61 #include <mach_assert.h>
64 #include <i386/apic.h>
65 #include <i386/AT386/mp/mp_events.h>
67 #define CPU_NUMBER(r) \
68 movl EXT(lapic_id), r ; \
70 shrl $ LAPIC_ID_SHIFT, r; \
71 andl $ LAPIC_ID_MASK, r
74 #define MP_IPL SPL6 /* software interrupt level */
76 /* word describing the reason for the interrupt, one per cpu */
79 #include <kern/lock.h>
80 extern cpu_int_word
[];
81 extern real_ncpus
; /* real number of cpus */
82 extern wncpu
; /* wanted number of cpus */
83 decl_simple_lock_data(extern,kdb_lock
) /* kdb lock */
85 extern int kdb_cpu
; /* current cpu running kdb */
87 extern int kdb_is_slave
[];
88 extern int kdb_active
[];
89 #endif /* ASSEMBLER */
91 #define i_bit(bit, word) ((long)(*(word)) & ((long)1 << (bit)))
95 * Device driver synchronization.
97 * at386_io_lock(op) and at386_io_unlock() are called
98 * by device drivers when accessing H/W. The underlying
99 * Processing is machine dependant. But the op argument
100 * to the at386_io_lock is generic
103 #define MP_DEV_OP_MAX 4
104 #define MP_DEV_WAIT MP_DEV_OP_MAX /* Wait for the lock */
107 * If the caller specifies an op value different than MP_DEV_WAIT, the
108 * at386_io_lock function must return true if lock was successful else
112 #define MP_DEV_OP_START 0 /* If lock busy, register a pending start op */
113 #define MP_DEV_OP_INTR 1 /* If lock busy, register a pending intr */
114 #define MP_DEV_OP_TIMEO 2 /* If lock busy, register a pending timeout */
115 #define MP_DEV_OP_CALLB 3 /* If lock busy, register a pending callback */
117 #else /* NCPUS > 1 */
118 #define at386_io_lock_state()
119 #define at386_io_lock(op) (TRUE)
120 #define at386_io_unlock()
122 #include <i386/apic.h>
124 #endif /* NCPUS > 1 */
127 #define _DISABLE_PREEMPTION(r) \
128 movl $ CPD_PREEMPTION_LEVEL,r ; \
131 #define _ENABLE_PREEMPTION(r) \
132 movl $ CPD_PREEMPTION_LEVEL,r ; \
138 call EXT(kernel_preempt_check) ; \
144 #define _ENABLE_PREEMPTION_NO_CHECK(r) \
145 movl $ CPD_PREEMPTION_LEVEL,r ; \
149 #define DISABLE_PREEMPTION(r) \
153 call EXT(_disable_preemption); \
157 #define ENABLE_PREEMPTION(r) \
161 call EXT(_enable_preemption); \
165 #define ENABLE_PREEMPTION_NO_CHECK(r) \
169 call EXT(_enable_preemption_no_check); \
174 #define MP_DISABLE_PREEMPTION(r) \
178 call EXT(_mp_disable_preemption); \
182 #define MP_ENABLE_PREEMPTION(r) \
186 call EXT(_mp_enable_preemption); \
190 #define MP_ENABLE_PREEMPTION_NO_CHECK(r) \
194 call EXT(_mp_enable_preemption_no_check); \
198 #else /* NCPUS > 1 */
199 #define MP_DISABLE_PREEMPTION(r)
200 #define MP_ENABLE_PREEMPTION(r)
201 #define MP_ENABLE_PREEMPTION_NO_CHECK(r)
202 #endif /* NCPUS > 1 */
203 #else /* MACH_ASSERT */
204 #define DISABLE_PREEMPTION(r) _DISABLE_PREEMPTION(r)
205 #define ENABLE_PREEMPTION(r) _ENABLE_PREEMPTION(r)
206 #define ENABLE_PREEMPTION_NO_CHECK(r) _ENABLE_PREEMPTION_NO_CHECK(r)
208 #define MP_DISABLE_PREEMPTION(r) _DISABLE_PREEMPTION(r)
209 #define MP_ENABLE_PREEMPTION(r) _ENABLE_PREEMPTION(r)
210 #define MP_ENABLE_PREEMPTION_NO_CHECK(r) _ENABLE_PREEMPTION_NO_CHECK(r)
211 #else /* NCPUS > 1 */
212 #define MP_DISABLE_PREEMPTION(r)
213 #define MP_ENABLE_PREEMPTION(r)
214 #define MP_ENABLE_PREEMPTION_NO_CHECK(r)
215 #endif /* NCPUS > 1 */
216 #endif /* MACH_ASSERT */
219 #define DISABLE_PREEMPTION(r)
220 #define ENABLE_PREEMPTION(r)
221 #define ENABLE_PREEMPTION_NO_CHECK(r)
222 #define MP_DISABLE_PREEMPTION(r)
223 #define MP_ENABLE_PREEMPTION(r)
224 #define MP_ENABLE_PREEMPTION_NO_CHECK(r)
227 #endif /* _I386AT_MP_H_ */