|
|
1.1 ! root 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 [email protected] ! 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: * File: ipc/ipc_object.h ! 28: * Author: Rich Draves ! 29: * Date: 1989 ! 30: * ! 31: * Definitions for IPC objects, for which tasks have capabilities. ! 32: */ ! 33: ! 34: #ifndef _IPC_IPC_OBJECT_H_ ! 35: #define _IPC_IPC_OBJECT_H_ ! 36: ! 37: #include <mach_ipc_compat.h> ! 38: ! 39: #include <mach/kern_return.h> ! 40: #include <mach/message.h> ! 41: #include <kern/lock.h> ! 42: #include <kern/macro_help.h> ! 43: #include <kern/zalloc.h> ! 44: ! 45: typedef unsigned int ipc_object_refs_t; ! 46: typedef unsigned int ipc_object_bits_t; ! 47: typedef unsigned int ipc_object_type_t; ! 48: ! 49: typedef struct ipc_object { ! 50: decl_simple_lock_data(,io_lock_data) ! 51: ipc_object_refs_t io_references; ! 52: ipc_object_bits_t io_bits; ! 53: } *ipc_object_t; ! 54: ! 55: #define IO_NULL ((ipc_object_t) 0) ! 56: #define IO_DEAD ((ipc_object_t) -1) ! 57: ! 58: #define IO_VALID(io) (((io) != IO_NULL) && ((io) != IO_DEAD)) ! 59: ! 60: #define IO_BITS_KOTYPE 0x0000ffff /* used by the object */ ! 61: #define IO_BITS_OTYPE 0x7fff0000 /* determines a zone */ ! 62: #define IO_BITS_ACTIVE 0x80000000U /* is object alive? */ ! 63: ! 64: #define io_active(io) ((int)(io)->io_bits < 0) /* hack */ ! 65: ! 66: #define io_otype(io) (((io)->io_bits & IO_BITS_OTYPE) >> 16) ! 67: #define io_kotype(io) ((io)->io_bits & IO_BITS_KOTYPE) ! 68: ! 69: #define io_makebits(active, otype, kotype) \ ! 70: (((active) ? IO_BITS_ACTIVE : 0) | ((otype) << 16) | (kotype)) ! 71: ! 72: /* ! 73: * Object types: ports, port sets, kernel-loaded ports ! 74: */ ! 75: #define IOT_PORT 0 ! 76: #define IOT_PORT_SET 1 ! 77: #define IOT_NUMBER 2 /* number of types used */ ! 78: ! 79: extern zone_t ipc_object_zones[IOT_NUMBER]; ! 80: ! 81: #define io_alloc(otype) \ ! 82: ((ipc_object_t) zalloc(ipc_object_zones[(otype)])) ! 83: ! 84: #define io_free(otype, io) \ ! 85: zfree(ipc_object_zones[(otype)], (vm_offset_t) (io)) ! 86: ! 87: #define io_lock_init(io) simple_lock_init(&(io)->io_lock_data) ! 88: #define io_lock(io) simple_lock(&(io)->io_lock_data) ! 89: #define io_lock_try(io) simple_lock_try(&(io)->io_lock_data) ! 90: #define io_unlock(io) simple_unlock(&(io)->io_lock_data) ! 91: ! 92: #define io_check_unlock(io) \ ! 93: MACRO_BEGIN \ ! 94: ipc_object_refs_t _refs = (io)->io_references; \ ! 95: \ ! 96: io_unlock(io); \ ! 97: if (_refs == 0) \ ! 98: io_free(io_otype(io), io); \ ! 99: MACRO_END ! 100: ! 101: #define io_reference(io) \ ! 102: MACRO_BEGIN \ ! 103: (io)->io_references++; \ ! 104: MACRO_END ! 105: ! 106: #define io_release(io) \ ! 107: MACRO_BEGIN \ ! 108: (io)->io_references--; \ ! 109: MACRO_END ! 110: ! 111: extern void ! 112: ipc_object_reference(/* ipc_object_t */); ! 113: ! 114: extern void ! 115: ipc_object_release(/* ipc_object_t */); ! 116: ! 117: extern kern_return_t ! 118: ipc_object_translate(/* ipc_space_t, mach_port_t, ! 119: mach_port_right_t, ipc_object_t * */); ! 120: ! 121: extern kern_return_t ! 122: ipc_object_alloc_dead(/* ipc_space_t, mach_port_t * */); ! 123: ! 124: extern kern_return_t ! 125: ipc_object_alloc_dead_name(/* ipc_space_t, mach_port_t */); ! 126: ! 127: extern kern_return_t ! 128: ipc_object_alloc(/* ipc_space_t, ipc_object_type_t, ! 129: mach_port_type_t, mach_port_urefs_t, ! 130: mach_port_t *, ipc_object_t * */); ! 131: ! 132: extern kern_return_t ! 133: ipc_object_alloc_name(/* ipc_space_t, ipc_object_type_t, ! 134: mach_port_type_t, mach_port_urefs_t, ! 135: mach_port_t, ipc_object_t * */); ! 136: ! 137: extern mach_msg_type_name_t ! 138: ipc_object_copyin_type(/* mach_msg_type_name_t */); ! 139: ! 140: extern kern_return_t ! 141: ipc_object_copyin(/* ipc_space_t, mach_port_t, ! 142: mach_msg_type_name_t, ipc_object_t * */); ! 143: ! 144: extern void ! 145: ipc_object_copyin_from_kernel(/* ipc_object_t, mach_msg_type_name_t */); ! 146: ! 147: extern void ! 148: ipc_object_destroy(/* ipc_object_t, mach_msg_type_name_t */); ! 149: ! 150: extern kern_return_t ! 151: ipc_object_copyout(/* ipc_space_t, ipc_object_t, ! 152: mach_msg_type_name_t, boolean_t, mach_port_t * */); ! 153: ! 154: extern kern_return_t ! 155: ipc_object_copyout_name(/* ipc_space_t, ipc_object_t, ! 156: mach_msg_type_name_t, boolean_t, mach_port_t */); ! 157: ! 158: extern void ! 159: ipc_object_copyout_dest(/* ipc_space_t, ipc_object_t, ! 160: mach_msg_type_name_t, mach_port_t * */); ! 161: ! 162: extern kern_return_t ! 163: ipc_object_rename(/* ipc_space_t, mach_port_t, mach_port_t */); ! 164: ! 165: #if MACH_IPC_COMPAT ! 166: ! 167: extern mach_msg_type_name_t ! 168: ipc_object_copyout_type_compat(/* mach_msg_type_name_t */); ! 169: ! 170: extern kern_return_t ! 171: ipc_object_copyin_compat(/* ipc_space_t, mach_port_t, ! 172: mach_msg_type_name_t, boolean_t, ! 173: ipc_object_t * */); ! 174: ! 175: extern kern_return_t ! 176: ipc_object_copyin_header(/* ipc_space_t, mach_port_t, ! 177: ipc_object_t *, mach_msg_type_name_t * */); ! 178: ! 179: extern kern_return_t ! 180: ipc_object_copyout_compat(/* ipc_space_t, ipc_object_t, ! 181: mach_msg_type_name_t, mach_port_t * */); ! 182: ! 183: extern kern_return_t ! 184: ipc_object_copyout_name_compat(/* ipc_space_t, ipc_object_t, ! 185: mach_msg_type_name_t, mach_port_t */); ! 186: ! 187: #endif MACH_IPC_COMPAT ! 188: ! 189: extern void ! 190: ipc_object_print(/* ipc_object_t */); ! 191: ! 192: #endif _IPC_IPC_OBJECT_H_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.