xref: /NextBSD/sys/sys/mach/ipc/ipc_pset.h (revision 33da5adc555b3bc29986eeadca03829e4ad06b1e)
1 /*
2  * Copyright 1991-1998 by Open Software Foundation, Inc.
3  *              All Rights Reserved
4  *
5  * Permission to use, copy, modify, and distribute this software and
6  * its documentation for any purpose and without fee is hereby granted,
7  * provided that the above copyright notice appears in all copies and
8  * that both the copyright notice and this permission notice appear in
9  * supporting documentation.
10  *
11  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
12  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13  * FOR A PARTICULAR PURPOSE.
14  *
15  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
16  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
18  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
19  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  */
21 /*
22  * MkLinux
23  */
24 /* CMU_HIST */
25 /*
26  * Revision 2.6  91/10/09  16:10:13  af
27  * 	 Revision 2.5.2.1  91/09/16  10:15:55  rpd
28  * 	 	Added (unconditional) ipc_pset_print declaration.
29  * 	 	[91/09/02            rpd]
30  *
31  * Revision 2.5.2.1  91/09/16  10:15:55  rpd
32  * 	Added (unconditional) ipc_pset_print declaration.
33  * 	[91/09/02            rpd]
34  *
35  * Revision 2.5  91/05/14  16:35:58  mrt
36  * 	Correcting copyright
37  *
38  * Revision 2.4  91/02/05  17:23:20  mrt
39  * 	Changed to new Mach copyright
40  * 	[91/02/01  15:50:34  mrt]
41  *
42  * Revision 2.3  90/11/05  14:29:57  rpd
43  * 	Added ipc_pset_reference, ipc_pset_release.
44  * 	[90/10/29            rpd]
45  *
46  * Revision 2.2  90/06/02  14:51:23  rpd
47  * 	Created for new IPC.
48  * 	[90/03/26  21:02:09  rpd]
49  *
50  */
51 /* CMU_ENDHIST */
52 /*
53  * Mach Operating System
54  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
55  * All Rights Reserved.
56  *
57  * Permission to use, copy, modify and distribute this software and its
58  * documentation is hereby granted, provided that both the copyright
59  * notice and this permission notice appear in all copies of the
60  * software, derivative works or modified versions, and any portions
61  * thereof, and that both notices appear in supporting documentation.
62  *
63  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
64  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
65  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
66  *
67  * Carnegie Mellon requests users of this software to return to
68  *
69  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
70  *  School of Computer Science
71  *  Carnegie Mellon University
72  *  Pittsburgh PA 15213-3890
73  *
74  * any improvements or extensions that they make and grant Carnegie Mellon
75  * the rights to redistribute these changes.
76  */
77 /*
78  */
79 /*
80  *	File:	ipc/ipc_pset.h
81  *	Author:	Rich Draves
82  *	Date:	1989
83  *
84  *	Definitions for port sets.
85  */
86 
87 #ifndef	_IPC_IPC_PSET_H_
88 #define _IPC_IPC_PSET_H_
89 
90 #include <sys/mach/port.h>
91 #include <sys/mach/kern_return.h>
92 #include <sys/mach/ipc/ipc_object.h>
93 #include <sys/mach/ipc/ipc_mqueue.h>
94 #if 0
95 #include <kern/thread_pool.h>
96 #include <kern/rpc_common.h>
97 
98 #include <mach_kdb.h>
99 #endif
100 
101 typedef struct ipc_pset {
102 
103 	/*
104 	 * Initial sub-structure in common with ipc_port and rpc_port.
105 	 * First element of pset_comm is an ipc_object.
106 	 */
107 	struct rpc_common_data	pset_comm;
108 
109 	mach_port_name_t		ips_local_name;
110 	struct knlist			ips_note;
111 	struct sx				ips_note_lock;
112 	TAILQ_HEAD(_ips_ports, ipc_port) ips_ports;
113 } *ipc_pset_t;
114 
115 #define ips_object		pset_comm.rcd_comm.icd_object
116 #define	ips_references		ips_object.io_references
117 #define ips_kobject		pset_comm.rcd_comm.icd_kobject
118 #define ips_subsystem		pset_comm.rcd_comm.icd_subsystem
119 #define ips_receiver_name	pset_comm.rcd_comm.icd_receiver_name
120 #define ips_thread_pool		pset_comm.rcd_thread_pool
121 
122 #define	IPS_NULL		((ipc_pset_t) IO_NULL)
123 
124 #define	ips_active(pset)	io_active(&(pset)->ips_object)
125 #define	ips_lock(pset)		io_lock(&(pset)->ips_object)
126 #define	ips_lock_owned(pset)		io_lock_owned(&(pset)->ips_object)
127 #define	ips_lock_try(pset)	io_lock_try(&(pset)->ips_object)
128 #define	ips_unlock(pset)	io_unlock(&(pset)->ips_object)
129 #define	ips_reference(pset)	io_reference(&(pset)->ips_object)
130 #define	ips_release(pset)	io_release(&(pset)->ips_object)
131 
132 /* Allocate a port set */
133 extern kern_return_t ipc_pset_alloc(
134 	ipc_space_t	space,
135 	mach_port_name_t	*namep,
136 	ipc_pset_t	*psetp);
137 
138 /* Allocate a port set, with a specific name */
139 extern kern_return_t ipc_pset_alloc_name(
140 	ipc_space_t	space,
141 	mach_port_name_t	name,
142 	ipc_pset_t	*psetp);
143 
144 /* Remove a port from a port set */
145 extern void ipc_pset_remove(
146 	ipc_pset_t	pset,
147 	ipc_port_t	port);
148 
149 /* Remove a port from its current port set to the specified port set */
150 extern kern_return_t ipc_pset_move(
151 	ipc_space_t	space,
152 	ipc_port_t	port,
153 	ipc_pset_t	nset);
154 
155 /* Destroy a port_set */
156 extern void ipc_pset_destroy(
157 	ipc_pset_t	pset);
158 
159 extern void ipc_pset_signal(
160 	ipc_pset_t pset);
161 
162 #define	ipc_pset_reference(pset)	\
163 		ipc_object_reference(&(pset)->ips_object)
164 
165 #define	ipc_pset_release(pset)		\
166 		ipc_object_release(&(pset)->ips_object)
167 
168 
169 #if	MACH_KDB
170 int ipc_list_count(struct ipc_kmsg *base);
171 #endif	/* MACH_KDB */
172 
173 #endif	/* _IPC_IPC_PSET_H_ */
174