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/*
33 * HISTORY
34 *
35 * Revision 1.1.1.1  1998/09/22 21:05:30  wsanchez
36 * Import of Mac OS X kernel (~semeria)
37 *
38 * Revision 1.1.1.1  1998/03/07 02:25:45  wsanchez
39 * Import of OSF Mach kernel (~mburg)
40 *
41 * Revision 1.1.7.1  1996/09/17  16:34:35  bruel
42 * 	fixed types.
43 * 	[96/09/17            bruel]
44 *
45 * Revision 1.1.5.1  1995/06/13  18:20:20  sjs
46 * 	Merged from flipc_shared.
47 * 	[95/06/07            sjs]
48 *
49 * Revision 1.1.3.11  1995/05/23  19:55:36  randys
50 * 	Don't keep track of messages sent to a bad destination--that's
51 * 	purely a transport function now.
52 * 	[95/05/23            randys]
53 *
54 * Revision 1.1.3.10  1995/05/23  15:40:20  randys
55 * 	Added field to FLIPC_domain_errors to indicate validity of other
56 * 	fields.
57 * 	[95/05/22            randys]
58 *
59 * Revision 1.1.3.9  1995/05/16  20:46:35  randys
60 * 	Added a "performance_valid" field to the flipc performance
61 * 	structure.
62 * 	[95/05/16            randys]
63 *
64 * Revision 1.1.3.8  1995/04/05  21:22:01  randys
65 * 	Added field to domain_info struct to include allocations lock
66 * 	sched policy.
67 * 	[95/04/05            randys]
68 *
69 * Revision 1.1.3.7  1995/03/09  19:42:33  rwd
70 * 	Define SEMAPHORE_NULL (for now) and include mach_types.h instead
71 * 	of sema_types.h.
72 * 	[95/03/08            rwd]
73 *
74 * Revision 1.1.3.6  1995/02/23  21:32:52  randys
75 * 	 Removed placeholder definition for locks--I don't believe that I
76 * 	 use locks unless I'm on top of a real time base, in which case
77 * 	 that base will define the type.
78 * 	[95/02/22            randys]
79 *
80 * Revision 1.1.3.5  1995/02/21  17:23:13  randys
81 * 	Re-indented code to four space indentation
82 * 	[1995/02/21  16:25:36  randys]
83 *
84 * Revision 1.1.3.4  1995/02/16  23:20:14  randys
85 * 	ANSIfy FLIPC_thread_yield_function.
86 * 	[95/02/14            randys]
87 *
88 * 	Add FLIPC_thread_yield_function type.
89 * 	[95/02/14            randys]
90 *
91 * Revision 1.1.3.3  1995/01/26  21:01:51  randys
92 * 	Added performance structure.
93 * 	[1995/01/24  21:14:12  randys]
94 *
95 * 	Added FLIPC_epgroup_info struct
96 * 	[1995/01/24  18:30:02  randys]
97 *
98 * 	Create a new structure (FLIPC_endpoint_info) to return
99 * 	information about an endpoint.
100 * 	[1995/01/20  19:26:35  randys]
101 *
102 * 	Get rid of FLIPC_DESTINATION_NULL and add in
103 * 	FLIPC_ADDRESS_ERROR (return code from FLIPC_buffer_destination)
104 * 	[1995/01/19  20:23:24  randys]
105 *
106 * 	Added domain index type for specifying domain in
107 * 	init and attach calls
108 * 	[1995/01/18  16:47:25  randys]
109 *
110 * Revision 1.1.3.2  1994/12/20  19:02:09  randys
111 * 	Added error reporting structure type, and added
112 * 	room in the standard domain query for error log size.
113 * 	[1994/12/19  23:46:09  randys]
114 *
115 * 	Added filename in comment at top of each file
116 * 	[1994/12/19  20:28:26  randys]
117 *
118 * 	Support and doc for minor user interface changes for error conditions
119 * 	[1994/12/18  23:24:30  randys]
120 *
121 * 	Yank the semaphore type definitions back out, and include the file
122 * 	that defines those types.
123 * 	[1994/12/13  17:50:03  randys]
124 *
125 * Revision 1.1.3.1  1994/12/12  17:46:20  randys
126 * 	Put definitions of semaphore_t and SEMAPHORE_NULL back in; they aren't
127 * 	defined in user space yet.
128 * 	[1994/12/12  17:21:56  randys]
129 *
130 * Revision 1.1.1.2  1994/12/11  23:11:23  randys
131 * 	Initial flipc code checkin
132 *
133 * $EndLog$
134 */
135
136/*
137 * mach/flipc_types.h
138 *
139 * Definitions of those flipc types that need to be visible to both the AIL
140 * and kernel sides of flipc (which is just about everything).
141 */
142
143#ifndef _MACH_FLIPC_TYPES_H_
144#define _MACH_FLIPC_TYPES_H_
145
146#include <mach/port.h>
147
148/*
149 * Define a couple of generally useful types.
150 */
151#include <mach/mach_types.h>
152
153#ifndef MACH_KERNEL
154#define SEMAPHORE_NULL (semaphore_port_t)0
155#endif /* !defined(MACH_KERNEL) */
156
157/*
158 * Basic flipc types; visible to both user and kernel segments of the
159 * flipc implementation.
160 */
161/* Flipc addresses.  These name a node-endpoint combination for
162   sending.  */
163typedef unsigned int FLIPC_address_t;
164#define FLIPC_ADDRESS_ERROR ((FLIPC_address_t) -1)
165
166/* Flipc endpoints.  */
167typedef void *FLIPC_endpoint_t;
168#define FLIPC_ENDPOINT_NULL ((FLIPC_endpoint_t) 0)
169
170/* Buffer pointers (returned by query functions).  Users are allowed to
171   copy directly to/from this pointer; it points at their data.  */
172typedef void *FLIPC_buffer_t;
173#define FLIPC_BUFFER_NULL ((FLIPC_buffer_t) 0)
174
175/* Endpoint group identifiers.  */
176typedef void *FLIPC_epgroup_t;
177#define FLIPC_EPGROUP_NULL ((FLIPC_epgroup_t) 0)
178#define FLIPC_EPGROUP_ERROR ((FLIPC_epgroup_t) -1)
179
180/* Domain index; argument to initialization and attach routines.  */
181typedef unsigned int FLIPC_domain_index_t;
182
183/* Domain handle (mach port).  */
184typedef mach_port_t FLIPC_domain_t;
185
186/* The different types an endpoint can be.  FLIPC_Inactive is used when
187   the endpoint has not been configured and hence is on the freelist.  */
188typedef enum {
189    FLIPC_Inactive = -1,
190    FLIPC_Send,
191    FLIPC_Receive
192} FLIPC_endpoint_type_t;
193
194/* Structure for returning performance information about the flipc
195   domain; a placeholder for future entries as needed.
196   This information will only be valid if the kernel is configured to
197   keep flipc performance information.  */
198typedef struct FLIPC_domain_performance_info {
199    unsigned long performance_valid;	/* Non zero if the other information
200				   in this structure is valid.  */
201    unsigned long messages_sent;		/* Since last init.  */
202    unsigned long messages_received;	/* Since last init.  Includes overruns
203				   (because they are marked in the
204				   endpoint data structure).  Doesn't
205				   include other drops (they are
206				   marked in other places) */
207} *FLIPC_domain_performance_info_t;
208
209/* Flipc yield function.  */
210typedef void (*FLIPC_thread_yield_function)(void);
211
212/* Structure for returning information about the flipc domain.  */
213typedef struct FLIPC_domain_info {
214    int max_endpoints;
215    int max_epgroups;
216    int max_buffers;
217    int max_buffers_per_endpoint;
218    int msg_buffer_size;
219    FLIPC_thread_yield_function yield_fn;
220    int policy;			/* Allocations lock sched policy.
221				   Unused if REAL_TIME_PRIMITIVES are
222				   not being used.  */
223    struct FLIPC_domain_performance_info performance;
224    int error_log_size;		/* In bytes.  */
225} *FLIPC_domain_info_t;
226
227/* Structure for returning information about the error state of
228   the flipc domain.  Note that this is variable sized; the size
229   of the transport specific information is not known at compile
230   time.  */
231typedef struct FLIPC_domain_errors {
232    int error_full_config_p;		/* 1 if disabled and badtype below are
233					   valid; 0 if only msgdrop_inactive
234					   is valid.  */
235    int msgdrop_inactive;		/* Messages dropped because
236					   of the domain being locally
237					   inactive.  */
238    int msgdrop_disabled;		/* Messages dropped because of a
239					   disabled endpoint.  */
240    int msgdrop_badtype;		/* Messages dropped because they
241					   were sent to a send endpoint.  */
242
243    int transport_error_size;	/* Size of the following array of
244				   ints, in bytes.  */
245    int transport_error_info[1];	/* Really of transport_error_size.  */
246} *FLIPC_domain_errors_t;
247
248/* Structure for returning information about endpoints.  */
249typedef struct FLIPC_endpoint_info {
250    FLIPC_endpoint_type_t type;
251    unsigned int processed_buffers_dropped_p;
252    unsigned long number_buffers;
253    FLIPC_epgroup_t epgroup;
254} *FLIPC_endpoint_info_t;
255
256typedef struct FLIPC_epgroup_info {
257    unsigned long msgs_per_wakeup;
258} *FLIPC_epgroup_info_t;
259
260#endif /* _MACH_FLIPC_TYPES_H_ */
261