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