]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/ast.h
2ab8d452f79191afff4f72564291fe1cbe3d29c3
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
36 * All Rights Reserved.
38 * Permission to use, copy, modify and distribute this software and its
39 * documentation is hereby granted, provided that both the copyright
40 * notice and this permission notice appear in all copies of the
41 * software, derivative works or modified versions, and any portions
42 * thereof, and that both notices appear in supporting documentation.
44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
48 * Carnegie Mellon requests users of this software to return to
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
62 * kern/ast.h: Definitions for Asynchronous System Traps.
68 #include <platforms.h>
70 #include <kern/assert.h>
71 #include <kern/macro_help.h>
72 #include <kern/lock.h>
74 #include <machine/ast.h>
77 * A processor takes an AST when it is about to return from an
78 * interrupt context, and calls ast_taken.
80 * Machine-dependent code is responsible for maintaining
81 * a set of reasons for an AST, and passing this set to ast_taken.
83 typedef uint32_t ast_t
;
88 #define AST_PREEMPT 0x01
89 #define AST_QUANTUM 0x02
90 #define AST_URGENT 0x04
91 #define AST_HANDOFF 0x08
92 #define AST_YIELD 0x10
93 #define AST_APC 0x20 /* migration APC hook */
95 * JMM - This is here temporarily. AST_BSD is used to simulate a
96 * general purpose mechanism for setting asynchronous procedure calls
101 #define AST_NONE 0x00
102 #define AST_ALL (~AST_NONE)
104 #define AST_SCHEDULING (AST_PREEMPTION | AST_YIELD | AST_HANDOFF)
105 #define AST_PREEMPTION (AST_PREEMPT | AST_QUANTUM | AST_URGENT)
109 * machine/ast.h is responsible for defining aston and astoff.
111 #else /* MACHINE_AST */
114 #define astoff(mycpu)
116 #endif /* MACHINE_AST */
118 /* Initialize module */
119 extern void ast_init(void);
122 extern void ast_taken(
126 /* Check for pending ASTs */
127 extern void ast_check(
128 processor_t processor
);
130 /* Pending ast mask for the current processor */
131 extern ast_t
*ast_pending(void);
134 * Per-thread ASTs are reset at context-switch time.
136 #ifndef MACHINE_AST_PER_THREAD
137 #define MACHINE_AST_PER_THREAD 0
140 #define AST_PER_THREAD (AST_APC | AST_BSD | MACHINE_AST_PER_THREAD)
142 * ast_pending(), ast_on(), ast_off(), ast_context(), and ast_propagate()
146 #define ast_on_fast(reasons) \
148 ast_t *myast = ast_pending(); \
150 if ((*myast |= (reasons)) != AST_NONE) \
154 #define ast_off_fast(reasons) \
156 ast_t *myast = ast_pending(); \
158 if ((*myast &= ~(reasons)) == AST_NONE) \
162 #define ast_propagate(reasons) ast_on(reasons)
164 #define ast_context(act) \
166 ast_t *myast = ast_pending(); \
168 if ((*myast = ((*myast &~ AST_PER_THREAD) | (act)->ast)) != AST_NONE) \
174 #define ast_on(reason) ast_on_fast(reason)
175 #define ast_off(reason) ast_off_fast(reason)
178 * NOTE: if thread is the current thread, thread_ast_set() should
179 * be followed by ast_propagate().
181 #define thread_ast_set(act, reason) \
182 (hw_atomic_or(&(act)->ast, (reason)))
183 #define thread_ast_clear(act, reason) \
184 (hw_atomic_and(&(act)->ast, ~(reason)))
185 #define thread_ast_clear_all(act) \
186 (hw_atomic_and(&(act)->ast, AST_NONE))
190 extern void astbsd_on(void);
191 extern void act_set_astbsd(thread_t
);
192 extern void bsd_ast(thread_t
);
194 #endif /* MACH_BSD */
196 #endif /* _KERN_AST_H_ */