1 /* 2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 /* 29 * @OSF_COPYRIGHT@ 30 */ 31 /* 32 * Mach Operating System 33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University 34 * All Rights Reserved. 35 * 36 * Permission to use, copy, modify and distribute this software and its 37 * documentation is hereby granted, provided that both the copyright 38 * notice and this permission notice appear in all copies of the 39 * software, derivative works or modified versions, and any portions 40 * thereof, and that both notices appear in supporting documentation. 41 * 42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 * 46 * Carnegie Mellon requests users of this software to return to 47 * 48 * Software Distribution Coordinator or [email protected] 49 * School of Computer Science 50 * Carnegie Mellon University 51 * Pittsburgh PA 15213-3890 52 * 53 * any improvements or extensions that they make and grant Carnegie Mellon 54 * the rights to redistribute these changes. 55 */ 56 /* 57 */ 58 /* 59 * File: ipc/ipc_right.h 60 * Author: Rich Draves 61 * Date: 1989 62 * 63 * Declarations of functions to manipulate IPC capabilities. 64 */ 65 66 #ifndef _IPC_IPC_RIGHT_H_ 67 #define _IPC_IPC_RIGHT_H_ 68 69 #include <mach/boolean.h> 70 #include <mach/kern_return.h> 71 #include <ipc/ipc_port.h> 72 #include <ipc/ipc_entry.h> 73 74 #define ipc_right_lookup_two_read ipc_right_lookup_two_write 75 76 /* Find an entry in a space, given the name */ 77 extern kern_return_t ipc_right_lookup_read( 78 ipc_space_t space, 79 mach_port_name_t name, 80 ipc_entry_bits_t *bitsp, 81 ipc_object_t *objectp); 82 83 /* Find an entry in a space, given the name */ 84 extern kern_return_t ipc_right_lookup_write( 85 ipc_space_t space, 86 mach_port_name_t name, 87 ipc_entry_t *entryp); 88 89 /* Find two entries in a space, given two names */ 90 extern kern_return_t ipc_right_lookup_two_write( 91 ipc_space_t space, 92 mach_port_name_t name1, 93 ipc_entry_t *entryp1, 94 mach_port_name_t name2, 95 ipc_entry_t *entryp2); 96 97 /* Translate (space, object) -> (name, entry) */ 98 extern bool ipc_right_reverse( 99 ipc_space_t space, 100 ipc_object_t object, 101 mach_port_name_t *namep, 102 ipc_entry_t *entryp); 103 104 /* Make a notification request, returning the previous send-once right */ 105 extern kern_return_t ipc_right_request_alloc( 106 ipc_space_t space, 107 mach_port_name_t name, 108 boolean_t immediate, 109 boolean_t send_possible, 110 ipc_port_t notify, 111 ipc_port_t *previousp); 112 113 /* Cancel a notification request and return the send-once right */ 114 extern ipc_port_t ipc_right_request_cancel( 115 ipc_space_t space, 116 ipc_port_t port, 117 mach_port_name_t name, 118 ipc_entry_t entry); 119 120 #define ipc_right_request_cancel_macro(space, port, name, entry) \ 121 ((entry->ie_request == IE_REQ_NONE) ? IP_NULL : \ 122 ipc_right_request_cancel((space), (port), (name), (entry))) 123 124 /* Check if an entry is being used */ 125 extern bool ipc_right_inuse( 126 ipc_entry_t entry); 127 128 /* Check if the port has died */ 129 extern boolean_t ipc_right_check( 130 ipc_space_t space, 131 ipc_port_t port, 132 mach_port_name_t name, 133 ipc_entry_t entry, 134 ipc_object_copyin_flags_t flags); 135 136 /* Clean up an entry in a dead space */ 137 extern void ipc_right_terminate( 138 ipc_space_t space, 139 mach_port_name_t name, 140 ipc_entry_t entry); 141 142 /* Destroy an entry in a space */ 143 extern kern_return_t ipc_right_destroy( 144 ipc_space_t space, 145 mach_port_name_t name, 146 ipc_entry_t entry, 147 boolean_t check_guard, 148 uint64_t guard); 149 150 /* Release a send/send-once/dead-name user reference */ 151 extern kern_return_t ipc_right_dealloc( 152 ipc_space_t space, 153 mach_port_name_t name, 154 ipc_entry_t entry); 155 156 /* Modify the user-reference count for a right */ 157 extern kern_return_t ipc_right_delta( 158 ipc_space_t space, 159 mach_port_name_t name, 160 ipc_entry_t entry, 161 mach_port_right_t right, 162 mach_port_delta_t delta); 163 164 /* Destroy a receive right; Modify ref count for send rights */ 165 extern kern_return_t ipc_right_destruct( 166 ipc_space_t space, 167 mach_port_name_t name, 168 ipc_entry_t entry, 169 mach_port_delta_t srdelta, 170 uint64_t guard); 171 172 /* Retrieve information about a right */ 173 extern kern_return_t ipc_right_info( 174 ipc_space_t space, 175 mach_port_name_t name, 176 ipc_entry_t entry, 177 mach_port_type_t *typep, 178 mach_port_urefs_t *urefsp); 179 180 /* Check if a subsequent ipc_right_copyin of the reply port will succeed */ 181 extern boolean_t ipc_right_copyin_check_reply( 182 ipc_space_t space, 183 mach_port_name_t reply_name, 184 ipc_entry_t reply_entry, 185 mach_msg_type_name_t reply_type); 186 187 /* Copyin a capability from a space */ 188 extern kern_return_t ipc_right_copyin( 189 ipc_space_t space, 190 mach_port_name_t name, 191 ipc_entry_t entry, 192 mach_msg_type_name_t msgt_name, 193 ipc_object_copyin_flags_t flags, 194 ipc_object_t *objectp, 195 ipc_port_t *sorightp, 196 ipc_port_t *releasep, 197 int *assertcntp, 198 mach_port_context_t context, 199 mach_msg_guard_flags_t *guard_flags); 200 201 /* Copyin a pair of dispositions from a space */ 202 extern kern_return_t ipc_right_copyin_two( 203 ipc_space_t space, 204 mach_port_name_t name, 205 ipc_entry_t entry, 206 mach_msg_type_name_t msgt_one, 207 mach_msg_type_name_t msgt_two, 208 ipc_object_t *objectp, 209 ipc_port_t *sorightp, 210 ipc_port_t *releasep); 211 212 /* Copyout a capability to a space */ 213 extern kern_return_t ipc_right_copyout( 214 ipc_space_t space, 215 mach_port_name_t name, 216 ipc_entry_t entry, 217 mach_msg_type_name_t msgt_name, 218 ipc_object_copyout_flags_t flags, 219 mach_port_context_t *context, 220 mach_msg_guard_flags_t *guard_flags, 221 ipc_object_t object); 222 223 #endif /* _IPC_IPC_RIGHT_H_ */ 224