xref: /titanic_44/usr/src/lib/libproc/common/pr_door.c (revision ee5416c9d7e449233197d5d20bc6b81e4ff091b2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 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 <stdlib.h>
30 #include <unistd.h>
31 #include <errno.h>
32 #include <door.h>
33 #include "libproc.h"
34 
35 /*
36  * door() system calls -- executed by subject process
37  */
38 
39 int
40 pr_door_info(struct ps_prochandle *Pr, int did, door_info_t *di)
41 {
42 	sysret_t rval;			/* return value from _door_info() */
43 	argdes_t argd[6];		/* arg descriptors for _door_info() */
44 	argdes_t *adp = &argd[0];	/* first argument */
45 	int error;
46 
47 	if (Pr == NULL)		/* no subject process */
48 		return (door_info(did, di));
49 
50 	adp->arg_value = did;
51 	adp->arg_object = NULL;
52 	adp->arg_type = AT_BYVAL;
53 	adp->arg_inout = AI_INPUT;
54 	adp->arg_size = 0;
55 	adp++;			/* move to door_info_t argument */
56 
57 	adp->arg_value = 0;
58 	adp->arg_object = di;
59 	adp->arg_type = AT_BYREF;
60 	adp->arg_inout = AI_OUTPUT;
61 	adp->arg_size = sizeof (door_info_t);
62 	adp++;			/* move to unused argument */
63 
64 	adp->arg_value = 0;
65 	adp->arg_object = NULL;
66 	adp->arg_type = AT_BYVAL;
67 	adp->arg_inout = AI_INPUT;
68 	adp->arg_size = 0;
69 	adp++;			/* move to unused argument */
70 
71 	adp->arg_value = 0;
72 	adp->arg_object = NULL;
73 	adp->arg_type = AT_BYVAL;
74 	adp->arg_inout = AI_INPUT;
75 	adp->arg_size = 0;
76 	adp++;			/* move to unused argument */
77 
78 	adp->arg_value = 0;
79 	adp->arg_object = NULL;
80 	adp->arg_type = AT_BYVAL;
81 	adp->arg_inout = AI_INPUT;
82 	adp->arg_size = 0;
83 	adp++;			/* move to subcode argument */
84 
85 	adp->arg_value = DOOR_INFO;
86 	adp->arg_object = NULL;
87 	adp->arg_type = AT_BYVAL;
88 	adp->arg_inout = AI_INPUT;
89 	adp->arg_size = 0;
90 
91 	error = Psyscall(Pr, &rval, SYS_door, 6, &argd[0]);
92 
93 	if (error) {
94 		errno = (error < 0)? ENOSYS : error;
95 		return (-1);
96 	}
97 	return (0);
98 }
99