xref: /titanic_41/usr/src/lib/librcm/librcm_impl.h (revision 3db86aab554edbb4244c8d1a1c90f152eee768af)
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 #ifndef _LIBRCM_IMPL_H
28 #define	_LIBRCM_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <assert.h>
37 #include <stdio.h>
38 #include <stdarg.h>
39 #include <dlfcn.h>
40 #include <errno.h>
41 #include <fcntl.h>
42 #include <poll.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <strings.h>
46 #include <syslog.h>
47 #include <unistd.h>
48 #include <sys/mman.h>
49 #include <sys/wait.h>
50 #include <sys/types.h>
51 #include <sys/stat.h>
52 #include <sys/param.h>
53 #include <sys/systeminfo.h>
54 #include <librcm.h>
55 
56 /*
57  * This file contains information private to librcm rcm_daemon.
58  */
59 #define	RCM_DAEMON_START	"/usr/lib/rcm/rcm_daemon"
60 #define	RCM_SERVICE_DOOR	"/var/run/rcm_daemon_door"
61 #define	RCM_MODULE_SUFFIX	"_rcm.so"
62 
63 /*
64  * flag fields supported by individual librcm interfaces
65  */
66 #define	RCM_ALLOC_HDL_MASK	(RCM_NOPID)
67 #define	RCM_GET_INFO_MASK	(RCM_INCLUDE_SUBTREE|RCM_INCLUDE_DEPENDENT|\
68 				RCM_DR_OPERATION|RCM_MOD_INFO|RCM_FILESYS)
69 #define	RCM_REGISTER_MASK	(RCM_FILESYS|RCM_REGISTER_DR|\
70 				RCM_REGISTER_EVENT|RCM_REGISTER_CAPACITY)
71 #define	RCM_REQUEST_MASK	(RCM_QUERY|RCM_SCOPE|RCM_FORCE|RCM_FILESYS|\
72 				RCM_QUERY_CANCEL)
73 #define	RCM_NOTIFY_MASK		(RCM_FILESYS)
74 
75 /* event data names */
76 #define	RCM_CMD			"rcm.cmd"
77 #define	RCM_RESULT		"rcm.result"
78 #define	RCM_RESULT_INFO		"rcm.result_info"
79 #define	RCM_RSRCNAMES		"rcm.rsrcnames"
80 #define	RCM_RSRCSTATE		"rcm.rsrcstate"
81 #define	RCM_CLIENT_ID		"rcm.client_id"
82 #define	RCM_CLIENT_INFO		"rcm.client_info"
83 #define	RCM_CLIENT_ERROR	"rcm.client_error"
84 #define	RCM_CLIENT_MODNAME	"rcm.client_modname"
85 #define	RCM_CLIENT_PROPERTIES	"rcm.client_properties"
86 #define	RCM_SEQ_NUM		"rcm.seq_num"
87 #define	RCM_REQUEST_FLAG	"rcm.request_flag"
88 #define	RCM_SUSPEND_INTERVAL	"rcm.suspend_interval"
89 #define	RCM_CHANGE_DATA		"rcm.change_data"
90 #define	RCM_EVENT_DATA		"rcm.event_data"
91 
92 /*
93  * action commands shared by librcm and rcm_daemon
94  */
95 #define	CMD_KNOCK		0
96 #define	CMD_REGISTER		1
97 #define	CMD_UNREGISTER		2
98 #define	CMD_GETINFO		3
99 #define	CMD_SUSPEND		4
100 #define	CMD_RESUME		5
101 #define	CMD_OFFLINE		6
102 #define	CMD_ONLINE		7
103 #define	CMD_REMOVE		8
104 #define	CMD_EVENT		9
105 #define	CMD_REQUEST_CHANGE	10
106 #define	CMD_NOTIFY_CHANGE	11
107 #define	CMD_GETSTATE		12
108 
109 /*
110  * Ops vector for calling directly into daemon from RCM modules
111  */
112 typedef struct {
113 	int	(*librcm_regis)();
114 	int	(*librcm_unregis)();
115 	int	(*librcm_getinfo)();
116 	int	(*librcm_suspend)();
117 	int	(*librcm_resume)();
118 	int	(*librcm_offline)();
119 	int	(*librcm_online)();
120 	int	(*librcm_remove)();
121 	int	(*librcm_request_change)();
122 	int	(*librcm_notify_change)();
123 	int	(*librcm_notify_event)();
124 	int	(*librcm_getstate)();
125 } librcm_ops_t;
126 
127 /*
128  * rcm handle struture
129  */
130 struct rcm_handle {
131 	char		*modname;
132 	pid_t		pid;
133 	int		seq_num;
134 	librcm_ops_t	*lrcm_ops;
135 	struct module	*module;
136 };
137 
138 struct rcm_info {
139 	nvlist_t *info;
140 	struct rcm_info	*next;
141 };
142 
143 /*
144  * module utility routines
145  */
146 char *rcm_module_dir(uint_t);
147 void *rcm_module_open(char *);
148 void rcm_module_close(void *);
149 
150 /*
151  * rcm scripting utility routines
152  */
153 char *rcm_script_dir(uint_t dirnum);
154 char *rcm_dir(uint_t dirnum, int *rcm_script);
155 char *rcm_get_script_dir(char *script_name);
156 int rcm_is_script(char *filename);
157 
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif /* _LIBRCM_IMPL_H */
164