Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ */ /* * HISTORY * * Revision 1.1.1.1 1998/09/22 21:05:34 wsanchez * Import of Mac OS X kernel (~semeria) * * Revision 1.2 1998/04/29 17:35:56 mburg * MK7.3 merger * * Revision 1.1.10.1 1998/02/03 09:28:28 gdt * Merge up to MK7.3 * [1998/02/03 09:13:40 gdt] * * Revision 1.1.8.1 1997/06/17 02:57:46 devrcs * Added `ipc_subsystem_terminate().' * [1997/03/18 18:25:52 rkc] * * Revision 1.1.5.1 1994/09/23 02:19:57 ezf * change marker to not FREE * [1994/09/22 21:33:39 ezf] * * Revision 1.1.3.1 1994/01/20 11:05:46 emcmanus * Copied for submission. * [1994/01/20 11:04:25 emcmanus] * * Revision 1.1.1.2 1994/01/13 02:40:32 condict * IPC support for the RPC subsytem object (server co-location). * * $EndLog$ */ /* * File: kern/ipc_subsystem.c * Purpose: Routines to support ipc semantics of new kernel * RPC subsystem descriptions */ #include <mach/message.h> #include <kern/ipc_kobject.h> #include <kern/task.h> #include <kern/ipc_subsystem.h> #include <kern/subsystem.h> #include <kern/misc_protos.h> #include <ipc/ipc_port.h> #include <ipc/ipc_space.h> /* * Routine: ipc_subsystem_init * Purpose: * Initialize ipc control of a subsystem. */ void ipc_subsystem_init( subsystem_t subsystem) { ipc_port_t port; port = ipc_port_alloc_kernel(); if (port == IP_NULL) panic("ipc_subsystem_init"); subsystem->ipc_self = port; } /* * Routine: ipc_subsystem_enable * Purpose: * Enable ipc access to a subsystem. */ void ipc_subsystem_enable( subsystem_t subsystem) { ipc_kobject_set(subsystem->ipc_self, (ipc_kobject_t) subsystem, IKOT_SUBSYSTEM); } /* * Routine: ipc_subsystem_disable * Purpose: * Disable IPC access to a subsystem. * Conditions: * Nothing locked. */ void ipc_subsystem_disable( subsystem_t subsystem) { ipc_port_t kport; kport = subsystem->ipc_self; if (kport != IP_NULL) ipc_kobject_set(kport, IKO_NULL, IKOT_NONE); } /* * Routine: ipc_subsystem_terminate * Purpose: * Clean up and destroy a subsystem's IPC state. */ void ipc_subsystem_terminate( subsystem_t subsystem) { ipc_port_dealloc_kernel(subsystem->ipc_self); } /* * Routine: convert_port_to_subsystem * Purpose: * Convert from a port to a subsystem. * Doesn't consume the port ref; produces a subsystem ref, * which may be null. * Conditions: * Nothing locked. */ subsystem_t convert_port_to_subsystem( ipc_port_t port) { subsystem_t subsystem = SUBSYSTEM_NULL; if (IP_VALID(port)) { ip_lock(port); if (ip_active(port) && (ip_kotype(port) == IKOT_SUBSYSTEM)) { subsystem = (subsystem_t) port->ip_kobject; } ip_unlock(port); } return (subsystem); } /* * Routine: convert_subsystem_to_port * Purpose: * Convert from a subsystem to a port. * Produces a naked send right which may be invalid. * Conditions: * Nothing locked. */ ipc_port_t convert_subsystem_to_port( subsystem_t subsystem) { ipc_port_t port; port = ipc_port_make_send(subsystem->ipc_self); return (port); } |