FreeBSD/Linux Kernel Cross Reference
sys/kern/ast.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: ast.h,v $
29 * Revision 2.11 92/05/22 18:37:52 jfriedl
30 * Put calls to aston/astoff in {} for safety.
31 *
32 * Revision 2.9 92/05/04 11:24:24 danner
33 * Changed AST_PER_THREAD definition (from dbg).
34 * [92/05/03 danner]
35 *
36 * Revision 2.8 92/04/06 01:16:11 rpd
37 * Fixed ast_context bug, with AST_PER_THREAD. From dbg.
38 * [92/04/05 rpd]
39 *
40 * Revision 2.7 91/08/28 11:14:20 jsb
41 * Renamed AST_CLPORT to AST_NETIPC.
42 * [91/08/14 21:38:09 jsb]
43 *
44 * Revision 2.6 91/06/06 17:06:48 jsb
45 * Added AST_CLPORT.
46 * [91/05/13 17:35:08 jsb]
47 *
48 * Revision 2.5 91/05/14 16:39:58 mrt
49 * Correcting copyright
50 *
51 * Revision 2.4 91/03/16 14:49:32 rpd
52 * Fixed dummy aston, astoff definitions.
53 * [91/02/12 rpd]
54 * Revised the AST interface, adding AST_NETWORK.
55 * Added volatile attribute to need_ast.
56 * [91/01/18 rpd]
57 *
58 * Revision 2.3 91/02/05 17:25:38 mrt
59 * Changed to new Mach copyright
60 * [91/02/01 16:11:14 mrt]
61 *
62 * Revision 2.2 90/06/02 14:53:34 rpd
63 * Merged with mainline.
64 * [90/03/26 22:02:55 rpd]
65 *
66 * Revision 2.1 89/08/03 15:45:04 rwd
67 * Created.
68 *
69 * 6-Sep-88 David Golub (dbg) at Carnegie-Mellon University
70 * Adapted to MACH_KERNEL and VAX.
71 *
72 * 11-Aug-88 David Black (dlb) at Carnegie-Mellon University
73 * Created. dbg gets equal credit for the design.
74 *
75 */
76
77 /*
78 * kern/ast.h: Definitions for Asynchronous System Traps.
79 */
80
81 #ifndef _KERN_AST_H_
82 #define _KERN_AST_H_
83
84 /*
85 * A CPU takes an AST when it is about to return to user code.
86 * Instead of going back to user code, it calls ast_taken.
87 * Machine-dependent code is responsible for maintaining
88 * a set of reasons for an AST, and passing this set to ast_taken.
89 */
90
91 #include <cpus.h>
92
93 #include <kern/cpu_number.h>
94 #include <kern/macro_help.h>
95 #include <machine/ast.h>
96
97 /*
98 * Bits for reasons
99 */
100
101 #define AST_ZILCH 0x0
102 #define AST_HALT 0x1
103 #define AST_TERMINATE 0x2
104 #define AST_BLOCK 0x4
105 #define AST_NETWORK 0x8
106 #define AST_NETIPC 0x10
107
108 #define AST_SCHEDULING (AST_HALT|AST_TERMINATE|AST_BLOCK)
109
110 /*
111 * Per-thread ASTs are reset at context-switch time.
112 * machine/ast.h can define MACHINE_AST_PER_THREAD.
113 */
114
115 #ifndef MACHINE_AST_PER_THREAD
116 #define MACHINE_AST_PER_THREAD 0
117 #endif
118
119 #define AST_PER_THREAD (AST_HALT | AST_TERMINATE | MACHINE_AST_PER_THREAD)
120
121 typedef unsigned int ast_t;
122
123 extern volatile ast_t need_ast[NCPUS];
124
125 #ifdef MACHINE_AST
126 /*
127 * machine/ast.h is responsible for defining aston and astoff.
128 */
129 #else MACHINE_AST
130
131 #define aston(mycpu)
132 #define astoff(mycpu)
133
134 #endif MACHINE_AST
135
136 extern void ast_taken();
137
138 /*
139 * ast_needed, ast_on, ast_off, ast_context, and ast_propagate
140 * assume splsched. mycpu is always cpu_number(). It is an
141 * argument in case cpu_number() is expensive.
142 */
143
144 #define ast_needed(mycpu) need_ast[mycpu]
145
146 #define ast_on(mycpu, reasons) \
147 MACRO_BEGIN \
148 if ((need_ast[mycpu] |= (reasons)) != AST_ZILCH) \
149 { aston(mycpu); } \
150 MACRO_END
151
152 #define ast_off(mycpu, reasons) \
153 MACRO_BEGIN \
154 if ((need_ast[mycpu] &= ~(reasons)) == AST_ZILCH) \
155 { astoff(mycpu); } \
156 MACRO_END
157
158 #define ast_propagate(thread, mycpu) ast_on((mycpu), (thread)->ast)
159
160 #define ast_context(thread, mycpu) \
161 MACRO_BEGIN \
162 if ((need_ast[mycpu] = \
163 (need_ast[mycpu] &~ AST_PER_THREAD) | (thread)->ast) \
164 != AST_ZILCH) \
165 { aston(mycpu); } \
166 else \
167 { astoff(mycpu); } \
168 MACRO_END
169
170
171 #define thread_ast_set(thread, reason) (thread)->ast |= (reason)
172 #define thread_ast_clear(thread, reason) (thread)->ast &= ~(reason)
173 #define thread_ast_clear_all(thread) (thread)->ast = AST_ZILCH
174
175 /*
176 * NOTE: if thread is the current thread, thread_ast_set should
177 * be followed by ast_propagate().
178 */
179
180 #endif _KERN_AST_H_
Cache object: db78e7cc845135076e8daba905113733
|