Annotation of kernel/kern/ast.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /* 
        !            26:  * Mach Operating System
        !            27:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
        !            28:  * All Rights Reserved.
        !            29:  * 
        !            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.
        !            35:  * 
        !            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.
        !            39:  * 
        !            40:  * Carnegie Mellon requests users of this software to return to
        !            41:  * 
        !            42:  *  Software Distribution Coordinator  or  [email protected]
        !            43:  *  School of Computer Science
        !            44:  *  Carnegie Mellon University
        !            45:  *  Pittsburgh PA 15213-3890
        !            46:  * 
        !            47:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            48:  * the rights to redistribute these changes.
        !            49:  */
        !            50: 
        !            51: /*
        !            52:  *     kern/ast.h: Definitions for Asynchronous System Traps.
        !            53:  */
        !            54: 
        !            55: #ifndef        _KERN_AST_H_
        !            56: #define _KERN_AST_H_
        !            57: 
        !            58: /*
        !            59:  *     A CPU takes an AST when it is about to return to user code.
        !            60:  *     Instead of going back to user code, it calls ast_taken.
        !            61:  *     Machine-dependent code is responsible for maintaining
        !            62:  *     a set of reasons for an AST, and passing this set to ast_taken.
        !            63:  */
        !            64: 
        !            65: #import <mach/features.h>
        !            66: 
        !            67: #include <kern/cpu_number.h>
        !            68: #include <kern/macro_help.h>
        !            69: #include <machine/ast.h>
        !            70: 
        !            71: /*
        !            72:  *     Bits for reasons
        !            73:  */
        !            74: 
        !            75: #define        AST_ZILCH       0x0
        !            76: #define AST_HALT       0x1
        !            77: #define AST_TERMINATE  0x2
        !            78: #define AST_BLOCK      0x4
        !            79: #define AST_NETWORK    0x8
        !            80: #define AST_NETIPC     0x10
        !            81: #define AST_UNIX       0x20
        !            82: 
        !            83: #define        AST_SCHEDULING  (AST_HALT|AST_TERMINATE|AST_BLOCK)
        !            84: 
        !            85: /*
        !            86:  * Per-thread ASTs are reset at context-switch time.
        !            87:  * machine/ast.h can define MACHINE_AST_PER_THREAD.
        !            88:  */
        !            89: 
        !            90: #ifndef        MACHINE_AST_PER_THREAD
        !            91: #define        MACHINE_AST_PER_THREAD  0
        !            92: #endif
        !            93: 
        !            94: #define AST_PER_THREAD  (AST_HALT              | \
        !            95:                        AST_TERMINATE           | \
        !            96:                        MACHINE_AST_PER_THREAD)
        !            97: 
        !            98: #ifndef __ASSEMBLER__
        !            99: 
        !           100: typedef unsigned int ast_t;
        !           101: 
        !           102: extern volatile ast_t need_ast[NCPUS];
        !           103: 
        !           104: #ifdef MACHINE_AST
        !           105: /*
        !           106:  *     machine/ast.h is responsible for defining aston and astoff.
        !           107:  */
        !           108: #else  /* MACHINE_AST */
        !           109: 
        !           110: #define aston(mycpu)
        !           111: #define astoff(mycpu)
        !           112: 
        !           113: #endif /* MACHINE_AST */
        !           114: 
        !           115: extern void ast_taken();
        !           116: 
        !           117: /*
        !           118:  *     ast_needed, ast_on, ast_off, ast_context, and ast_propagate
        !           119:  *     assume splsched.  mycpu is always cpu_number().  It is an
        !           120:  *     argument in case cpu_number() is expensive.
        !           121:  */
        !           122: 
        !           123: #define ast_needed(mycpu)              need_ast[mycpu]
        !           124: 
        !           125: #define ast_on(mycpu, reasons)                                         \
        !           126: MACRO_BEGIN                                                            \
        !           127:        if ((need_ast[mycpu] |= (reasons)) != AST_ZILCH)                \
        !           128:                { aston(mycpu); }                                       \
        !           129: MACRO_END
        !           130: 
        !           131: #define ast_off(mycpu, reasons)                                                \
        !           132: MACRO_BEGIN                                                            \
        !           133:        if ((need_ast[mycpu] &= ~(reasons)) == AST_ZILCH)               \
        !           134:                { astoff(mycpu); }                                      \
        !           135: MACRO_END
        !           136: 
        !           137: #define ast_propagate(thread, mycpu)   ast_on((mycpu), (thread)->ast)
        !           138: 
        !           139: #define ast_context(thread, mycpu)                                     \
        !           140: MACRO_BEGIN                                                            \
        !           141:        if ((need_ast[mycpu] =                                          \
        !           142:             (need_ast[mycpu] &~ AST_PER_THREAD) | (thread)->ast)       \
        !           143:                                        != AST_ZILCH)                   \
        !           144:                { aston(mycpu); }                                       \
        !           145:        else                                                            \
        !           146:                { astoff(mycpu); }                                      \
        !           147: MACRO_END
        !           148: 
        !           149: 
        !           150: #define        thread_ast_set(thread, reason)          (thread)->ast |= (reason)
        !           151: #define thread_ast_clear(thread, reason)       (thread)->ast &= ~(reason)
        !           152: #define thread_ast_clear_all(thread)           (thread)->ast = AST_ZILCH
        !           153: 
        !           154: /*
        !           155:  *     NOTE: if thread is the current thread, thread_ast_set should
        !           156:  *     be followed by ast_propagate().
        !           157:  */
        !           158: 
        !           159: #endif /* __ASSEMBLER__ */
        !           160: #endif /* _KERN_AST_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.