]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/ast.h
9d2a912c089b61cd330db7905b5566b1c339fe7b
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,1989 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.
54 * kern/ast.h: Definitions for Asynchronous System Traps.
61 #include <platforms.h>
63 #include <kern/assert.h>
64 #include <kern/cpu_number.h>
65 #include <kern/macro_help.h>
66 #include <kern/lock.h>
68 #include <machine/ast.h>
71 * A processor takes an AST when it is about to return from an
72 * interrupt context, and calls ast_taken.
74 * Machine-dependent code is responsible for maintaining
75 * a set of reasons for an AST, and passing this set to ast_taken.
77 typedef uint32_t ast_t
;
82 #define AST_BLOCK 0x01
83 #define AST_QUANTUM 0x02
84 #define AST_HANDOFF 0x04
85 #define AST_YIELD 0x08
86 #define AST_URGENT 0x10
87 #define AST_APC 0x20 /* migration APC hook */
89 * JMM - This is here temporarily. AST_BSD is used to simulate a
90 * general purpose mechanism for setting asynchronous procedure calls
96 #define AST_ALL (~AST_NONE)
98 #define AST_SCHEDULING (AST_PREEMPT | AST_YIELD | AST_HANDOFF)
99 #define AST_PREEMPT (AST_BLOCK | AST_QUANTUM | AST_URGENT)
101 extern volatile ast_t need_ast
[NCPUS
];
105 * machine/ast.h is responsible for defining aston and astoff.
107 #else /* MACHINE_AST */
110 #define astoff(mycpu)
112 #endif /* MACHINE_AST */
114 /* Initialize module */
115 extern void ast_init(void);
118 extern void ast_taken(
122 /* Check for pending ASTs */
123 extern void ast_check(
124 processor_t processor
);
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_needed(), ast_on(), ast_off(), ast_context(), and ast_propagate()
138 #define ast_needed(mycpu) (need_ast[mycpu] != AST_NONE)
140 #define ast_on_fast(reasons) \
142 int mycpu = cpu_number(); \
143 if ((need_ast[mycpu] |= (reasons)) != AST_NONE) \
147 #define ast_off_fast(reasons) \
149 int mycpu = cpu_number(); \
150 if ((need_ast[mycpu] &= ~(reasons)) == AST_NONE) \
154 #define ast_propagate(reasons) ast_on(reasons)
156 #define ast_context(act, mycpu) \
158 assert((mycpu) == cpu_number()); \
159 if ((need_ast[mycpu] = \
160 ((need_ast[mycpu] &~ AST_PER_THREAD) | (act)->ast)) != AST_NONE) \
166 #define ast_on(reason) ast_on_fast(reason)
167 #define ast_off(reason) ast_off_fast(reason)
169 #define thread_ast_set(act, reason) \
170 (hw_atomic_or(&(act)->ast, (reason)))
171 #define thread_ast_clear(act, reason) \
172 (hw_atomic_and(&(act)->ast, ~(reason)))
173 #define thread_ast_clear_all(act) \
174 (hw_atomic_and(&(act)->ast, AST_NONE))
177 * NOTE: if thread is the current thread, thread_ast_set() should
178 * be followed by ast_propagate().
181 #ifdef MACH_KERNEL_PRIVATE
183 #define ast_urgency() (need_ast[cpu_number()] & AST_URGENT)
185 #endif /* MACH_KERNEL_PRIVATE */
187 #endif /* _KERN_AST_H_ */