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