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 2000-2002 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _ENVD_H 28 #define _ENVD_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> 33 #include <libintl.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #define SENSOR_POLL_INTERVAL 4 /* in seconds */ 40 #define WARNING_INTERVAL 30 /* in seconds */ 41 #define SHUTDOWN_INTERVAL 20 /* in seconds */ 42 #define ENV_CONF_FILE "piclenvd.conf" 43 #define ENVMODEL_CONF_FILE "envmodel.conf" 44 #define PM_DEVICE "/dev/pm" 45 #define SHUTDOWN_CMD "/usr/sbin/shutdown -y -g 60 -i 5" 46 47 /* 48 * devfs-path for various fans and their min/max speeds 49 */ 50 #define ENV_CPU_FAN_DEVFS \ 51 "/pci@1f,0/pmu@3/fan-control@0,c8:cpu_fan" 52 #define ENV_SYSTEM_FAN_DEVFS \ 53 "/pci@1f,0/pmu@3/fan-control@0,c8:sys_fan" 54 55 #define SYSTEM_FAN_SPEED_MIN 0 56 #define SYSTEM_FAN_SPEED_MAX 100 57 58 59 /* 60 * devfs-path for various temperature sensors and CPU platform path 61 */ 62 #define CPU_DIE_SENSOR_DEVFS \ 63 "/pci@1f,0/pmu@3/i2c@0,0/temperature@30:die_temp" 64 #define CPU_AMB_SENSOR_DEVFS \ 65 "/pci@1f,0/pmu@3/i2c@0,0/temperature@30:amb_temp" 66 67 /* 68 * Temperature thresholds structure 69 */ 70 typedef int16_t tempr_t; 71 72 typedef struct { 73 tempr_t low_power_off; /* low power-off temperature */ 74 tempr_t high_power_off; /* high power-off temperature */ 75 tempr_t low_shutdown; /* low shutdown temperature */ 76 tempr_t high_shutdown; /* high shutdown temperature */ 77 tempr_t low_warning; /* low warning temperature */ 78 tempr_t high_warning; /* high warning temperature */ 79 tempr_t target_temp; /* target temperature */ 80 } sensor_thresh_t; 81 82 #define TEMP_IN_SHUTDOWN_RANGE(val, threshp) \ 83 ((val) > (threshp)->high_shutdown || (val) < (threshp)->low_shutdown) 84 85 #define TEMP_IN_WARNING_RANGE(val, threshp) \ 86 ((val) > (threshp)->high_warning || (val) < (threshp)->low_warning) 87 88 89 /* 90 * CPU "die" temperature thresholds 91 */ 92 #define CPU_DIE_HIGH_POWER_OFF 125 93 #define CPU_DIE_HIGH_SHUTDOWN 90 94 #define CPU_DIE_HIGH_WARNING 85 95 #define CPU_DIE_TARGET_TEMP 80 96 #define CPU_DIE_LOW_WARNING 0 97 #define CPU_DIE_LOW_SHUTDOWN -10 98 #define CPU_DIE_LOW_POWER_OFF -20 99 100 /* 101 * CPU ambient temperature thresholds 102 */ 103 #define CPU_AMB_HIGH_POWER_OFF 70 104 #define CPU_AMB_HIGH_SHUTDOWN 60 105 #define CPU_AMB_HIGH_WARNING 40 106 #define CPU_AMB_TARGET_TEMP 32 107 #define CPU_AMB_LOW_WARNING 0 108 #define CPU_AMB_LOW_SHUTDOWN -10 109 #define CPU_AMB_LOW_POWER_OFF -20 110 111 112 /* 113 * Fan names 114 */ 115 #define ENV_SYSTEM_FAN "system" 116 117 /* 118 * Sensor names 119 */ 120 #define SENSOR_CPU_DIE "cpu" 121 #define SENSOR_CPU_AMB "cpu-ambient" 122 123 /* 124 * Temperature sensor related data structure 125 */ 126 typedef struct env_sensor { 127 char *name; /* sensor name */ 128 char *devfs_path; /* sensor device devfs path */ 129 sensor_thresh_t *temp_thresh; /* sensor temp threshold */ 130 int fd; /* device file descriptor */ 131 int error; /* error flag */ 132 boolean_t present; /* sensor present */ 133 tempr_t cur_temp; /* current temperature */ 134 time_t warning_tstamp; /* last warning time in secs */ 135 time_t shutdown_tstamp; /* shutdown temp time (secs) */ 136 boolean_t shutdown_initiated; /* shutdown initated */ 137 } env_sensor_t; 138 139 extern env_sensor_t *sensor_lookup(char *sensor_name); 140 extern int get_temperature(env_sensor_t *, tempr_t *); 141 142 /* 143 * Fan information data structure 144 */ 145 typedef uint8_t fanspeed_t; 146 147 typedef struct env_fan { 148 char *name; /* fan name */ 149 char *devfs_path; /* fan device devfs path */ 150 fanspeed_t speed_min; /* minimum speed */ 151 fanspeed_t speed_max; /* maximum speed */ 152 int fd; /* device file descriptor */ 153 boolean_t present; /* fan present */ 154 fanspeed_t cur_speed; /* current fan speed */ 155 fanspeed_t prev_speed; /* previous fan speed */ 156 } env_fan_t; 157 158 159 extern env_fan_t *fan_lookup(char *fan_name); 160 extern int get_fan_speed(env_fan_t *, fanspeed_t *); 161 162 extern int env_debug; 163 extern void envd_log(int pri, const char *fmt, ...); 164 165 /* 166 * Various messages 167 */ 168 #define ENVD_PLUGIN_INIT_FAILED \ 169 gettext("SUNW_piclenvd: initialization failed!\n") 170 171 #define ENVD_PICL_SETUP_FAILED \ 172 gettext("SUNW_piclenvd: PICL setup failed!\n") 173 174 #define PM_THREAD_CREATE_FAILED \ 175 gettext("SUNW_piclenvd: pmthr thread creation failed!\n") 176 177 #define PM_THREAD_EXITING \ 178 gettext("SUNW_piclenvd: pmthr exiting! errno:%d %s\n") 179 180 #define ENV_THREAD_CREATE_FAILED \ 181 gettext("SUNW_piclenvd: envthr thread creation failed!\n") 182 183 #define ENV_SHUTDOWN_MSG \ 184 gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \ 185 "limits (%d...%d). Shutting down the system.\n") 186 187 #define ENV_WARNING_MSG \ 188 gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \ 189 "operating limits (%d...%d).\n") 190 191 #define ENV_FAN_OPEN_FAIL \ 192 gettext("SUNW_piclenvd: can't open '%s' fan path:%s errno:%d %s\n") 193 194 #define ENV_SENSOR_OPEN_FAIL \ 195 gettext("SUNW_piclenvd: can't open '%s' sensor path:%s errno:%d %s\n") 196 197 #define ENV_SENSOR_ACCESS_FAIL \ 198 gettext("SUNW_piclenvd: can't access '%s' sensor errno:%d %s\n") 199 200 #define ENV_SENSOR_ACCESS_OK \ 201 gettext("SUNW_piclenvd: '%s' sensor is accessible now.\n") 202 203 #define ENV_CONF_INT_EXPECTED \ 204 gettext("SUNW_piclenvd: file:%s line:%d Invalid syntax or integer " \ 205 "value outside range for keyword '%s'.\n") 206 207 #define ENV_CONF_STRING_EXPECTED \ 208 gettext("SUNW_piclenvd: file:%s line:%d Invalid syntax for keyword " \ 209 "'%s'. Expecting string in double quotes (length < %d).\n") 210 211 #define ENV_CONF_UNSUPPORTED_TYPE \ 212 gettext("SUNW_piclenvd: file:%s line:%d Unsupported type:%d for " \ 213 "keyword '%s'.\n") 214 215 #define ENV_CONF_UNSUPPORTED_KEYWORD \ 216 gettext("SUNW_piclenvd: file:%s line:%d Unsupported keyword '%s'.\n") 217 218 #ifdef __cplusplus 219 } 220 #endif 221 222 #endif /* _ENVD_H */ 223