4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
29 #include <sys/types.h>
33 #include <sys/port_impl.h>
36 #include <sys/systm.h>
40 * The second argument of _portfs(PORT_CREATE, 0,,,) represents the version
41 * number of the event ports framework. The version number is required to
42 * identify possible changes/extensions of the port_event_t structure. If an
43 * extension is required the port_create() function will be mapped to a second
44 * library create function like port_create_v1(PORT_CREATE, VERSION,,,)
45 * VERSION will be a number > 0.
46 * As long as such an extension is not required the second argument will be
47 * set to 0 and no check will be done in the kernel interface.
53 r
.r_vals
= _portfs(PORT_CREATE
| PORT_SYS_NOPORT
, 0, 0, 0, 0, 0);
58 port_associate(int port
, int source
, uintptr_t object
, int events
, void *user
)
61 r
.r_vals
= _portfs(PORT_ASSOCIATE
, port
, source
, object
, events
,
68 port_get(int port
, port_event_t
*pe
, struct timespec
*to
)
72 r
.r_vals
= _portfs(PORT_GET
, port
, (uintptr_t)pe
, to
->tv_sec
,
73 to
->tv_nsec
, (uintptr_t)to
);
75 r
.r_vals
= _portfs(PORT_GET
, port
, (uintptr_t)pe
, 0, 0,
81 port_getn(int port
, port_event_t list
[], uint_t max
, uint_t
*nget
,
82 struct timespec
*timeout
)
89 r
.r_vals
= _portfs(PORT_GETN
, port
, (uintptr_t)list
, max
, *nget
,
92 /* global error, errno is already set */
96 if (r
.r_val2
== ETIME
) {
104 port_dissociate(int port
, int source
, uintptr_t object
)
107 r
.r_vals
= _portfs(PORT_DISSOCIATE
, port
, source
, object
, 0, 0);
112 port_send(int port
, int events
, void *user
)
115 r
.r_vals
= _portfs(PORT_SEND
, port
, events
, (uintptr_t)user
,
116 (uintptr_t)NULL
, (uintptr_t)NULL
);
122 * _port_dispatch() will block if there are not resources available to
123 * satisfy the request.
127 _port_dispatch(int port
, int flags
, int source
, int events
, uintptr_t object
,
131 if (flags
& PORT_SHARE_EVENT
)
132 r
.r_vals
= _portfs(PORT_DISPATCH
, port
, source
, events
, object
,
135 r
.r_vals
= _portfs(PORT_DISPATCH
| PORT_SYS_NOSHARE
, port
,
136 source
, events
, object
, (uintptr_t)user
);
141 port_sendn(int ports
[], int errors
[], uint_t nent
, int events
, void *user
)
147 if (nent
<= PORT_MAX_LIST
) {
148 r
.r_vals
= _portfs(PORT_SENDN
| PORT_SYS_NOPORT
,
149 (uintptr_t)ports
, (uintptr_t)errors
, nent
, events
,
154 /* use chunks of max PORT_MAX_LIST elements per syscall */
156 for (offset
= 0; offset
< nent
; ) {
157 lnent
= nent
- offset
;
158 if (nent
- offset
> PORT_MAX_LIST
)
159 lnent
= PORT_MAX_LIST
;
161 lnent
= nent
- offset
;
162 r
.r_vals
= _portfs(PORT_SENDN
| PORT_SYS_NOPORT
,
163 (uintptr_t)&ports
[offset
], (uintptr_t)&errors
[offset
],
164 lnent
, events
, (uintptr_t)user
);
165 if (r
.r_val2
== -1) {
166 /* global error, return last no of events submitted */
179 port_alert(int port
, int flags
, int events
, void *user
)
182 r
.r_vals
= _portfs(PORT_ALERT
, port
, flags
, events
, (uintptr_t)user
,