Annotation of XNU/osfmk/kern/ast.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      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.
                     11:  * 
                     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
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  * @OSF_COPYRIGHT@
                     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: 
                     53: /*
                     54:  *      kern/ast.h: Definitions for Asynchronous System Traps.
                     55:  */
                     56: 
                     57: #ifndef _KERN_AST_H_
                     58: #define _KERN_AST_H_
                     59: 
                     60: #include <cpus.h>
                     61: #include <platforms.h>
                     62: 
                     63: #include <kern/assert.h>
                     64: #include <kern/cpu_number.h>
                     65: #include <kern/macro_help.h>
                     66: #include <kern/lock.h>
                     67: #include <kern/spl.h>
                     68: #include <machine/ast.h>
                     69: 
                     70: /*
                     71:  *      A CPU takes an AST when it is about to return to user code.
                     72:  *      Instead of going back to user code, it calls ast_taken.
                     73:  *      Machine-dependent code is responsible for maintaining
                     74:  *      a set of reasons for an AST, and passing this set to ast_taken.
                     75:  */
                     76: 
                     77: typedef unsigned int ast_t;
                     78: 
                     79: /*
                     80:  *      Bits for reasons
                     81:  */
                     82: #define AST_NONE       0x00
                     83: #define AST_HALT       0x01
                     84: #define AST_TERMINATE  0x02
                     85: #define AST_BLOCK       0x04
                     86: #define AST_UNUSED      0x08
                     87: #define AST_QUANTUM     0x10
                     88: #define AST_APC                0x20    /* migration APC hook */
                     89: #define        AST_URGENT      0x40
                     90: 
                     91: /*
                     92:  * JMM - This is here temporarily. AST_BSD is used to simulate a
                     93:  * general purpose mechanism for setting asynchronous procedure calls
                     94:  * from the outside.
                     95:  */
                     96: #define        AST_BSD         0x80
                     97: #define        AST_BSD_INIT    0x100
                     98: 
                     99: #include <dipc.h>
                    100: #if    DIPC
                    101: #define        AST_DIPC        0x10000
                    102: #endif /* DIPC */
                    103: 
                    104: #define AST_SWAPOUT    0x20000
                    105: 
                    106: #define        AST_ALL         (~AST_NONE)
                    107: 
                    108: #define AST_SCHEDULING  (AST_HALT | AST_TERMINATE | AST_BLOCK | AST_SWAPOUT)
                    109: #define        AST_PREEMPT     (AST_BLOCK | AST_QUANTUM | AST_URGENT)
                    110: 
                    111: extern volatile ast_t need_ast[NCPUS];
                    112: 
                    113: #ifdef  MACHINE_AST
                    114: /*
                    115:  *      machine/ast.h is responsible for defining aston and astoff.
                    116:  */
                    117: #else   /* MACHINE_AST */
                    118: 
                    119: #define aston(mycpu)
                    120: #define astoff(mycpu)
                    121: 
                    122: #endif  /* MACHINE_AST */
                    123: 
                    124: /* Initialize module */
                    125: extern void    ast_init(void);
                    126: 
                    127: /* Handle ASTs */
                    128: extern void    ast_taken(
                    129:                        boolean_t       preemption,
                    130:                        ast_t           mask,
                    131:                        boolean_t       interrupt);
                    132: 
                    133: /* Check for pending ASTs */
                    134: extern void            ast_check(void);
                    135: 
                    136: /*
                    137:  * Per-thread ASTs are reset at context-switch time.
                    138:  */
                    139: #ifndef MACHINE_AST_PER_THREAD
                    140: #define MACHINE_AST_PER_THREAD  0
                    141: #endif
                    142: 
                    143: #define AST_PER_THREAD (MACHINE_AST_PER_THREAD|AST_HALT|AST_TERMINATE|AST_APC)
                    144: 
                    145: /*
                    146:  *      ast_needed, ast_on, ast_off, ast_context, and ast_propagate
                    147:  *      assume splsched.
                    148:  */
                    149: 
                    150: #define ast_needed(mycpu)               need_ast[mycpu]
                    151: 
                    152: #define ast_on_fast(reasons)                                           \
                    153: MACRO_BEGIN                                                            \
                    154:        int mycpu = cpu_number();                                       \
                    155:        if ((need_ast[mycpu] |= (reasons)) != AST_NONE)                 \
                    156:                { aston(mycpu); }                                       \
                    157: MACRO_END
                    158: 
                    159: #define ast_off_fast(reasons)                                          \
                    160: MACRO_BEGIN                                                            \
                    161:        int mycpu = cpu_number();                                       \
                    162:        if ((need_ast[mycpu] &= ~(reasons)) == AST_NONE)                \
                    163:                 { astoff(mycpu); }                                     \
                    164: MACRO_END
                    165: 
                    166: #define ast_propagate(reasons)         ast_on(reasons)
                    167: 
                    168: #define ast_context(act, mycpu)                                                \
                    169: MACRO_BEGIN                                                            \
                    170:        assert(mycpu == cpu_number());                                  \
                    171:        if ((need_ast[mycpu] =                                          \
                    172:             (need_ast[mycpu] &~ AST_PER_THREAD) | (act)->ast)          \
                    173:                                        != AST_NONE)                    \
                    174:                { aston(mycpu); }                                       \
                    175:        else                                                            \
                    176:                { astoff(mycpu); }                                      \
                    177: MACRO_END
                    178: 
                    179: #define ast_on(reason)                      ast_on_fast(reason)
                    180: #define ast_off(reason)                             ast_off_fast(reason)
                    181: 
                    182: #define thread_ast_set(act, reason)          (act)->ast |= (reason)
                    183: #define thread_ast_clear(act, reason)        (act)->ast &= ~(reason)
                    184: #define thread_ast_clear_all(act)            (act)->ast = AST_NONE
                    185: 
                    186: /*
                    187:  *      NOTE: if thread is the current thread, thread_ast_set should
                    188:  *      be followed by ast_propagate().
                    189:  */
                    190: 
                    191: #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.