17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _ENVD_H 287c478bd9Sstevel@tonic-gate #define _ENVD_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #include <libintl.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #define SENSORPOLL_INTERVAL 4 387c478bd9Sstevel@tonic-gate #define INTERRUPTPOLL_INTERVAL 2 397c478bd9Sstevel@tonic-gate #define WARNING_INTERVAL 30 407c478bd9Sstevel@tonic-gate #define SHUTDOWN_INTERVAL 60 417c478bd9Sstevel@tonic-gate #define ENV_CONF_FILE "envmodel.conf" 427c478bd9Sstevel@tonic-gate #define TUNABLE_CONF_FILE "piclenvd.conf" 437c478bd9Sstevel@tonic-gate #define PM_DEVICE "/dev/pm" 447c478bd9Sstevel@tonic-gate #define SHUTDOWN_CMD "/usr/sbin/shutdown -y -g 60 -i 5" 457c478bd9Sstevel@tonic-gate #define PICL_PLUGINS_NODE "plugins" 467c478bd9Sstevel@tonic-gate #define PICL_ENVIRONMENTAL_NODE "environmental" 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * ADC Sample of ADM in Khz, currently 11.2 KHz 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate #define ADCSAMPLE 11250 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Taco Platform Details 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate #define MAX_SENSORS 3 577c478bd9Sstevel@tonic-gate #define MAX_FANS 2 587c478bd9Sstevel@tonic-gate #define MAX_HWMS 1 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * ADM1031 Hardware Monitor IDs 627c478bd9Sstevel@tonic-gate * Used as index into arrays 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate #define CPU_HWM_ID 0 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #define CPU_HWM_DEVFS \ 677c478bd9Sstevel@tonic-gate "/devices/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:control" 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate #define HWM_FAN1 0 707c478bd9Sstevel@tonic-gate #define HWM_FAN2 1 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Taco sensor IDs as used in FRUID segment 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate #define SYS_IN_SENSOR_ID 0 767c478bd9Sstevel@tonic-gate #define CPU_SENSOR_ID 1 777c478bd9Sstevel@tonic-gate #define INT_AMB_SENSOR_ID 2 787c478bd9Sstevel@tonic-gate #define MAX_SENSOR_ID 2 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * Taco fan IDs used in FRUID segment 827c478bd9Sstevel@tonic-gate */ 837c478bd9Sstevel@tonic-gate #define SYSTEM_FAN_ID 0 847c478bd9Sstevel@tonic-gate #define CPU_FAN_ID 1 857c478bd9Sstevel@tonic-gate #define MAX_FAN_ID 1 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * devfs-path for various fans and their min/max speeds 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate #define ENV_CPU_FAN_DEVFS \ 917c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_2" 927c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_FAN_DEVFS \ 937c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_1" 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #define FAN_RANGE_DEFAULT 4 967c478bd9Sstevel@tonic-gate #define CPU_FAN_SPEED_MIN 14 977c478bd9Sstevel@tonic-gate #define CPU_FAN_SPEED_MAX 100 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate #define SYSTEM_OUT_FAN_SPEED_MIN 14 1007c478bd9Sstevel@tonic-gate #define SYSTEM_OUT_FAN_SPEED_MAX 100 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #define SYSTEM_INTAKE_FAN_SPEED_MIN 14 1037c478bd9Sstevel@tonic-gate #define SYSTEM_INTAKE_FAN_SPEED_MAX 100 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * devfs-path for various temperature sensors and CPU platform path 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate #define SENSOR_CPU_DIE_DEVFS \ 1117c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_2" 1127c478bd9Sstevel@tonic-gate #define SENSOR_SYS_IN_DEVFS \ 1137c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_1" 1147c478bd9Sstevel@tonic-gate #define SENSOR_INT_AMB_DEVFS \ 1157c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:local" 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * Temperature type 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate typedef int16_t tempr_t; 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * Fan names 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_INTAKE_FAN "intake-fan" 1277c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_OUT_FAN "outtake-fan" 1287c478bd9Sstevel@tonic-gate #define ENV_CPU_FAN "cpu-fan" 1297c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_IN_OUT_FANS "intake-outtake-fans" 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * Sensor names 1337c478bd9Sstevel@tonic-gate */ 1347c478bd9Sstevel@tonic-gate #define SENSOR_CPU_DIE "cpu" 1357c478bd9Sstevel@tonic-gate #define SENSOR_SYS_IN "sys-in" 1367c478bd9Sstevel@tonic-gate #define SENSOR_INT_AMB "int-amb" 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* Bit Map of ADM 1031 Status 1/2 Registers */ 139*78ae253aSToomas Soome typedef enum adm1031 { 1407c478bd9Sstevel@tonic-gate FANFAULT = 0x2, 1417c478bd9Sstevel@tonic-gate REMOTEHIGH = 0x4, 1427c478bd9Sstevel@tonic-gate REMOTELOW = 0x8, 1437c478bd9Sstevel@tonic-gate REMOTETHERN = 0x10, 1447c478bd9Sstevel@tonic-gate LHIGH = 0x40, 1457c478bd9Sstevel@tonic-gate LLOW = 0x80 1467c478bd9Sstevel@tonic-gate } adm1031_t; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* ADM Stat 1/2 Mask */ 149*78ae253aSToomas Soome typedef enum adm1031Mask { 1507c478bd9Sstevel@tonic-gate STAT1MASK = 0xdc, 1517c478bd9Sstevel@tonic-gate STAT2MASK = 0x1c 1527c478bd9Sstevel@tonic-gate } adm1031Mask_t; 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* 1557c478bd9Sstevel@tonic-gate * ES segment related structures 1567c478bd9Sstevel@tonic-gate */ 1577c478bd9Sstevel@tonic-gate typedef struct id_off { 1587c478bd9Sstevel@tonic-gate uint_t id; 1597c478bd9Sstevel@tonic-gate ushort_t offset; 1607c478bd9Sstevel@tonic-gate } id_off_t; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate typedef struct fan_ctl_pair { 1637c478bd9Sstevel@tonic-gate uchar_t tMin; 1647c478bd9Sstevel@tonic-gate uchar_t tRange; 1657c478bd9Sstevel@tonic-gate } fan_ctl_pair_t; 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate typedef struct Correction_Pair { 1687c478bd9Sstevel@tonic-gate uchar_t measured; 1697c478bd9Sstevel@tonic-gate uchar_t corrected; 1707c478bd9Sstevel@tonic-gate } Correction_Pair_t; 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate #define ES_SENSOR_POLICY_LEN 8 1737c478bd9Sstevel@tonic-gate #define ES_CORRECTION_PAIRS 12 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate typedef struct sensor_ctrl_blk { 1767c478bd9Sstevel@tonic-gate uchar_t high_power_off; 1777c478bd9Sstevel@tonic-gate uchar_t high_shutdown; 1787c478bd9Sstevel@tonic-gate uchar_t high_warning; 1797c478bd9Sstevel@tonic-gate uchar_t low_warning; 1807c478bd9Sstevel@tonic-gate uchar_t low_shutdown; 1817c478bd9Sstevel@tonic-gate uchar_t low_power_off; 1827c478bd9Sstevel@tonic-gate uchar_t sensorPolicy[ES_SENSOR_POLICY_LEN]; 1837c478bd9Sstevel@tonic-gate ushort_t correctionEntries; 1847c478bd9Sstevel@tonic-gate Correction_Pair_t correctionPair[ES_CORRECTION_PAIRS]; 1857c478bd9Sstevel@tonic-gate } sensor_ctrl_blk_t; 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate #define ES_FAN_CTL_PAIRS 4 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate typedef struct fan_ctrl_blk { 1917c478bd9Sstevel@tonic-gate uchar_t tSpinUp; 1927c478bd9Sstevel@tonic-gate uchar_t minFanSpeed; 1937c478bd9Sstevel@tonic-gate ushort_t setPoint; 1947c478bd9Sstevel@tonic-gate ushort_t loopGain; 1957c478bd9Sstevel@tonic-gate ushort_t loopBias; 1967c478bd9Sstevel@tonic-gate ushort_t hysteresis; 1977c478bd9Sstevel@tonic-gate ushort_t fanViabTestInt; 1987c478bd9Sstevel@tonic-gate ushort_t fanViabTestThresh; 1997c478bd9Sstevel@tonic-gate ushort_t grossFanThresh; 2007c478bd9Sstevel@tonic-gate uchar_t no_ctl_pairs; 2017c478bd9Sstevel@tonic-gate fan_ctl_pair_t fan_ctl_pairs[ES_FAN_CTL_PAIRS]; 2027c478bd9Sstevel@tonic-gate } fan_ctrl_blk_t; 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate #define TEMP_IN_WARNING_RANGE(val, sensorp) \ 2057c478bd9Sstevel@tonic-gate ((val) > (sensorp)->es_ptr->high_warning || \ 2067c478bd9Sstevel@tonic-gate (val) < (char)((sensorp)->es_ptr->low_warning)) 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate #define TEMP_IN_SHUTDOWN_RANGE(val, sensorp) \ 2097c478bd9Sstevel@tonic-gate ((val) > (sensorp)->es_ptr->high_shutdown || \ 2107c478bd9Sstevel@tonic-gate (val) < (char)((sensorp)->es_ptr->low_shutdown)) 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /* 2137c478bd9Sstevel@tonic-gate * Macros to fetch 16 and 32 bit data from unaligned address 2147c478bd9Sstevel@tonic-gate */ 2157c478bd9Sstevel@tonic-gate #define GET_UNALIGN16(addr) \ 2167c478bd9Sstevel@tonic-gate (((*(uint8_t *)addr) << 8) | *((uint8_t *)addr + 1)) 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate #define GET_UNALIGN32(addr) \ 2197c478bd9Sstevel@tonic-gate (((*(uint8_t *)addr) << 24) | (*((uint8_t *)addr + 1) << 16) | \ 2207c478bd9Sstevel@tonic-gate ((*((uint8_t *)addr + 2)) << 8) | (*((uint8_t *)addr + 3))) 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate /* 2237c478bd9Sstevel@tonic-gate * SEEPROM section header layout and location 2247c478bd9Sstevel@tonic-gate */ 2257c478bd9Sstevel@tonic-gate typedef struct { 2267c478bd9Sstevel@tonic-gate uint8_t header_tag; /* section header tag */ 2277c478bd9Sstevel@tonic-gate uint8_t header_version[2]; /* header version (msb) */ 2287c478bd9Sstevel@tonic-gate uint8_t header_length; /* header length */ 2297c478bd9Sstevel@tonic-gate uint8_t header_crc8; /* crc8 */ 2307c478bd9Sstevel@tonic-gate uint8_t segment_count; /* total number of segments */ 2317c478bd9Sstevel@tonic-gate } section_layout_t; 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate #define SECTION_HDR_OFFSET 0x1800 2347c478bd9Sstevel@tonic-gate #define SECTION_HDR_TAG 0x08 2357c478bd9Sstevel@tonic-gate #define SECTION_HDR_VER 0x0001 2367c478bd9Sstevel@tonic-gate #define SECTION_HDR_LENGTH 0x06 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* 2397c478bd9Sstevel@tonic-gate * SEEPROM segment header layout 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate typedef struct { 2427c478bd9Sstevel@tonic-gate uint16_t name; /* segment name */ 2437c478bd9Sstevel@tonic-gate uint16_t descriptor[2]; /* descriptor (msb) */ 2447c478bd9Sstevel@tonic-gate uint16_t offset; /* segment data offset */ 2457c478bd9Sstevel@tonic-gate uint16_t length; /* segment length */ 2467c478bd9Sstevel@tonic-gate } segment_layout_t; 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate #define ENVSEG_NAME 0x4553 /* environmental segment name */ 2497c478bd9Sstevel@tonic-gate #define ENVSEG_VERSION 2 /* environmental segment version */ 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate #define SENSOR_WARN 1 2527c478bd9Sstevel@tonic-gate #define SENSOR_OK 0 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate /* 2557c478bd9Sstevel@tonic-gate * SEEPROM environmental segment header layout 2567c478bd9Sstevel@tonic-gate */ 2577c478bd9Sstevel@tonic-gate typedef struct { 2587c478bd9Sstevel@tonic-gate uint16_t sensor_id[2]; /* unique sensor ID (on this FRU) */ 2597c478bd9Sstevel@tonic-gate uint16_t offset; /* sensor data record offset */ 2607c478bd9Sstevel@tonic-gate } envseg_sensor_t; 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate typedef struct { 2637c478bd9Sstevel@tonic-gate uint8_t version; /* envseg version */ 2647c478bd9Sstevel@tonic-gate uint8_t sensor_count; /* total number of sensor records */ 2657c478bd9Sstevel@tonic-gate envseg_sensor_t sensors[1]; /* sensor table (variable length) */ 2667c478bd9Sstevel@tonic-gate } envseg_layout_t; 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate /* 2697c478bd9Sstevel@tonic-gate * FRU envseg list 2707c478bd9Sstevel@tonic-gate */ 2717c478bd9Sstevel@tonic-gate typedef struct fruenvseg { 2727c478bd9Sstevel@tonic-gate struct fruenvseg *next; /* next entry */ 2737c478bd9Sstevel@tonic-gate char *fru; /* FRU SEEPROM path */ 2747c478bd9Sstevel@tonic-gate void *envsegbufp; /* envseg data buffer */ 2757c478bd9Sstevel@tonic-gate int envseglen; /* envseg length */ 2767c478bd9Sstevel@tonic-gate } fruenvseg_t; 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate #define I2C_DEVFS "/devices/pci@1e,600000/isa@7/i2c@0,320" 2797c478bd9Sstevel@tonic-gate #define MBFRU_DEV "/motherboard-fru-prom@0,a8:motherboard-fru-prom" 2807c478bd9Sstevel@tonic-gate #define FRU_SEEPROM_NAME "motherboard-fru-prom" 2817c478bd9Sstevel@tonic-gate /* 2827c478bd9Sstevel@tonic-gate * Table data structures 2837c478bd9Sstevel@tonic-gate */ 2847c478bd9Sstevel@tonic-gate typedef struct { 2857c478bd9Sstevel@tonic-gate int32_t x; 2867c478bd9Sstevel@tonic-gate int32_t y; 2877c478bd9Sstevel@tonic-gate } point_t; 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate typedef struct { 2907c478bd9Sstevel@tonic-gate int nentries; 2917c478bd9Sstevel@tonic-gate point_t *xymap; 2927c478bd9Sstevel@tonic-gate } table_t; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate /* 2957c478bd9Sstevel@tonic-gate * Temperature sensor related data structure 2967c478bd9Sstevel@tonic-gate */ 2977c478bd9Sstevel@tonic-gate typedef struct env_sensor { 2987c478bd9Sstevel@tonic-gate char *name; /* sensor name */ 2997c478bd9Sstevel@tonic-gate char *devfs_path; /* sensor device devfs path */ 3007c478bd9Sstevel@tonic-gate sensor_ctrl_blk_t *es_ptr; 3017c478bd9Sstevel@tonic-gate uchar_t id; 3027c478bd9Sstevel@tonic-gate int hwm_id; 3037c478bd9Sstevel@tonic-gate void *fanp; 3047c478bd9Sstevel@tonic-gate int fd; /* device file descriptor */ 3057c478bd9Sstevel@tonic-gate int error; /* error flag */ 3067c478bd9Sstevel@tonic-gate boolean_t present; /* sensor present */ 3077c478bd9Sstevel@tonic-gate tempr_t cur_temp; /* current temperature */ 3087c478bd9Sstevel@tonic-gate time_t warning_tstamp; /* last warning time (secs) */ 3097c478bd9Sstevel@tonic-gate time_t shutdown_tstamp; /* shutdown temp time (secs) */ 3107c478bd9Sstevel@tonic-gate boolean_t shutdown_initiated; /* shutdown initated */ 3117c478bd9Sstevel@tonic-gate table_t *crtbl; /* Correction table */ 3127c478bd9Sstevel@tonic-gate tempr_t tmin; 3137c478bd9Sstevel@tonic-gate } env_sensor_t; 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate extern env_sensor_t *sensor_lookup(char *sensor_name); 3167c478bd9Sstevel@tonic-gate extern int get_temperature(env_sensor_t *, tempr_t *); 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate /* 3197c478bd9Sstevel@tonic-gate * Fan information data structure 3207c478bd9Sstevel@tonic-gate */ 3217c478bd9Sstevel@tonic-gate typedef int fanspeed_t; 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate typedef struct env_fan { 3247c478bd9Sstevel@tonic-gate char *name; /* fan name */ 3257c478bd9Sstevel@tonic-gate char *devfs_path; /* fan device devfs path */ 3267c478bd9Sstevel@tonic-gate fan_ctrl_blk_t *es_ptr; 3277c478bd9Sstevel@tonic-gate uchar_t id; 3287c478bd9Sstevel@tonic-gate fanspeed_t speed_min; /* minimum speed */ 3297c478bd9Sstevel@tonic-gate fanspeed_t speed_max; /* maximum speed */ 3307c478bd9Sstevel@tonic-gate int forced_speed; /* forced (fixed) speed */ 3317c478bd9Sstevel@tonic-gate int fd; /* device file descriptor */ 3327c478bd9Sstevel@tonic-gate boolean_t present; /* fan present */ 3337c478bd9Sstevel@tonic-gate int speedrange; /* speed range N */ 3347c478bd9Sstevel@tonic-gate int fanstat; /* Fan status */ 3357c478bd9Sstevel@tonic-gate uint8_t cspeed; /* Current speed (tach) */ 3367c478bd9Sstevel@tonic-gate uint8_t lspeed; /* Last speed (tach) */ 3377c478bd9Sstevel@tonic-gate int conccnt; /* Concurrent tach count */ 3387c478bd9Sstevel@tonic-gate } env_fan_t; 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate /* 3417c478bd9Sstevel@tonic-gate * Tuneables 3427c478bd9Sstevel@tonic-gate */ 3437c478bd9Sstevel@tonic-gate typedef struct env_tuneable { 3447c478bd9Sstevel@tonic-gate char *name; 3457c478bd9Sstevel@tonic-gate char type; 3467c478bd9Sstevel@tonic-gate void *value; 3477c478bd9Sstevel@tonic-gate int (*rfunc)(ptree_rarg_t *, void *); 3487c478bd9Sstevel@tonic-gate int (*wfunc)(ptree_warg_t *, const void *); 3497c478bd9Sstevel@tonic-gate int nbytes; 3507c478bd9Sstevel@tonic-gate picl_prophdl_t proph; 3517c478bd9Sstevel@tonic-gate } env_tuneable_t; 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate extern env_fan_t *fan_lookup(char *fan_name); 3547c478bd9Sstevel@tonic-gate extern int get_fan_speed(env_fan_t *, fanspeed_t *); 3557c478bd9Sstevel@tonic-gate extern int set_fan_speed(env_fan_t *, fanspeed_t); 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate extern int env_debug; 3587c478bd9Sstevel@tonic-gate extern void envd_log(int pri, const char *fmt, ...); 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate /* 3617c478bd9Sstevel@tonic-gate * Various messages 3627c478bd9Sstevel@tonic-gate */ 3637c478bd9Sstevel@tonic-gate #define ENVD_PLUGIN_INIT_FAILED \ 3647c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: initialization failed!\n") 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate #define ENVD_PICL_SETUP_FAILED \ 3677c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: PICL setup failed!\n") 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate #define PM_THREAD_CREATE_FAILED \ 3707c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: pmthr thread creation failed!\n") 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate #define PM_THREAD_EXITING \ 3737c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: pmthr exiting! errno:%d %s\n") 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate #define ENVTHR_THREAD_CREATE_FAILED \ 3767c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: envthr thread creation failed!\n") 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate #define ENV_SHUTDOWN_MSG \ 3797c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \ 3807c478bd9Sstevel@tonic-gate "limits (%d...%d). Shutting down the system.\n") 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate #define ENV_WARNING_MSG \ 3837c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \ 3847c478bd9Sstevel@tonic-gate "operating limits (%d...%d).\n") 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate #define ENV_FAN_OPEN_FAIL \ 3877c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open '%s' fan path:%s errno:%d %s\n") 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate #define ENV_SENSOR_OPEN_FAIL \ 3907c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open '%s' sensor path:%s errno:%d %s\n") 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate #define ENV_SENSOR_ACCESS_FAIL \ 3937c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't access '%s' sensor errno:%d %s\n") 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate #define ENV_SENSOR_ACCESS_OK \ 3967c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: '%s' sensor is accessible now.\n") 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate #define ENV_FRU_OPEN_FAIL \ 3997c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open FRU SEEPROM path:%s errno:%d %s\n") 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate #define ENV_FRU_BAD_ENVSEG \ 4027c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: version mismatch or environmental segment " \ 4037c478bd9Sstevel@tonic-gate "header too short in FRU SEEPROM %s\n") 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate #define ENV_FRU_BAD_SENSOR_ENTRY \ 4067c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: discarding bad sensor entry (sensor_id " \ 4077c478bd9Sstevel@tonic-gate "%x sensor '%s') in FRU SEEPROM %s\n") 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate #define ENV_FRU_SENSOR_MAP_NOMEM \ 4107c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: out of memory, discarding sensor map for " \ 4117c478bd9Sstevel@tonic-gate "sensor_id %x (sensor '%s') in FRU SEEPROM %s\n") 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate #define ENV_ADM_OPEN_FAIL \ 4147c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open hwm path:%s errno:%d %s\n") 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate #define ENV_ADM_MANUAL_MODE \ 4177c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: Cannot change the ADM Chip to Manual mode") 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate #define ENV_ADM_AUTO_MODE \ 4207c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: Cannot change the ADM Chip to Auto mode") 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate #define ENV_FAN_FAULT \ 4237c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: ADM %s, Fan %s Fault") 4247c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4257c478bd9Sstevel@tonic-gate } 4267c478bd9Sstevel@tonic-gate #endif 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate #endif /* _ENVD_H */ 429