xref: /titanic_51/usr/src/cmd/rcm_daemon/common/rcm_module.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 (c) 1999-2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _RCM_MODULE_H
28*7c478bd9Sstevel@tonic-gate #define	_RCM_MODULE_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 <librcm.h>
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /*
39*7c478bd9Sstevel@tonic-gate  * Each RCM module is required to define
40*7c478bd9Sstevel@tonic-gate  *
41*7c478bd9Sstevel@tonic-gate  * struct rcm_mod_ops *rcm_mod_init();
42*7c478bd9Sstevel@tonic-gate  * const char *rcm_mod_info();
43*7c478bd9Sstevel@tonic-gate  * int rcm_mod_fini();
44*7c478bd9Sstevel@tonic-gate  *
45*7c478bd9Sstevel@tonic-gate  * The rcm_mod_init() is always invoked when the module is loaded. It should
46*7c478bd9Sstevel@tonic-gate  * return an rcm_mod_ops vector.
47*7c478bd9Sstevel@tonic-gate  *
48*7c478bd9Sstevel@tonic-gate  * Once the module is loaded, the regis() entry point is
49*7c478bd9Sstevel@tonic-gate  * called to allow the module to inform the framework all the
50*7c478bd9Sstevel@tonic-gate  * events and devices it cares about.
51*7c478bd9Sstevel@tonic-gate  *
52*7c478bd9Sstevel@tonic-gate  * If at any point of time, the module has no outstanding registration
53*7c478bd9Sstevel@tonic-gate  * against any device, the module will be unloaded. The rcm_mod_fini()
54*7c478bd9Sstevel@tonic-gate  * entry point, if defined, is always invoked before module unloading.
55*7c478bd9Sstevel@tonic-gate  */
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /*
59*7c478bd9Sstevel@tonic-gate  * ops vector:
60*7c478bd9Sstevel@tonic-gate  * The ops version must have a valid version number and all function fields
61*7c478bd9Sstevel@tonic-gate  * must be non-NULL. Non-conforming RCM modules are rejected.
62*7c478bd9Sstevel@tonic-gate  *
63*7c478bd9Sstevel@tonic-gate  * Valid ops versions are defined below.
64*7c478bd9Sstevel@tonic-gate  */
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate #define	RCM_MOD_OPS_V1		1
67*7c478bd9Sstevel@tonic-gate #define	RCM_MOD_OPS_V2		2
68*7c478bd9Sstevel@tonic-gate #define	RCM_MOD_OPS_VERSION	RCM_MOD_OPS_V2
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate struct rcm_mod_ops {
71*7c478bd9Sstevel@tonic-gate 	int	version;
72*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_register)(rcm_handle_t *);
73*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_unregister)(rcm_handle_t *);
74*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_get_info)(rcm_handle_t *, char *, id_t, uint_t,
75*7c478bd9Sstevel@tonic-gate 			char **, char **, nvlist_t *, rcm_info_t **);
76*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_request_suspend)(rcm_handle_t *, char *, id_t,
77*7c478bd9Sstevel@tonic-gate 			timespec_t *, uint_t, char **, rcm_info_t **);
78*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_resume)(rcm_handle_t *, char *, id_t, uint_t,
79*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
80*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_request_offline)(rcm_handle_t *, char *, id_t, uint_t,
81*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
82*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_online)(rcm_handle_t *, char *, id_t, uint_t,
83*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
84*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_remove)(rcm_handle_t *, char *, id_t, uint_t,
85*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
86*7c478bd9Sstevel@tonic-gate 	/*
87*7c478bd9Sstevel@tonic-gate 	 * Fields for version 2 and beyond
88*7c478bd9Sstevel@tonic-gate 	 */
89*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_request_capacity_change)(rcm_handle_t *, char *, id_t,
90*7c478bd9Sstevel@tonic-gate 			uint_t, nvlist_t *, char **, rcm_info_t **);
91*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_capacity_change)(rcm_handle_t *, char *, id_t,
92*7c478bd9Sstevel@tonic-gate 			uint_t, nvlist_t *, char **, rcm_info_t **);
93*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_event)(rcm_handle_t *, char *, id_t, uint_t,
94*7c478bd9Sstevel@tonic-gate 			char **, nvlist_t *, rcm_info_t **);
95*7c478bd9Sstevel@tonic-gate };
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate /*
98*7c478bd9Sstevel@tonic-gate  * Version 1 struct for compatibility
99*7c478bd9Sstevel@tonic-gate  */
100*7c478bd9Sstevel@tonic-gate struct rcm_mod_ops_v1 {
101*7c478bd9Sstevel@tonic-gate 	int	version;
102*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_register)(rcm_handle_t *);
103*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_unregister)(rcm_handle_t *);
104*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_get_info)(rcm_handle_t *, char *, id_t, uint_t, char **,
105*7c478bd9Sstevel@tonic-gate 			rcm_info_t **);
106*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_request_suspend)(rcm_handle_t *, char *, id_t,
107*7c478bd9Sstevel@tonic-gate 			timespec_t *, uint_t, char **, rcm_info_t **);
108*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_resume)(rcm_handle_t *, char *, id_t, uint_t,
109*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
110*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_request_offline)(rcm_handle_t *, char *, id_t, uint_t,
111*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
112*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_online)(rcm_handle_t *, char *, id_t, uint_t,
113*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
114*7c478bd9Sstevel@tonic-gate 	int	(*rcmop_notify_remove)(rcm_handle_t *, char *, id_t, uint_t,
115*7c478bd9Sstevel@tonic-gate 			char **, rcm_info_t **);
116*7c478bd9Sstevel@tonic-gate };
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate /*
119*7c478bd9Sstevel@tonic-gate  * RCM modules should use rcm_log_message() instead of syslog().
120*7c478bd9Sstevel@tonic-gate  * This allows the daemon to control the amount of message to be
121*7c478bd9Sstevel@tonic-gate  * printed and to redirect output to screen for debugging purposes.
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate /* message levels for rcm_log_message */
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate #define	RCM_ERROR	0	/* error message */
127*7c478bd9Sstevel@tonic-gate #define	RCM_WARNING	1
128*7c478bd9Sstevel@tonic-gate #define	RCM_NOTICE	2
129*7c478bd9Sstevel@tonic-gate #define	RCM_INFO	3
130*7c478bd9Sstevel@tonic-gate 				/* 4 is not used for now */
131*7c478bd9Sstevel@tonic-gate #define	RCM_DEBUG	5	/* debug message */
132*7c478bd9Sstevel@tonic-gate #define	RCM_TRACE1	6	/* tracing message */
133*7c478bd9Sstevel@tonic-gate #define	RCM_TRACE2	7
134*7c478bd9Sstevel@tonic-gate #define	RCM_TRACE3	8
135*7c478bd9Sstevel@tonic-gate #define	RCM_TRACE4	9
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate extern void rcm_log_message(int, char *, ...);
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
140*7c478bd9Sstevel@tonic-gate }
141*7c478bd9Sstevel@tonic-gate #endif
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate #endif /* _RCM_MODULE_H */
144