1*03831d35Sstevel /* 2*03831d35Sstevel * CDDL HEADER START 3*03831d35Sstevel * 4*03831d35Sstevel * The contents of this file are subject to the terms of the 5*03831d35Sstevel * Common Development and Distribution License (the "License"). 6*03831d35Sstevel * You may not use this file except in compliance with the License. 7*03831d35Sstevel * 8*03831d35Sstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*03831d35Sstevel * or http://www.opensolaris.org/os/licensing. 10*03831d35Sstevel * See the License for the specific language governing permissions 11*03831d35Sstevel * and limitations under the License. 12*03831d35Sstevel * 13*03831d35Sstevel * When distributing Covered Code, include this CDDL HEADER in each 14*03831d35Sstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*03831d35Sstevel * If applicable, add the following below this CDDL HEADER, with the 16*03831d35Sstevel * fields enclosed by brackets "[]" replaced with your own identifying 17*03831d35Sstevel * information: Portions Copyright [yyyy] [name of copyright owner] 18*03831d35Sstevel * 19*03831d35Sstevel * CDDL HEADER END 20*03831d35Sstevel */ 21*03831d35Sstevel 22*03831d35Sstevel /* 23*03831d35Sstevel * Copyright 2000 Sun Microsystems, Inc. All rights reserved. 24*03831d35Sstevel * Use is subject to license terms. 25*03831d35Sstevel */ 26*03831d35Sstevel 27*03831d35Sstevel #ifndef _SYS_SGENV_H 28*03831d35Sstevel #define _SYS_SGENV_H 29*03831d35Sstevel 30*03831d35Sstevel #pragma ident "%Z%%M% %I% %E% SMI" 31*03831d35Sstevel 32*03831d35Sstevel #ifdef __cplusplus 33*03831d35Sstevel extern "C" { 34*03831d35Sstevel #endif 35*03831d35Sstevel 36*03831d35Sstevel /* 37*03831d35Sstevel * sgenv.h - Serengeti Environmental Driver 38*03831d35Sstevel * 39*03831d35Sstevel * This header file contains the environmental definitions for 40*03831d35Sstevel * the Serengeti platform. 41*03831d35Sstevel * 42*03831d35Sstevel * It contains all the information necessary to obtain the required 43*03831d35Sstevel * data from the kstats which export the environmental data. The 44*03831d35Sstevel * following information is exported. 45*03831d35Sstevel * 46*03831d35Sstevel * o Board status information 47*03831d35Sstevel * o Keyswitch position 48*03831d35Sstevel * o Environmental Readings 49*03831d35Sstevel */ 50*03831d35Sstevel 51*03831d35Sstevel #include <sys/time.h> /* hrtime_t */ 52*03831d35Sstevel #include <sys/sgenv_tag.h> /* TagID information */ 53*03831d35Sstevel #include <sys/sgfrutypes.h> /* HPU type information */ 54*03831d35Sstevel #include <sys/serengeti.h> 55*03831d35Sstevel 56*03831d35Sstevel #define SGENV_DRV_NAME "sgenv" 57*03831d35Sstevel 58*03831d35Sstevel /* 59*03831d35Sstevel * Board Status Information 60*03831d35Sstevel * ======================== 61*03831d35Sstevel */ 62*03831d35Sstevel 63*03831d35Sstevel /* name of kstat returning board status info */ 64*03831d35Sstevel #define SG_BOARD_STATUS_KSTAT_NAME "sg_board_status" 65*03831d35Sstevel 66*03831d35Sstevel /* Masks to determine which LEDs are on */ 67*03831d35Sstevel #define SG_HOTPLUG_LED_MASK 0x1 68*03831d35Sstevel #define SG_FAULT_LED_MASK 0x2 69*03831d35Sstevel #define SG_POWER_LED_MASK 0x4 70*03831d35Sstevel 71*03831d35Sstevel /* 72*03831d35Sstevel * Calculate the number of boards, who's info readings that were 73*03831d35Sstevel * returned by this kstat 74*03831d35Sstevel */ 75*03831d35Sstevel #define SGENV_NUM_BOARD_READINGS(ksp) ((ksp)->ks_data_size / \ 76*03831d35Sstevel (sizeof (sg_board_info_t))) 77*03831d35Sstevel 78*03831d35Sstevel typedef union sg_led { 79*03831d35Sstevel struct { 80*03831d35Sstevel int _pad :29, /* MSB */ 81*03831d35Sstevel power :1, 82*03831d35Sstevel fault :1, 83*03831d35Sstevel hotplug :1; /* LSB */ 84*03831d35Sstevel } status; 85*03831d35Sstevel 86*03831d35Sstevel int led_status; 87*03831d35Sstevel 88*03831d35Sstevel } sg_led_t; 89*03831d35Sstevel 90*03831d35Sstevel typedef struct sg_board_info { 91*03831d35Sstevel int node_id; 92*03831d35Sstevel int board_num; 93*03831d35Sstevel 94*03831d35Sstevel int condition; /* see <sbd_cond_t> in <sbdp_ioctl.h> */ 95*03831d35Sstevel int assigned; 96*03831d35Sstevel int claimed; 97*03831d35Sstevel int present; /* 1 if board is present in Domain */ 98*03831d35Sstevel 99*03831d35Sstevel sg_led_t led; 100*03831d35Sstevel 101*03831d35Sstevel } sg_board_info_t; 102*03831d35Sstevel 103*03831d35Sstevel 104*03831d35Sstevel /* 105*03831d35Sstevel * Keyswitch Information 106*03831d35Sstevel * ===================== 107*03831d35Sstevel */ 108*03831d35Sstevel 109*03831d35Sstevel /* name of kstat returning keyswitch info */ 110*03831d35Sstevel #define SG_KEYSWITCH_KSTAT_NAME "sg_keyswitch" 111*03831d35Sstevel 112*03831d35Sstevel /* 113*03831d35Sstevel * Kstat structure used to pass Keyswitch data to userland. 114*03831d35Sstevel * 115*03831d35Sstevel * The position is stored in the 32-bit integer value of the 116*03831d35Sstevel * kstat_named_t union <keyswitch_position>. 117*03831d35Sstevel * 118*03831d35Sstevel * (i.e. to get the position - read keyswitch_position.value.ui32) 119*03831d35Sstevel */ 120*03831d35Sstevel typedef struct { 121*03831d35Sstevel kstat_named_t keyswitch_position; /* position */ 122*03831d35Sstevel 123*03831d35Sstevel } sg_keyswitch_kstat_t; 124*03831d35Sstevel 125*03831d35Sstevel 126*03831d35Sstevel /* 127*03831d35Sstevel * Environmental Information 128*03831d35Sstevel * ========================= 129*03831d35Sstevel * 130*03831d35Sstevel * the environmental kstat exports an array of env_sensor_t structs 131*03831d35Sstevel */ 132*03831d35Sstevel 133*03831d35Sstevel #define SG_ENV_INFO_KSTAT_NAME "sg_env_info" 134*03831d35Sstevel 135*03831d35Sstevel 136*03831d35Sstevel /* 137*03831d35Sstevel * sd_infostamp access macros and return values 138*03831d35Sstevel * 139*03831d35Sstevel * N.b. None of the values need shifting. This means the 140*03831d35Sstevel * UTC time in nanoseconds since The Epoch has, at best, 141*03831d35Sstevel * a resolution of c.256 nanoseconds (since the lo-order 142*03831d35Sstevel * c.8-bits are overlaid with other information). 143*03831d35Sstevel */ 144*03831d35Sstevel 145*03831d35Sstevel #define SG_INFO_TIMESTATUS(info) ((int)((info) & _SG_INFO_TIMSTSMSK)) 146*03831d35Sstevel #define SG_INFO_VALUESTATUS(info) ((int)((info) & _SG_INFO_VALSTSMSK)) 147*03831d35Sstevel #define SG_INFO_NANOSECONDS(info) ((hrtime_t)((info) & _SG_INFO_TIMVALMSK)) 148*03831d35Sstevel 149*03831d35Sstevel #define _SG_INFO_TIMSTSMSK ((sensor_status_t)0x0F) 150*03831d35Sstevel #define SG_INFO_TIME_OK 0x00 /* always 0 */ 151*03831d35Sstevel #define SG_INFO_TIME_NOT_KNOWN 0x01 152*03831d35Sstevel #define SG_INFO_TIME_NOT_AVAILABLE 0x02 153*03831d35Sstevel 154*03831d35Sstevel #define _SG_INFO_VALSTSMSK ((sensor_status_t)0xF0) 155*03831d35Sstevel #define SG_INFO_VALUE_OK 0x00 /* always 0 */ 156*03831d35Sstevel #define SG_INFO_VALUE_NOT_POSSIBLE 0x10 157*03831d35Sstevel #define SG_INFO_VALUE_NOT_AVAILABLE 0x20 158*03831d35Sstevel 159*03831d35Sstevel #define _SG_INFO_TIMVALMSK \ 160*03831d35Sstevel (((hrtime_t)~0) & ~(_SG_INFO_TIMSTSMSK | _SG_INFO_VALSTSMSK)) 161*03831d35Sstevel 162*03831d35Sstevel 163*03831d35Sstevel /* Calculate the number of sensor readings that were returned by this kstat */ 164*03831d35Sstevel #define SGENV_NUM_ENV_READINGS(ksp) ((ksp)->ks_data_size / \ 165*03831d35Sstevel (sizeof (env_sensor_t))) 166*03831d35Sstevel 167*03831d35Sstevel /* used to calculate the status of a sensor reading from <sd_status> */ 168*03831d35Sstevel #define SG_STATUS_SHIFT 16 169*03831d35Sstevel #define SG_STATUS_MASK 0xFFFF 170*03831d35Sstevel #define SG_PREV_STATUS_MASK 0xFFFF0000 171*03831d35Sstevel 172*03831d35Sstevel #define SG_GET_SENSOR_STATUS(status) ((status) & SG_STATUS_MASK) 173*03831d35Sstevel #define SG_GET_PREV_SENSOR_STATUS(status) ((status) >> SG_STATUS_SHIFT) 174*03831d35Sstevel 175*03831d35Sstevel #define SG_SET_SENSOR_STATUS(status, value) \ 176*03831d35Sstevel status &= ~SG_STATUS_MASK; \ 177*03831d35Sstevel status |= ((value) & SG_STATUS_MASK) 178*03831d35Sstevel 179*03831d35Sstevel #define SG_SET_PREV_SENSOR_STATUS(status, value) \ 180*03831d35Sstevel status &= ~SG_PREV_STATUS_MASK; \ 181*03831d35Sstevel status |= (((value) & SG_STATUS_MASK) << SG_STATUS_SHIFT) 182*03831d35Sstevel 183*03831d35Sstevel 184*03831d35Sstevel typedef int32_t sensor_data_t; 185*03831d35Sstevel typedef hrtime_t sensor_status_t; 186*03831d35Sstevel 187*03831d35Sstevel /* 188*03831d35Sstevel * The possible states a sensor reading can be in. 189*03831d35Sstevel */ 190*03831d35Sstevel typedef enum env_sensor_status { 191*03831d35Sstevel SG_SENSOR_STATUS_OK = 0x01, 192*03831d35Sstevel SG_SENSOR_STATUS_LO_WARN = 0x02, 193*03831d35Sstevel SG_SENSOR_STATUS_HI_WARN = 0x04, 194*03831d35Sstevel SG_SENSOR_STATUS_LO_DANGER = 0x08, 195*03831d35Sstevel SG_SENSOR_STATUS_HI_DANGER = 0x10, 196*03831d35Sstevel SG_SENSOR_STATUS_FAN_OFF = 0x100, 197*03831d35Sstevel SG_SENSOR_STATUS_FAN_LOW = 0x200, 198*03831d35Sstevel SG_SENSOR_STATUS_FAN_HIGH = 0x400, 199*03831d35Sstevel SG_SENSOR_STATUS_FAN_FAIL = 0x800, 200*03831d35Sstevel SG_SENSOR_STATUS_UNKNOWN = 0x1000 201*03831d35Sstevel 202*03831d35Sstevel } env_sensor_status_t; 203*03831d35Sstevel 204*03831d35Sstevel 205*03831d35Sstevel /* 206*03831d35Sstevel * The raw env. info. kstat is made up of an array of these structures. 207*03831d35Sstevel */ 208*03831d35Sstevel typedef struct env_sensor { 209*03831d35Sstevel sensor_id_t sd_id; /* defined in sensor_tag.h */ 210*03831d35Sstevel sensor_data_t sd_value; 211*03831d35Sstevel sensor_data_t sd_lo; 212*03831d35Sstevel sensor_data_t sd_hi; 213*03831d35Sstevel sensor_data_t sd_lo_warn; 214*03831d35Sstevel sensor_data_t sd_hi_warn; 215*03831d35Sstevel sensor_status_t sd_infostamp; 216*03831d35Sstevel env_sensor_status_t sd_status; 217*03831d35Sstevel 218*03831d35Sstevel } env_sensor_t; 219*03831d35Sstevel 220*03831d35Sstevel 221*03831d35Sstevel /* 222*03831d35Sstevel * Events Information 223*03831d35Sstevel * ================== 224*03831d35Sstevel */ 225*03831d35Sstevel #define SGENV_FAN_SPEED_UNKNOWN (-1) 226*03831d35Sstevel #define SGENV_FAN_SPEED_OFF 0 227*03831d35Sstevel #define SGENV_FAN_SPEED_LOW 1 228*03831d35Sstevel #define SGENV_FAN_SPEED_HIGH 2 229*03831d35Sstevel 230*03831d35Sstevel #define SGENV_FAN_SPEED_UNKNOWN_STR "Unknown" 231*03831d35Sstevel #define SGENV_FAN_SPEED_OFF_STR "Off" 232*03831d35Sstevel #define SGENV_FAN_SPEED_LOW_STR "Low" 233*03831d35Sstevel #define SGENV_FAN_SPEED_HIGH_STR "High" 234*03831d35Sstevel 235*03831d35Sstevel #define SGENV_EVENT_MSG_OK "returned to the normal operating range" 236*03831d35Sstevel #define SGENV_EVENT_MSG_LO_WARN "dropped below low warning threshold" 237*03831d35Sstevel #define SGENV_EVENT_MSG_HI_WARN "exceeded high warning threshold" 238*03831d35Sstevel #define SGENV_EVENT_MSG_LO_DANGER "dropped below low warning limit" 239*03831d35Sstevel #define SGENV_EVENT_MSG_HI_DANGER "exceeded high warning limit" 240*03831d35Sstevel #define SGENV_EVENT_MSG_UNKNOWN "changed to an unknown status" 241*03831d35Sstevel 242*03831d35Sstevel 243*03831d35Sstevel #ifdef __cplusplus 244*03831d35Sstevel } 245*03831d35Sstevel #endif 246*03831d35Sstevel 247*03831d35Sstevel #endif /* _SYS_SGENV_H */ 248