1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _LIBRCM_IMPL_H
28*0Sstevel@tonic-gate #define	_LIBRCM_IMPL_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef	__cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <assert.h>
37*0Sstevel@tonic-gate #include <stdio.h>
38*0Sstevel@tonic-gate #include <stdarg.h>
39*0Sstevel@tonic-gate #include <dlfcn.h>
40*0Sstevel@tonic-gate #include <errno.h>
41*0Sstevel@tonic-gate #include <fcntl.h>
42*0Sstevel@tonic-gate #include <poll.h>
43*0Sstevel@tonic-gate #include <stdlib.h>
44*0Sstevel@tonic-gate #include <string.h>
45*0Sstevel@tonic-gate #include <strings.h>
46*0Sstevel@tonic-gate #include <syslog.h>
47*0Sstevel@tonic-gate #include <unistd.h>
48*0Sstevel@tonic-gate #include <sys/mman.h>
49*0Sstevel@tonic-gate #include <sys/wait.h>
50*0Sstevel@tonic-gate #include <sys/types.h>
51*0Sstevel@tonic-gate #include <sys/stat.h>
52*0Sstevel@tonic-gate #include <sys/param.h>
53*0Sstevel@tonic-gate #include <sys/systeminfo.h>
54*0Sstevel@tonic-gate #include <librcm.h>
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate /*
57*0Sstevel@tonic-gate  * This file contains information private to librcm rcm_daemon.
58*0Sstevel@tonic-gate  */
59*0Sstevel@tonic-gate #define	RCM_DAEMON_START	"/usr/lib/rcm/rcm_daemon"
60*0Sstevel@tonic-gate #define	RCM_SERVICE_DOOR	"/var/run/rcm_daemon_door"
61*0Sstevel@tonic-gate #define	RCM_MODULE_SUFFIX	"_rcm.so"
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /*
64*0Sstevel@tonic-gate  * flag fields supported by individual librcm interfaces
65*0Sstevel@tonic-gate  */
66*0Sstevel@tonic-gate #define	RCM_ALLOC_HDL_MASK	(RCM_NOPID)
67*0Sstevel@tonic-gate #define	RCM_GET_INFO_MASK	(RCM_INCLUDE_SUBTREE|RCM_INCLUDE_DEPENDENT|\
68*0Sstevel@tonic-gate 				RCM_DR_OPERATION|RCM_MOD_INFO|RCM_FILESYS)
69*0Sstevel@tonic-gate #define	RCM_REGISTER_MASK	(RCM_FILESYS|RCM_REGISTER_DR|\
70*0Sstevel@tonic-gate 				RCM_REGISTER_EVENT|RCM_REGISTER_CAPACITY)
71*0Sstevel@tonic-gate #define	RCM_REQUEST_MASK	(RCM_QUERY|RCM_SCOPE|RCM_FORCE|RCM_FILESYS|\
72*0Sstevel@tonic-gate 				RCM_QUERY_CANCEL)
73*0Sstevel@tonic-gate #define	RCM_NOTIFY_MASK		(RCM_FILESYS)
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate /* event data names */
76*0Sstevel@tonic-gate #define	RCM_CMD			"rcm.cmd"
77*0Sstevel@tonic-gate #define	RCM_RESULT		"rcm.result"
78*0Sstevel@tonic-gate #define	RCM_RESULT_INFO		"rcm.result_info"
79*0Sstevel@tonic-gate #define	RCM_RSRCNAMES		"rcm.rsrcnames"
80*0Sstevel@tonic-gate #define	RCM_RSRCSTATE		"rcm.rsrcstate"
81*0Sstevel@tonic-gate #define	RCM_CLIENT_ID		"rcm.client_id"
82*0Sstevel@tonic-gate #define	RCM_CLIENT_INFO		"rcm.client_info"
83*0Sstevel@tonic-gate #define	RCM_CLIENT_ERROR	"rcm.client_error"
84*0Sstevel@tonic-gate #define	RCM_CLIENT_MODNAME	"rcm.client_modname"
85*0Sstevel@tonic-gate #define	RCM_CLIENT_PROPERTIES	"rcm.client_properties"
86*0Sstevel@tonic-gate #define	RCM_SEQ_NUM		"rcm.seq_num"
87*0Sstevel@tonic-gate #define	RCM_REQUEST_FLAG	"rcm.request_flag"
88*0Sstevel@tonic-gate #define	RCM_SUSPEND_INTERVAL	"rcm.suspend_interval"
89*0Sstevel@tonic-gate #define	RCM_CHANGE_DATA		"rcm.change_data"
90*0Sstevel@tonic-gate #define	RCM_EVENT_DATA		"rcm.event_data"
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate /*
93*0Sstevel@tonic-gate  * action commands shared by librcm and rcm_daemon
94*0Sstevel@tonic-gate  */
95*0Sstevel@tonic-gate #define	CMD_KNOCK		0
96*0Sstevel@tonic-gate #define	CMD_REGISTER		1
97*0Sstevel@tonic-gate #define	CMD_UNREGISTER		2
98*0Sstevel@tonic-gate #define	CMD_GETINFO		3
99*0Sstevel@tonic-gate #define	CMD_SUSPEND		4
100*0Sstevel@tonic-gate #define	CMD_RESUME		5
101*0Sstevel@tonic-gate #define	CMD_OFFLINE		6
102*0Sstevel@tonic-gate #define	CMD_ONLINE		7
103*0Sstevel@tonic-gate #define	CMD_REMOVE		8
104*0Sstevel@tonic-gate #define	CMD_EVENT		9
105*0Sstevel@tonic-gate #define	CMD_REQUEST_CHANGE	10
106*0Sstevel@tonic-gate #define	CMD_NOTIFY_CHANGE	11
107*0Sstevel@tonic-gate #define	CMD_GETSTATE		12
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * Ops vector for calling directly into daemon from RCM modules
111*0Sstevel@tonic-gate  */
112*0Sstevel@tonic-gate typedef struct {
113*0Sstevel@tonic-gate 	int	(*librcm_regis)();
114*0Sstevel@tonic-gate 	int	(*librcm_unregis)();
115*0Sstevel@tonic-gate 	int	(*librcm_getinfo)();
116*0Sstevel@tonic-gate 	int	(*librcm_suspend)();
117*0Sstevel@tonic-gate 	int	(*librcm_resume)();
118*0Sstevel@tonic-gate 	int	(*librcm_offline)();
119*0Sstevel@tonic-gate 	int	(*librcm_online)();
120*0Sstevel@tonic-gate 	int	(*librcm_remove)();
121*0Sstevel@tonic-gate 	int	(*librcm_request_change)();
122*0Sstevel@tonic-gate 	int	(*librcm_notify_change)();
123*0Sstevel@tonic-gate 	int	(*librcm_notify_event)();
124*0Sstevel@tonic-gate 	int	(*librcm_getstate)();
125*0Sstevel@tonic-gate } librcm_ops_t;
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate /*
128*0Sstevel@tonic-gate  * rcm handle struture
129*0Sstevel@tonic-gate  */
130*0Sstevel@tonic-gate struct rcm_handle {
131*0Sstevel@tonic-gate 	char		*modname;
132*0Sstevel@tonic-gate 	pid_t		pid;
133*0Sstevel@tonic-gate 	int		seq_num;
134*0Sstevel@tonic-gate 	librcm_ops_t	*lrcm_ops;
135*0Sstevel@tonic-gate 	struct module	*module;
136*0Sstevel@tonic-gate };
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate struct rcm_info {
139*0Sstevel@tonic-gate 	nvlist_t *info;
140*0Sstevel@tonic-gate 	struct rcm_info	*next;
141*0Sstevel@tonic-gate };
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate /*
144*0Sstevel@tonic-gate  * module utility routines
145*0Sstevel@tonic-gate  */
146*0Sstevel@tonic-gate char *rcm_module_dir(uint_t);
147*0Sstevel@tonic-gate void *rcm_module_open(char *);
148*0Sstevel@tonic-gate void rcm_module_close(void *);
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate /*
151*0Sstevel@tonic-gate  * rcm scripting utility routines
152*0Sstevel@tonic-gate  */
153*0Sstevel@tonic-gate char *rcm_script_dir(uint_t dirnum);
154*0Sstevel@tonic-gate char *rcm_dir(uint_t dirnum, int *rcm_script);
155*0Sstevel@tonic-gate char *rcm_get_script_dir(char *script_name);
156*0Sstevel@tonic-gate int rcm_is_script(char *filename);
157*0Sstevel@tonic-gate 
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate #ifdef	__cplusplus
160*0Sstevel@tonic-gate }
161*0Sstevel@tonic-gate #endif
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate #endif /* _LIBRCM_IMPL_H */
164