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