7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <sys/types.h>
30 #include <sys/systm.h>
31 #include <sys/cred.h>
32 #include <sys/modctl.h>
33 #include <sys/vfs.h>
34 #include <sys/vfs_opreg.h>
35 #include <sys/sysmacros.h>
36 #include <sys/cmn_err.h>
37 #include <sys/stat.h>
38 #include <sys/errno.h>
39 #include <sys/kmem.h>
40 #include <sys/file.h>
41 #include <sys/kstat.h>
42 #include <sys/port_impl.h>
43 #include <sys/task.h>
44 #include <sys/project.h>
45
46 /*
47 * Event Ports can be shared across threads or across processes.
48 * Every thread/process can use an own event port or a group of them
397
398 static int64_t
399 portfs32(uint32_t arg1, int32_t arg2, uint32_t arg3, uint32_t arg4,
400 uint32_t arg5, uint32_t arg6);
401
402 static struct sysent port_sysent32 = {
403 6,
404 SE_ARGC | SE_64RVAL | SE_NOUNLOAD,
405 (int (*)())portfs32,
406 };
407
408 static struct modlsys modlsys32 = {
409 &mod_syscallops32,
410 "32-bit event ports syscalls",
411 &port_sysent32
412 };
413 #endif /* _SYSCALL32_IMPL */
414
415 static struct modlinkage modlinkage = {
416 MODREV_1,
417 &modlsys,
418 #ifdef _SYSCALL32_IMPL
419 &modlsys32,
420 #endif
421 NULL
422 };
423
424 port_kstat_t port_kstat = {
425 { "ports", KSTAT_DATA_UINT32 }
426 };
427
428 dev_t portdev;
429 struct vnodeops *port_vnodeops;
430 struct vfs port_vfs;
431
432 extern rctl_hndl_t rc_process_portev;
433 extern rctl_hndl_t rc_project_portids;
434 extern void aio_close_port(void *, int, pid_t, int);
435
436 /*
437 * This table contains a list of event sources which need a static
438 * association with a port (every port).
439 * The last NULL entry in the table is required to detect "end of table".
440 */
441 struct port_ksource port_ksource_tab[] = {
456 static int *port_errorn(int *, int, int, int);
457 static int port_noshare(void *, int *, pid_t, int, void *);
458 static int port_get_timeout(timespec_t *, timespec_t *, timespec_t **, int *,
459 int);
460 static void port_init(port_t *);
461 static void port_remove_alert(port_queue_t *);
462 static void port_add_ksource_local(port_t *, port_ksource_t *);
463 static void port_check_return_cond(port_queue_t *);
464 static void port_dequeue_thread(port_queue_t *, portget_t *);
465 static portget_t *port_queue_thread(port_queue_t *, uint_t);
466 static void port_kstat_init(void);
467
468 #ifdef _SYSCALL32_IMPL
469 static int port_copy_event32(port_event32_t *, port_kevent_t *, list_t *);
470 #endif
471
472 int
473 _init(void)
474 {
475 static const fs_operation_def_t port_vfsops_template[] = {
476 NULL, NULL
477 };
478 extern const fs_operation_def_t port_vnodeops_template[];
479 vfsops_t *port_vfsops;
480 int error;
481 major_t major;
482
483 if ((major = getudev()) == (major_t)-1)
484 return (ENXIO);
485 portdev = makedevice(major, 0);
486
487 /* Create a dummy vfs */
488 error = vfs_makefsops(port_vfsops_template, &port_vfsops);
489 if (error) {
490 cmn_err(CE_WARN, "port init: bad vfs ops");
491 return (error);
492 }
493 vfs_setops(&port_vfs, port_vfsops);
494 port_vfs.vfs_flag = VFS_RDONLY;
495 port_vfs.vfs_dev = portdev;
496 vfs_make_fsid(&(port_vfs.vfs_fsid), portdev, 0);
|
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <sys/types.h>
28 #include <sys/systm.h>
29 #include <sys/cred.h>
30 #include <sys/modctl.h>
31 #include <sys/vfs.h>
32 #include <sys/vfs_opreg.h>
33 #include <sys/sysmacros.h>
34 #include <sys/cmn_err.h>
35 #include <sys/stat.h>
36 #include <sys/errno.h>
37 #include <sys/kmem.h>
38 #include <sys/file.h>
39 #include <sys/kstat.h>
40 #include <sys/port_impl.h>
41 #include <sys/task.h>
42 #include <sys/project.h>
43
44 /*
45 * Event Ports can be shared across threads or across processes.
46 * Every thread/process can use an own event port or a group of them
395
396 static int64_t
397 portfs32(uint32_t arg1, int32_t arg2, uint32_t arg3, uint32_t arg4,
398 uint32_t arg5, uint32_t arg6);
399
400 static struct sysent port_sysent32 = {
401 6,
402 SE_ARGC | SE_64RVAL | SE_NOUNLOAD,
403 (int (*)())portfs32,
404 };
405
406 static struct modlsys modlsys32 = {
407 &mod_syscallops32,
408 "32-bit event ports syscalls",
409 &port_sysent32
410 };
411 #endif /* _SYSCALL32_IMPL */
412
413 static struct modlinkage modlinkage = {
414 MODREV_1,
415 { &modlsys,
416 #ifdef _SYSCALL32_IMPL
417 &modlsys32,
418 #endif
419 NULL
420 }
421 };
422
423 port_kstat_t port_kstat = {
424 { "ports", KSTAT_DATA_UINT32 }
425 };
426
427 dev_t portdev;
428 struct vnodeops *port_vnodeops;
429 struct vfs port_vfs;
430
431 extern rctl_hndl_t rc_process_portev;
432 extern rctl_hndl_t rc_project_portids;
433 extern void aio_close_port(void *, int, pid_t, int);
434
435 /*
436 * This table contains a list of event sources which need a static
437 * association with a port (every port).
438 * The last NULL entry in the table is required to detect "end of table".
439 */
440 struct port_ksource port_ksource_tab[] = {
455 static int *port_errorn(int *, int, int, int);
456 static int port_noshare(void *, int *, pid_t, int, void *);
457 static int port_get_timeout(timespec_t *, timespec_t *, timespec_t **, int *,
458 int);
459 static void port_init(port_t *);
460 static void port_remove_alert(port_queue_t *);
461 static void port_add_ksource_local(port_t *, port_ksource_t *);
462 static void port_check_return_cond(port_queue_t *);
463 static void port_dequeue_thread(port_queue_t *, portget_t *);
464 static portget_t *port_queue_thread(port_queue_t *, uint_t);
465 static void port_kstat_init(void);
466
467 #ifdef _SYSCALL32_IMPL
468 static int port_copy_event32(port_event32_t *, port_kevent_t *, list_t *);
469 #endif
470
471 int
472 _init(void)
473 {
474 static const fs_operation_def_t port_vfsops_template[] = {
475 { NULL, { NULL } }
476 };
477 extern const fs_operation_def_t port_vnodeops_template[];
478 vfsops_t *port_vfsops;
479 int error;
480 major_t major;
481
482 if ((major = getudev()) == (major_t)-1)
483 return (ENXIO);
484 portdev = makedevice(major, 0);
485
486 /* Create a dummy vfs */
487 error = vfs_makefsops(port_vfsops_template, &port_vfsops);
488 if (error) {
489 cmn_err(CE_WARN, "port init: bad vfs ops");
490 return (error);
491 }
492 vfs_setops(&port_vfs, port_vfsops);
493 port_vfs.vfs_flag = VFS_RDONLY;
494 port_vfs.vfs_dev = portdev;
495 vfs_make_fsid(&(port_vfs.vfs_fsid), portdev, 0);
|