]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/AT386/mp/mp.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
29 * Mach Operating System
30 * Copyright (c) 1991,1990 Carnegie Mellon University
31 * All Rights Reserved.
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
61 #include <platforms.h>
64 #include <mach_assert.h>
67 #include <i386/apic.h>
68 #include <i386/AT386/mp/mp_events.h>
70 #define CPU_NUMBER(r) \
71 movl EXT(lapic_id), r ; \
73 shrl $ LAPIC_ID_SHIFT, r; \
74 andl $ LAPIC_ID_MASK, r
77 #define MP_IPL SPL6 /* software interrupt level */
79 /* word describing the reason for the interrupt, one per cpu */
82 #include <kern/lock.h>
83 extern cpu_int_word
[];
84 extern real_ncpus
; /* real number of cpus */
85 extern wncpu
; /* wanted number of cpus */
86 decl_simple_lock_data(extern,kdb_lock
) /* kdb lock */
88 extern int kdb_cpu
; /* current cpu running kdb */
90 extern int kdb_is_slave
[];
91 extern int kdb_active
[];
92 #endif /* ASSEMBLER */
94 #define i_bit(bit, word) ((long)(*(word)) & ((long)1 << (bit)))
98 * Device driver synchronization.
100 * at386_io_lock(op) and at386_io_unlock() are called
101 * by device drivers when accessing H/W. The underlying
102 * Processing is machine dependant. But the op argument
103 * to the at386_io_lock is generic
106 #define MP_DEV_OP_MAX 4
107 #define MP_DEV_WAIT MP_DEV_OP_MAX /* Wait for the lock */
110 * If the caller specifies an op value different than MP_DEV_WAIT, the
111 * at386_io_lock function must return true if lock was successful else
115 #define MP_DEV_OP_START 0 /* If lock busy, register a pending start op */
116 #define MP_DEV_OP_INTR 1 /* If lock busy, register a pending intr */
117 #define MP_DEV_OP_TIMEO 2 /* If lock busy, register a pending timeout */
118 #define MP_DEV_OP_CALLB 3 /* If lock busy, register a pending callback */
120 #else /* NCPUS > 1 */
121 #define at386_io_lock_state()
122 #define at386_io_lock(op) (TRUE)
123 #define at386_io_unlock()
125 #include <i386/apic.h>
127 #endif /* NCPUS > 1 */
130 #define _DISABLE_PREEMPTION(r) \
131 movl $ CPD_PREEMPTION_LEVEL,r ; \
134 #define _ENABLE_PREEMPTION(r) \
135 movl $ CPD_PREEMPTION_LEVEL,r ; \
141 call EXT(kernel_preempt_check) ; \
147 #define _ENABLE_PREEMPTION_NO_CHECK(r) \
148 movl $ CPD_PREEMPTION_LEVEL,r ; \
152 #define DISABLE_PREEMPTION(r) \
156 call EXT(_disable_preemption); \
160 #define ENABLE_PREEMPTION(r) \
164 call EXT(_enable_preemption); \
168 #define ENABLE_PREEMPTION_NO_CHECK(r) \
172 call EXT(_enable_preemption_no_check); \
177 #define MP_DISABLE_PREEMPTION(r) \
181 call EXT(_mp_disable_preemption); \
185 #define MP_ENABLE_PREEMPTION(r) \
189 call EXT(_mp_enable_preemption); \
193 #define MP_ENABLE_PREEMPTION_NO_CHECK(r) \
197 call EXT(_mp_enable_preemption_no_check); \
201 #else /* NCPUS > 1 */
202 #define MP_DISABLE_PREEMPTION(r)
203 #define MP_ENABLE_PREEMPTION(r)
204 #define MP_ENABLE_PREEMPTION_NO_CHECK(r)
205 #endif /* NCPUS > 1 */
206 #else /* MACH_ASSERT */
207 #define DISABLE_PREEMPTION(r) _DISABLE_PREEMPTION(r)
208 #define ENABLE_PREEMPTION(r) _ENABLE_PREEMPTION(r)
209 #define ENABLE_PREEMPTION_NO_CHECK(r) _ENABLE_PREEMPTION_NO_CHECK(r)
211 #define MP_DISABLE_PREEMPTION(r) _DISABLE_PREEMPTION(r)
212 #define MP_ENABLE_PREEMPTION(r) _ENABLE_PREEMPTION(r)
213 #define MP_ENABLE_PREEMPTION_NO_CHECK(r) _ENABLE_PREEMPTION_NO_CHECK(r)
214 #else /* NCPUS > 1 */
215 #define MP_DISABLE_PREEMPTION(r)
216 #define MP_ENABLE_PREEMPTION(r)
217 #define MP_ENABLE_PREEMPTION_NO_CHECK(r)
218 #endif /* NCPUS > 1 */
219 #endif /* MACH_ASSERT */
222 #define DISABLE_PREEMPTION(r)
223 #define ENABLE_PREEMPTION(r)
224 #define ENABLE_PREEMPTION_NO_CHECK(r)
225 #define MP_DISABLE_PREEMPTION(r)
226 #define MP_ENABLE_PREEMPTION(r)
227 #define MP_ENABLE_PREEMPTION_NO_CHECK(r)
230 #endif /* _I386AT_MP_H_ */