summaryrefslogtreecommitdiff
path: root/usr/src/lib/librcm/librcm_impl.h
blob: b096ffba0d6b7ddf82d0d11562b93d396a7cb02a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _LIBRCM_IMPL_H
#define	_LIBRCM_IMPL_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <syslog.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/systeminfo.h>
#include <librcm.h>

/*
 * This file contains information private to librcm rcm_daemon.
 */
#define	RCM_DAEMON_START	"/usr/lib/rcm/rcm_daemon"
#define	RCM_SERVICE_DOOR	"/var/run/rcm_daemon_door"
#define	RCM_MODULE_SUFFIX	"_rcm.so"

/*
 * flag fields supported by individual librcm interfaces
 */
#define	RCM_ALLOC_HDL_MASK	(RCM_NOPID)
#define	RCM_GET_INFO_MASK	(RCM_INCLUDE_SUBTREE|RCM_INCLUDE_DEPENDENT|\
				RCM_DR_OPERATION|RCM_MOD_INFO|RCM_FILESYS)
#define	RCM_REGISTER_MASK	(RCM_FILESYS|RCM_REGISTER_DR|\
				RCM_REGISTER_EVENT|RCM_REGISTER_CAPACITY)
#define	RCM_REQUEST_MASK	(RCM_QUERY|RCM_SCOPE|RCM_FORCE|RCM_FILESYS|\
				RCM_QUERY_CANCEL|RCM_RETIRE_REQUEST)
#define	RCM_NOTIFY_MASK		(RCM_FILESYS|RCM_RETIRE_NOTIFY)

/* event data names */
#define	RCM_CMD			"rcm.cmd"
#define	RCM_RESULT		"rcm.result"
#define	RCM_RESULT_INFO		"rcm.result_info"
#define	RCM_RSRCNAMES		"rcm.rsrcnames"
#define	RCM_RSRCSTATE		"rcm.rsrcstate"
#define	RCM_CLIENT_ID		"rcm.client_id"
#define	RCM_CLIENT_INFO		"rcm.client_info"
#define	RCM_CLIENT_ERROR	"rcm.client_error"
#define	RCM_CLIENT_MODNAME	"rcm.client_modname"
#define	RCM_CLIENT_PROPERTIES	"rcm.client_properties"
#define	RCM_SEQ_NUM		"rcm.seq_num"
#define	RCM_REQUEST_FLAG	"rcm.request_flag"
#define	RCM_SUSPEND_INTERVAL	"rcm.suspend_interval"
#define	RCM_CHANGE_DATA		"rcm.change_data"
#define	RCM_EVENT_DATA		"rcm.event_data"

/*
 * action commands shared by librcm and rcm_daemon
 */
#define	CMD_KNOCK		0
#define	CMD_REGISTER		1
#define	CMD_UNREGISTER		2
#define	CMD_GETINFO		3
#define	CMD_SUSPEND		4
#define	CMD_RESUME		5
#define	CMD_OFFLINE		6
#define	CMD_ONLINE		7
#define	CMD_REMOVE		8
#define	CMD_EVENT		9
#define	CMD_REQUEST_CHANGE	10
#define	CMD_NOTIFY_CHANGE	11
#define	CMD_GETSTATE		12

/*
 * Ops vector for calling directly into daemon from RCM modules
 */
typedef struct {
	int	(*librcm_regis)();
	int	(*librcm_unregis)();
	int	(*librcm_getinfo)();
	int	(*librcm_suspend)();
	int	(*librcm_resume)();
	int	(*librcm_offline)();
	int	(*librcm_online)();
	int	(*librcm_remove)();
	int	(*librcm_request_change)();
	int	(*librcm_notify_change)();
	int	(*librcm_notify_event)();
	int	(*librcm_getstate)();
} librcm_ops_t;

/*
 * rcm handle struture
 */
struct rcm_handle {
	char		*modname;
	pid_t		pid;
	int		seq_num;
	librcm_ops_t	*lrcm_ops;
	struct module	*module;
};

struct rcm_info {
	nvlist_t *info;
	struct rcm_info	*next;
};

/*
 * module utility routines
 */
char *rcm_module_dir(uint_t);
void *rcm_module_open(char *);
void rcm_module_close(void *);

/*
 * rcm scripting utility routines
 */
char *rcm_script_dir(uint_t dirnum);
char *rcm_dir(uint_t dirnum, int *rcm_script);
char *rcm_get_script_dir(char *script_name);
int rcm_is_script(char *filename);


#ifdef	__cplusplus
}
#endif

#endif /* _LIBRCM_IMPL_H */