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