]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/ast.h
afc8d5a24929ae97f7a119738e32ef23da756d89
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
27 * Mach Operating System
28 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
29 * All Rights Reserved.
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 * Carnegie Mellon requests users of this software to return to
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
55 * kern/ast.h: Definitions for Asynchronous System Traps.
61 #include <platforms.h>
63 #include <kern/assert.h>
64 #include <kern/macro_help.h>
65 #include <kern/lock.h>
67 #include <machine/ast.h>
70 * A processor takes an AST when it is about to return from an
71 * interrupt context, and calls ast_taken.
73 * Machine-dependent code is responsible for maintaining
74 * a set of reasons for an AST, and passing this set to ast_taken.
76 typedef uint32_t ast_t
;
81 #define AST_PREEMPT 0x01
82 #define AST_QUANTUM 0x02
83 #define AST_URGENT 0x04
84 #define AST_HANDOFF 0x08
85 #define AST_YIELD 0x10
86 #define AST_APC 0x20 /* migration APC hook */
88 * JMM - This is here temporarily. AST_BSD is used to simulate a
89 * general purpose mechanism for setting asynchronous procedure calls
95 #define AST_ALL (~AST_NONE)
97 #define AST_SCHEDULING (AST_PREEMPTION | AST_YIELD | AST_HANDOFF)
98 #define AST_PREEMPTION (AST_PREEMPT | AST_QUANTUM | AST_URGENT)
102 * machine/ast.h is responsible for defining aston and astoff.
104 #else /* MACHINE_AST */
107 #define astoff(mycpu)
109 #endif /* MACHINE_AST */
111 /* Initialize module */
112 extern void ast_init(void);
115 extern void ast_taken(
119 /* Check for pending ASTs */
120 extern void ast_check(
121 processor_t processor
);
123 /* Pending ast mask for the current processor */
124 extern ast_t
*ast_pending(void);
127 * Per-thread ASTs are reset at context-switch time.
129 #ifndef MACHINE_AST_PER_THREAD
130 #define MACHINE_AST_PER_THREAD 0
133 #define AST_PER_THREAD (AST_APC | AST_BSD | MACHINE_AST_PER_THREAD)
135 * ast_pending(), ast_on(), ast_off(), ast_context(), and ast_propagate()
139 #define ast_on_fast(reasons) \
141 ast_t *myast = ast_pending(); \
143 if ((*myast |= (reasons)) != AST_NONE) \
147 #define ast_off_fast(reasons) \
149 ast_t *myast = ast_pending(); \
151 if ((*myast &= ~(reasons)) == AST_NONE) \
155 #define ast_propagate(reasons) ast_on(reasons)
157 #define ast_context(act) \
159 ast_t *myast = ast_pending(); \
161 if ((*myast = ((*myast &~ AST_PER_THREAD) | (act)->ast)) != AST_NONE) \
167 #define ast_on(reason) ast_on_fast(reason)
168 #define ast_off(reason) ast_off_fast(reason)
171 * NOTE: if thread is the current thread, thread_ast_set() should
172 * be followed by ast_propagate().
174 #define thread_ast_set(act, reason) \
175 (hw_atomic_or(&(act)->ast, (reason)))
176 #define thread_ast_clear(act, reason) \
177 (hw_atomic_and(&(act)->ast, ~(reason)))
178 #define thread_ast_clear_all(act) \
179 (hw_atomic_and(&(act)->ast, AST_NONE))
183 extern void astbsd_on(void);
184 extern void act_set_astbsd(thread_t
);
185 extern void bsd_ast(thread_t
);
187 #endif /* MACH_BSD */
189 #endif /* _KERN_AST_H_ */