|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 1991,1990,1989 Carnegie Mellon University.
4: * Copyright (c) 1993,1994 The University of Utah and
5: * the Computer Systems Laboratory (CSL).
6: * All rights reserved.
7: *
8: * Permission to use, copy, modify and distribute this software and its
9: * documentation is hereby granted, provided that both the copyright
10: * notice and this permission notice appear in all copies of the
11: * software, derivative works or modified versions, and any portions
12: * thereof, and that both notices appear in supporting documentation.
13: *
14: * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
15: * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
16: * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
17: * THIS SOFTWARE.
18: *
19: * Carnegie Mellon requests users of this software to return to
20: *
21: * Software Distribution Coordinator or [email protected]
22: * School of Computer Science
23: * Carnegie Mellon University
24: * Pittsburgh PA 15213-3890
25: *
26: * any improvements or extensions that they make and grant Carnegie Mellon
27: * the rights to redistribute these changes.
28: */
29: /*
30: * kern/ast.h: Definitions for Asynchronous System Traps.
31: */
32:
33: #ifndef _KERN_AST_H_
34: #define _KERN_AST_H_
35:
36: /*
37: * A CPU takes an AST when it is about to return to user code.
38: * Instead of going back to user code, it calls ast_taken.
39: * Machine-dependent code is responsible for maintaining
40: * a set of reasons for an AST, and passing this set to ast_taken.
41: */
42:
43: #include "cpu_number.h"
44: #include <kern/macro_help.h>
45: #include <machine/ast.h>
46:
47: /*
48: * Bits for reasons
49: */
50:
51: #define AST_ZILCH 0x0
52: #define AST_HALT 0x1
53: #define AST_TERMINATE 0x2
54: #define AST_BLOCK 0x4
55: #define AST_NETWORK 0x8
56: #define AST_NETIPC 0x10
57:
58: #define AST_SCHEDULING (AST_HALT|AST_TERMINATE|AST_BLOCK)
59:
60: /*
61: * Per-thread ASTs are reset at context-switch time.
62: * machine/ast.h can define MACHINE_AST_PER_THREAD.
63: */
64:
65: #ifndef MACHINE_AST_PER_THREAD
66: #define MACHINE_AST_PER_THREAD 0
67: #endif
68:
69: #define AST_PER_THREAD (AST_HALT | AST_TERMINATE | MACHINE_AST_PER_THREAD)
70:
1.1.1.3 ! root 71: typedef unsigned long ast_t;
1.1 root 72:
73: extern volatile ast_t need_ast[NCPUS];
74:
75: #ifdef MACHINE_AST
76: /*
77: * machine/ast.h is responsible for defining aston and astoff.
78: */
1.1.1.2 root 79: #else /* MACHINE_AST */
1.1 root 80:
81: #define aston(mycpu)
82: #define astoff(mycpu)
83:
1.1.1.2 root 84: #endif /* MACHINE_AST */
1.1 root 85:
1.1.1.3 ! root 86: extern void ast_taken(void);
1.1 root 87:
88: /*
89: * ast_needed, ast_on, ast_off, ast_context, and ast_propagate
90: * assume splsched. mycpu is always cpu_number(). It is an
91: * argument in case cpu_number() is expensive.
92: */
93:
94: #define ast_needed(mycpu) need_ast[mycpu]
95:
96: #define ast_on(mycpu, reasons) \
97: MACRO_BEGIN \
98: if ((need_ast[mycpu] |= (reasons)) != AST_ZILCH) \
99: { aston(mycpu); } \
100: MACRO_END
101:
102: #define ast_off(mycpu, reasons) \
103: MACRO_BEGIN \
104: if ((need_ast[mycpu] &= ~(reasons)) == AST_ZILCH) \
105: { astoff(mycpu); } \
106: MACRO_END
107:
108: #define ast_propagate(thread, mycpu) ast_on((mycpu), (thread)->ast)
109:
110: #define ast_context(thread, mycpu) \
111: MACRO_BEGIN \
112: if ((need_ast[mycpu] = \
113: (need_ast[mycpu] &~ AST_PER_THREAD) | (thread)->ast) \
114: != AST_ZILCH) \
115: { aston(mycpu); } \
116: else \
117: { astoff(mycpu); } \
118: MACRO_END
119:
120:
121: #define thread_ast_set(thread, reason) (thread)->ast |= (reason)
122: #define thread_ast_clear(thread, reason) (thread)->ast &= ~(reason)
123: #define thread_ast_clear_all(thread) (thread)->ast = AST_ZILCH
124:
125: /*
126: * NOTE: if thread is the current thread, thread_ast_set should
127: * be followed by ast_propagate().
128: */
129:
1.1.1.3 ! root 130: extern void ast_init (void);
! 131:
! 132: extern void ast_check (void);
! 133:
1.1.1.2 root 134: #endif /* _KERN_AST_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.