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 2004 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 DISK_SCAN_INTERVAL 10 387c478bd9Sstevel@tonic-gate #define DISK_HIGH_WARN_TEMPERATURE 55 397c478bd9Sstevel@tonic-gate #define DISK_LOW_WARN_TEMPERATURE 5 407c478bd9Sstevel@tonic-gate #define DISK_HIGH_SHUTDOWN_TEMPERATURE 60 417c478bd9Sstevel@tonic-gate #define DISK_LOW_SHUTDOWN_TEMPERATURE 0 427c478bd9Sstevel@tonic-gate #define DISK_INVALID_TEMP 0xFFFF 437c478bd9Sstevel@tonic-gate #define LSI1030_VENDOR_ID 0x1000 447c478bd9Sstevel@tonic-gate #define LSI1030_DEVICE_ID 0x30 457c478bd9Sstevel@tonic-gate #define SENSORPOLL_INTERVAL 4 467c478bd9Sstevel@tonic-gate #define INTERRUPTPOLL_INTERVAL 2 477c478bd9Sstevel@tonic-gate #define WARNING_INTERVAL 30 487c478bd9Sstevel@tonic-gate #define DISK_WARNING_INTERVAL 30 497c478bd9Sstevel@tonic-gate #define DISK_WARNING_DURATION 20 507c478bd9Sstevel@tonic-gate #define SHUTDOWN_INTERVAL 60 517c478bd9Sstevel@tonic-gate #define DISK_SHUTDOWN_INTERVAL 30 527c478bd9Sstevel@tonic-gate #define ENV_CONF_FILE "envmodel.conf" 537c478bd9Sstevel@tonic-gate #define TUNABLE_CONF_FILE "piclenvd.conf" 547c478bd9Sstevel@tonic-gate #define PM_DEVICE "/dev/pm" 557c478bd9Sstevel@tonic-gate #define SHUTDOWN_CMD "/usr/sbin/shutdown -y -g 60 -i 5" 567c478bd9Sstevel@tonic-gate #define PICL_PLUGINS_NODE "plugins" 577c478bd9Sstevel@tonic-gate #define PICL_ENVIRONMENTAL_NODE "environmental" 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * ADC Sample of ADM in Khz, currently 11.2 KHz 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate #define ADCSAMPLE 11250 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Enchilada Platform Details 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #define MAX_SENSORS 6 687c478bd9Sstevel@tonic-gate #define MAX_FANS 4 697c478bd9Sstevel@tonic-gate #define MAX_HWMS 2 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * ADM1031 Hardware Monitor IDs 737c478bd9Sstevel@tonic-gate * Used as index into arrays 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate #define CPU_HWM_ID 0 767c478bd9Sstevel@tonic-gate #define SYS_HWM_ID 1 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate #define CPU_HWM_DEVFS \ 797c478bd9Sstevel@tonic-gate "/devices/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,58:control" 807c478bd9Sstevel@tonic-gate #define SYS_HWM_DEVFS \ 817c478bd9Sstevel@tonic-gate "/devices/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:control" 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate #define DISK0_PHYSPATH \ 847c478bd9Sstevel@tonic-gate "/pci@1d,700000/scsi@4/sd@0,0" 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #define DISK1_PHYSPATH \ 877c478bd9Sstevel@tonic-gate "/pci@1d,700000/scsi@4/sd@1,0" 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #define ENV_DISK0_DEVFS \ 907c478bd9Sstevel@tonic-gate "/devices/pci@1d,700000/scsi@4/sd@0,0:a,raw" 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate #define ENV_DISK1_DEVFS \ 937c478bd9Sstevel@tonic-gate "/devices/pci@1d,700000/scsi@4/sd@1,0:a,raw" 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #define DISK0_NODE_PATH \ 967c478bd9Sstevel@tonic-gate "name:/platform/pci@1d,700000/scsi@4/sd@0,0" 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #define DISK1_NODE_PATH \ 997c478bd9Sstevel@tonic-gate "name:/platform/pci@1d,700000/scsi@4/sd@1,0" 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #define SCSI_CONTROLLER_NODE_PATH \ 1037c478bd9Sstevel@tonic-gate "name:/platform/pci@1d,700000/scsi@4" 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #define HWM_FAN1 0 1067c478bd9Sstevel@tonic-gate #define HWM_FAN2 1 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * Enchilada sensor IDs as used in FRUID segment 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate #define CPU0_SENSOR_ID 0 1127c478bd9Sstevel@tonic-gate #define CPU1_SENSOR_ID 1 1137c478bd9Sstevel@tonic-gate #define INT_AMB0_SENSOR_ID 5 1147c478bd9Sstevel@tonic-gate #define SYS_OUT_SENSOR_ID 3 1157c478bd9Sstevel@tonic-gate #define INT_AMB1_SENSOR_ID 4 1167c478bd9Sstevel@tonic-gate #define SYS_IN_SENSOR_ID 2 1177c478bd9Sstevel@tonic-gate #define MAX_SENSOR_ID 5 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* 1207c478bd9Sstevel@tonic-gate * Enchilada fan IDs used in FRUID segment 1217c478bd9Sstevel@tonic-gate */ 1227c478bd9Sstevel@tonic-gate #define CPU0_FAN_ID 0 1237c478bd9Sstevel@tonic-gate #define CPU1_FAN_ID 1 1247c478bd9Sstevel@tonic-gate #define SYSTEM_OUT_FAN_ID 2 1257c478bd9Sstevel@tonic-gate #define SYSTEM_INTAKE_FAN_ID 3 1267c478bd9Sstevel@tonic-gate #define DIMM_FAN_ID 4 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #define DISK0_ID 0 1297c478bd9Sstevel@tonic-gate #define DISK1_ID 1 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate /* CPU Path Names */ 1337c478bd9Sstevel@tonic-gate #define CPU0_PATH "_class:/jbus/cpu?ID=0" 1347c478bd9Sstevel@tonic-gate #define CPU1_PATH "_class:/jbus/cpu?ID=1" 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* DIMM Fan controller path Name */ 1377c478bd9Sstevel@tonic-gate #define DIMM_FAN_CONTROLLER_PATH \ 1387c478bd9Sstevel@tonic-gate "name:/platform/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,52" 1397c478bd9Sstevel@tonic-gate /* 1407c478bd9Sstevel@tonic-gate * devfs-path for various fans and their min/max speeds 1417c478bd9Sstevel@tonic-gate */ 1427c478bd9Sstevel@tonic-gate #define ENV_CPU0_FAN_DEVFS \ 1437c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,58:fan_1" 1447c478bd9Sstevel@tonic-gate #define ENV_CPU1_FAN_DEVFS \ 1457c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,58:fan_2" 1467c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_INTAKE_FAN_DEVFS \ 1477c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_1" 1487c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_OUT_FAN_DEVFS \ 1497c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_2" 1507c478bd9Sstevel@tonic-gate #define ENV_DIMM_FAN_DEVFS \ 1517c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,52:fan_1" 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #define FAN_RANGE_DEFAULT 4 1547c478bd9Sstevel@tonic-gate #define CPU_FAN_SPEED_MIN 14 1557c478bd9Sstevel@tonic-gate #define CPU_FAN_SPEED_MAX 100 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate #define SYSTEM_OUT_FAN_SPEED_MIN 14 1587c478bd9Sstevel@tonic-gate #define SYSTEM_OUT_FAN_SPEED_MAX 100 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate #define SYSTEM_INTAKE_FAN_SPEED_MIN 14 1617c478bd9Sstevel@tonic-gate #define SYSTEM_INTAKE_FAN_SPEED_MAX 100 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate /* 1657c478bd9Sstevel@tonic-gate * devfs-path for various temperature sensors and CPU platform path 1667c478bd9Sstevel@tonic-gate */ 1677c478bd9Sstevel@tonic-gate #define SENSOR_CPU0_DIE_DEVFS \ 1687c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,58:remote_1" 1697c478bd9Sstevel@tonic-gate #define SENSOR_CPU1_DIE_DEVFS \ 1707c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,58:remote_2" 1717c478bd9Sstevel@tonic-gate #define SENSOR_INT_AMB_0_DEVFS \ 1727c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,58:local" 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #define SENSOR_SYS_IN_DEVFS \ 1757c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_1" 1767c478bd9Sstevel@tonic-gate #define SENSOR_SYS_OUT_DEVFS \ 1777c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_2" 1787c478bd9Sstevel@tonic-gate #define SENSOR_INT_AMB_1_DEVFS \ 1797c478bd9Sstevel@tonic-gate "/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:local" 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* 1827c478bd9Sstevel@tonic-gate * Temperature type 1837c478bd9Sstevel@tonic-gate */ 1847c478bd9Sstevel@tonic-gate typedef int16_t tempr_t; 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate /* 1887c478bd9Sstevel@tonic-gate * Fan names 1897c478bd9Sstevel@tonic-gate */ 1907c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_OUT_FAN "outtake-fan" 1917c478bd9Sstevel@tonic-gate #define ENV_CPU0_FAN "cpu0-fan" 1927c478bd9Sstevel@tonic-gate #define ENV_SYSTEM_INTAKE_FAN "intake-fan" 1937c478bd9Sstevel@tonic-gate #define ENV_CPU1_FAN "cpu1-fan" 1947c478bd9Sstevel@tonic-gate #define ENV_DIMM_FAN "dimm-fan" 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate #define ENV_DISK0 "hard-disk0" 1977c478bd9Sstevel@tonic-gate #define ENV_DISK1 "hard-disk1" 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * Sensor names 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate #define SENSOR_CPU0_DIE "cpu0" 2027c478bd9Sstevel@tonic-gate #define SENSOR_CPU1_DIE "cpu1" 2037c478bd9Sstevel@tonic-gate #define SENSOR_INT_AMB_0 "int-amb0" 2047c478bd9Sstevel@tonic-gate #define SENSOR_SYS_IN "sys-in" 2057c478bd9Sstevel@tonic-gate #define SENSOR_SYS_OUT "sys-out" 2067c478bd9Sstevel@tonic-gate #define SENSOR_INT_AMB_1 "int-amb1" 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* Bit Map of ADM 1031 Status 1/2 Registers */ 209*78ae253aSToomas Soome typedef enum adm1031 { 2107c478bd9Sstevel@tonic-gate FANFAULT = 0x2, 2117c478bd9Sstevel@tonic-gate REMOTEHIGH = 0x4, 2127c478bd9Sstevel@tonic-gate REMOTELOW = 0x8, 2137c478bd9Sstevel@tonic-gate REMOTETHERN = 0x10, 2147c478bd9Sstevel@tonic-gate LHIGH = 0x40, 2157c478bd9Sstevel@tonic-gate LLOW = 0x80 2167c478bd9Sstevel@tonic-gate } adm1031_t; 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate /* ADM Stat 1/2 Mask */ 219*78ae253aSToomas Soome typedef enum adm1031Mask { 2207c478bd9Sstevel@tonic-gate STAT1MASK = 0xdc, 2217c478bd9Sstevel@tonic-gate STAT2MASK = 0x1c 2227c478bd9Sstevel@tonic-gate } adm1031Mask_t; 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* 2257c478bd9Sstevel@tonic-gate * ES segment related structures 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate typedef struct id_off { 2287c478bd9Sstevel@tonic-gate uint_t id; 2297c478bd9Sstevel@tonic-gate ushort_t offset; 2307c478bd9Sstevel@tonic-gate } id_off_t; 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate typedef struct fan_ctl_pair { 2337c478bd9Sstevel@tonic-gate uchar_t tMin; 2347c478bd9Sstevel@tonic-gate uchar_t tRange; 2357c478bd9Sstevel@tonic-gate } fan_ctl_pair_t; 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate typedef struct Correction_Pair { 2387c478bd9Sstevel@tonic-gate uchar_t measured; 2397c478bd9Sstevel@tonic-gate uchar_t corrected; 2407c478bd9Sstevel@tonic-gate } Correction_Pair_t; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate #define ES_SENSOR_POLICY_LEN 8 2437c478bd9Sstevel@tonic-gate #define ES_CORRECTION_PAIRS 12 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate typedef struct sensor_ctrl_blk { 2467c478bd9Sstevel@tonic-gate uchar_t high_power_off; 2477c478bd9Sstevel@tonic-gate uchar_t high_shutdown; 2487c478bd9Sstevel@tonic-gate uchar_t high_warning; 2497c478bd9Sstevel@tonic-gate uchar_t low_warning; 2507c478bd9Sstevel@tonic-gate uchar_t low_shutdown; 2517c478bd9Sstevel@tonic-gate uchar_t low_power_off; 2527c478bd9Sstevel@tonic-gate uchar_t sensorPolicy[ES_SENSOR_POLICY_LEN]; 2537c478bd9Sstevel@tonic-gate ushort_t correctionEntries; 2547c478bd9Sstevel@tonic-gate Correction_Pair_t correctionPair[ES_CORRECTION_PAIRS]; 2557c478bd9Sstevel@tonic-gate } sensor_ctrl_blk_t; 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate #define ES_FAN_CTL_PAIRS 4 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate typedef struct fan_ctrl_blk { 2617c478bd9Sstevel@tonic-gate uchar_t tSpinUp; 2627c478bd9Sstevel@tonic-gate uchar_t minFanSpeed; 2637c478bd9Sstevel@tonic-gate ushort_t setPoint; 2647c478bd9Sstevel@tonic-gate ushort_t loopGain; 2657c478bd9Sstevel@tonic-gate ushort_t loopBias; 2667c478bd9Sstevel@tonic-gate ushort_t hysteresis; 2677c478bd9Sstevel@tonic-gate ushort_t fanViabTestInt; 2687c478bd9Sstevel@tonic-gate ushort_t fanViabTestThresh; 2697c478bd9Sstevel@tonic-gate ushort_t grossFanThresh; 2707c478bd9Sstevel@tonic-gate uchar_t no_ctl_pairs; 2717c478bd9Sstevel@tonic-gate fan_ctl_pair_t fan_ctl_pairs[ES_FAN_CTL_PAIRS]; 2727c478bd9Sstevel@tonic-gate } fan_ctrl_blk_t; 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate #define TEMP_IN_WARNING_RANGE(val, sensorp) \ 2757c478bd9Sstevel@tonic-gate ((val) > (sensorp)->es_ptr->high_warning || \ 2767c478bd9Sstevel@tonic-gate (val) < (char)((sensorp)->es_ptr->low_warning)) 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate #define TEMP_IN_SHUTDOWN_RANGE(val, sensorp) \ 2797c478bd9Sstevel@tonic-gate ((val) > (sensorp)->es_ptr->high_shutdown || \ 2807c478bd9Sstevel@tonic-gate (val) < (char)((sensorp)->es_ptr->low_shutdown)) 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate #define DISK_TEMP_IN_WARNING_RANGE(val, diskp) \ 2837c478bd9Sstevel@tonic-gate ((val) > (diskp)->high_warning || \ 2847c478bd9Sstevel@tonic-gate (val) < (char)((diskp)->low_warning)) 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate #define DISK_TEMP_IN_SHUTDOWN_RANGE(val, diskp) \ 2877c478bd9Sstevel@tonic-gate ((val) > (diskp)->high_shutdown || \ 2887c478bd9Sstevel@tonic-gate (val) < (char)((diskp)->low_shutdown)) 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate /* 2917c478bd9Sstevel@tonic-gate * Macros to fetch 16 and 32 bit data from unaligned address 2927c478bd9Sstevel@tonic-gate */ 2937c478bd9Sstevel@tonic-gate #define GET_UNALIGN16(addr) \ 2947c478bd9Sstevel@tonic-gate (((*(uint8_t *)addr) << 8) | *((uint8_t *)addr + 1)) 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate #define GET_UNALIGN32(addr) \ 2977c478bd9Sstevel@tonic-gate (((*(uint8_t *)addr) << 24) | (*((uint8_t *)addr + 1) << 16) | \ 2987c478bd9Sstevel@tonic-gate ((*((uint8_t *)addr + 2)) << 8) | (*((uint8_t *)addr + 3))) 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * SEEPROM section header layout and location 3037c478bd9Sstevel@tonic-gate */ 3047c478bd9Sstevel@tonic-gate typedef struct { 3057c478bd9Sstevel@tonic-gate uint8_t header_tag; /* section header tag */ 3067c478bd9Sstevel@tonic-gate uint8_t header_version[2]; /* header version (msb) */ 3077c478bd9Sstevel@tonic-gate uint8_t header_length; /* header length */ 3087c478bd9Sstevel@tonic-gate uint8_t header_crc8; /* crc8 */ 3097c478bd9Sstevel@tonic-gate uint8_t segment_count; /* total number of segments */ 3107c478bd9Sstevel@tonic-gate } section_layout_t; 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate #define SECTION_HDR_OFFSET 0x1800 3137c478bd9Sstevel@tonic-gate #define SECTION_HDR_TAG 0x08 3147c478bd9Sstevel@tonic-gate #define SECTION_HDR_VER 0x0001 3157c478bd9Sstevel@tonic-gate #define SECTION_HDR_LENGTH 0x06 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate /* 3187c478bd9Sstevel@tonic-gate * SEEPROM segment header layout 3197c478bd9Sstevel@tonic-gate */ 3207c478bd9Sstevel@tonic-gate typedef struct { 3217c478bd9Sstevel@tonic-gate uint16_t name; /* segment name */ 3227c478bd9Sstevel@tonic-gate uint16_t descriptor[2]; /* descriptor (msb) */ 3237c478bd9Sstevel@tonic-gate uint16_t offset; /* segment data offset */ 3247c478bd9Sstevel@tonic-gate uint16_t length; /* segment length */ 3257c478bd9Sstevel@tonic-gate } segment_layout_t; 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate #define ENVSEG_NAME 0x4553 /* environmental segment name */ 3287c478bd9Sstevel@tonic-gate #define ENVSEG_VERSION 2 /* environmental segment version */ 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate #define SENSOR_WARN 1 3317c478bd9Sstevel@tonic-gate #define SENSOR_OK 0 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate /* 3347c478bd9Sstevel@tonic-gate * SEEPROM environmental segment header layout 3357c478bd9Sstevel@tonic-gate */ 3367c478bd9Sstevel@tonic-gate typedef struct { 3377c478bd9Sstevel@tonic-gate uint16_t sensor_id[2]; /* unique sensor ID (on this FRU) */ 3387c478bd9Sstevel@tonic-gate uint16_t offset; /* sensor data record offset */ 3397c478bd9Sstevel@tonic-gate } envseg_sensor_t; 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate typedef struct { 3427c478bd9Sstevel@tonic-gate uint8_t version; /* envseg version */ 3437c478bd9Sstevel@tonic-gate uint8_t sensor_count; /* total number of sensor records */ 3447c478bd9Sstevel@tonic-gate envseg_sensor_t sensors[1]; /* sensor table (variable length) */ 3457c478bd9Sstevel@tonic-gate } envseg_layout_t; 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate /* 3487c478bd9Sstevel@tonic-gate * FRU envseg list 3497c478bd9Sstevel@tonic-gate */ 3507c478bd9Sstevel@tonic-gate typedef struct fruenvseg { 3517c478bd9Sstevel@tonic-gate struct fruenvseg *next; /* next entry */ 3527c478bd9Sstevel@tonic-gate char *fru; /* FRU SEEPROM path */ 3537c478bd9Sstevel@tonic-gate void *envsegbufp; /* envseg data buffer */ 3547c478bd9Sstevel@tonic-gate int envseglen; /* envseg length */ 3557c478bd9Sstevel@tonic-gate } fruenvseg_t; 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate #define I2C_DEVFS "/devices/pci@1e,600000/isa@7/i2c@0,320" 3587c478bd9Sstevel@tonic-gate #define MBFRU_DEV "/motherboard-fru-prom@0,a2:motherboard-fru-prom" 3597c478bd9Sstevel@tonic-gate #define FRU_SEEPROM_NAME "motherboard-fru-prom" 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate /* 3627c478bd9Sstevel@tonic-gate * Table data structures 3637c478bd9Sstevel@tonic-gate */ 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate typedef struct { 3667c478bd9Sstevel@tonic-gate int32_t x; 3677c478bd9Sstevel@tonic-gate int32_t y; 3687c478bd9Sstevel@tonic-gate } point_t; 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate typedef struct { 3717c478bd9Sstevel@tonic-gate int nentries; 3727c478bd9Sstevel@tonic-gate point_t *xymap; 3737c478bd9Sstevel@tonic-gate } table_t; 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate /* 3767c478bd9Sstevel@tonic-gate * Temperature sensor related data structure 3777c478bd9Sstevel@tonic-gate */ 3787c478bd9Sstevel@tonic-gate typedef struct env_sensor { 3797c478bd9Sstevel@tonic-gate char *name; /* sensor name */ 3807c478bd9Sstevel@tonic-gate char *devfs_path; /* sensor device devfs path */ 3817c478bd9Sstevel@tonic-gate sensor_ctrl_blk_t *es_ptr; 3827c478bd9Sstevel@tonic-gate int id; 3837c478bd9Sstevel@tonic-gate int hwm_id; 3847c478bd9Sstevel@tonic-gate void *fanp; 3857c478bd9Sstevel@tonic-gate int fd; /* device file descriptor */ 3867c478bd9Sstevel@tonic-gate int error; /* error flag */ 387*78ae253aSToomas Soome boolean_t present; /* sensor present */ 3887c478bd9Sstevel@tonic-gate tempr_t cur_temp; /* current temperature */ 3897c478bd9Sstevel@tonic-gate time_t warning_tstamp; /* last warning time (secs) */ 3907c478bd9Sstevel@tonic-gate time_t shutdown_tstamp; /* shutdown temp time (secs) */ 391*78ae253aSToomas Soome boolean_t shutdown_initiated; /* shutdown initated */ 3927c478bd9Sstevel@tonic-gate table_t *crtbl; /* Correction Table */ 3937c478bd9Sstevel@tonic-gate tempr_t tmin; 3947c478bd9Sstevel@tonic-gate } env_sensor_t; 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate extern env_sensor_t *sensor_lookup(char *sensor_name); 3977c478bd9Sstevel@tonic-gate extern int get_temperature(env_sensor_t *, tempr_t *); 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate typedef struct env_disk { 4007c478bd9Sstevel@tonic-gate char *name; /* disk name */ 4017c478bd9Sstevel@tonic-gate char *devfs_path; /* disk device devfs path */ 4027c478bd9Sstevel@tonic-gate char *physpath; /* used to be probe for IDLW TIME */ 4037c478bd9Sstevel@tonic-gate char *nodepath; /* used to detect presence of disk */ 4047c478bd9Sstevel@tonic-gate uchar_t id; 4057c478bd9Sstevel@tonic-gate int fd; /* device file descriptor */ 4067c478bd9Sstevel@tonic-gate boolean_t present; /* disk present */ 4077c478bd9Sstevel@tonic-gate boolean_t tpage_supported; /* Temperature page */ 4087c478bd9Sstevel@tonic-gate int current_temp; 4097c478bd9Sstevel@tonic-gate int ref_temp; 4107c478bd9Sstevel@tonic-gate int reliability_temp; 411*78ae253aSToomas Soome uchar_t high_shutdown; 412*78ae253aSToomas Soome uchar_t high_warning; 413*78ae253aSToomas Soome uchar_t low_warning; 414*78ae253aSToomas Soome uchar_t low_shutdown; 4157c478bd9Sstevel@tonic-gate time_t warning_start; /* warning start time (secs) */ 4167c478bd9Sstevel@tonic-gate time_t warning_tstamp; /* last warning time (secs) */ 4177c478bd9Sstevel@tonic-gate time_t shutdown_tstamp; /* shutdown temp time (secs) */ 418*78ae253aSToomas Soome boolean_t shutdown_initiated; /* shutdown initated */ 4197c478bd9Sstevel@tonic-gate } env_disk_t; 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate extern env_disk_t *disk_lookup(char *disk_name); 4227c478bd9Sstevel@tonic-gate extern int disk_temperature(env_disk_t *, tempr_t *); 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate /* 4257c478bd9Sstevel@tonic-gate * Fan information data structure 4267c478bd9Sstevel@tonic-gate */ 4277c478bd9Sstevel@tonic-gate typedef int fanspeed_t; 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate typedef struct env_fan { 4307c478bd9Sstevel@tonic-gate char *name; /* fan name */ 4317c478bd9Sstevel@tonic-gate char *devfs_path; /* fan device devfs path */ 4327c478bd9Sstevel@tonic-gate fan_ctrl_blk_t *es_ptr; 4337c478bd9Sstevel@tonic-gate uchar_t id; 4347c478bd9Sstevel@tonic-gate fanspeed_t speed_min; /* minimum speed */ 4357c478bd9Sstevel@tonic-gate fanspeed_t speed_max; /* maximum speed */ 4367c478bd9Sstevel@tonic-gate int forced_speed; /* forced (fixed) speed */ 4377c478bd9Sstevel@tonic-gate int fd; /* device file descriptor */ 4387c478bd9Sstevel@tonic-gate boolean_t present; /* fan present */ 4397c478bd9Sstevel@tonic-gate int speedrange; /* speed range N */ 4407c478bd9Sstevel@tonic-gate int fanstat; /* Fan status */ 4417c478bd9Sstevel@tonic-gate uint8_t cspeed; /* Current speed (tach) */ 4427c478bd9Sstevel@tonic-gate uint8_t lspeed; /* Last speed (tach) */ 4437c478bd9Sstevel@tonic-gate int conccnt; /* Concurrent tach count */ 4447c478bd9Sstevel@tonic-gate } env_fan_t; 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate /* 4477c478bd9Sstevel@tonic-gate * Tuneables 4487c478bd9Sstevel@tonic-gate */ 4497c478bd9Sstevel@tonic-gate typedef struct env_tuneable { 4507c478bd9Sstevel@tonic-gate char *name; 4517c478bd9Sstevel@tonic-gate char type; 4527c478bd9Sstevel@tonic-gate void *value; 4537c478bd9Sstevel@tonic-gate int (*rfunc)(ptree_rarg_t *, void *); 4547c478bd9Sstevel@tonic-gate int (*wfunc)(ptree_warg_t *, const void *); 4557c478bd9Sstevel@tonic-gate int nbytes; 4567c478bd9Sstevel@tonic-gate picl_prophdl_t proph; 4577c478bd9Sstevel@tonic-gate } env_tuneable_t; 4587c478bd9Sstevel@tonic-gate 4597c478bd9Sstevel@tonic-gate extern env_fan_t *fan_lookup(char *fan_name); 4607c478bd9Sstevel@tonic-gate extern int get_fan_speed(env_fan_t *, fanspeed_t *); 4617c478bd9Sstevel@tonic-gate extern int set_fan_speed(env_fan_t *, fanspeed_t); 4627c478bd9Sstevel@tonic-gate 4637c478bd9Sstevel@tonic-gate extern int env_debug; 4647c478bd9Sstevel@tonic-gate extern void envd_log(int pri, const char *fmt, ...); 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate /* 4677c478bd9Sstevel@tonic-gate * Various messages 4687c478bd9Sstevel@tonic-gate */ 4697c478bd9Sstevel@tonic-gate #define ENVD_PLUGIN_INIT_FAILED \ 4707c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: initialization failed!\n") 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate #define ENVD_PICL_SETUP_FAILED \ 4737c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: PICL setup failed!\n") 4747c478bd9Sstevel@tonic-gate 4757c478bd9Sstevel@tonic-gate #define PM_THREAD_CREATE_FAILED \ 4767c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: pmthr thread creation failed!\n") 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate #define PM_THREAD_EXITING \ 4797c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: pmthr exiting! errno:%d %s\n") 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate #define DISK_TEMP_THREAD_EXITING \ 4827c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: Disk temp thread exiting." \ 4837c478bd9Sstevel@tonic-gate " Disk temperature will not be monitored. errno:%d %s\n") 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate #define ENVTHR_THREAD_CREATE_FAILED \ 4867c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: envthr thread creation failed!\n") 4877c478bd9Sstevel@tonic-gate 4887c478bd9Sstevel@tonic-gate #define ENV_SHUTDOWN_MSG \ 4897c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \ 4907c478bd9Sstevel@tonic-gate "limits (%d...%d). Shutting down the system.\n") 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gate #define ENV_DIMM_FAN_FAILURE_SHUTDOWN_MSG \ 4937c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: %s has Failed.\n" \ 4947c478bd9Sstevel@tonic-gate "(rpm = %s status = %s command = %s debug = %s).\n" \ 4957c478bd9Sstevel@tonic-gate "Shutting down the system to protect the memory modules.\n") 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate #define ENV_WARNING_MSG \ 4987c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \ 4997c478bd9Sstevel@tonic-gate "operating limits (%d...%d).\n") 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate #define ENV_FAN_OPEN_FAIL \ 5027c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open '%s' fan path:%s errno:%d %s\n") 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate #define ENV_SENSOR_OPEN_FAIL \ 5057c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open '%s' sensor path:%s errno:%d %s\n") 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate #define ENV_SENSOR_ACCESS_FAIL \ 5087c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't access '%s' sensor errno:%d %s\n") 5097c478bd9Sstevel@tonic-gate 5107c478bd9Sstevel@tonic-gate #define ENV_SENSOR_ACCESS_OK \ 5117c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: '%s' sensor is accessible now.\n") 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate #define ENV_FRU_OPEN_FAIL \ 5147c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open FRU SEEPROM path:%s errno:%d %s\n") 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate #define ENV_FRU_BAD_ENVSEG \ 5177c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: version mismatch or environmental segment " \ 5187c478bd9Sstevel@tonic-gate "header too short in FRU SEEPROM %s\n") 5197c478bd9Sstevel@tonic-gate 5207c478bd9Sstevel@tonic-gate #define ENV_FRU_BAD_SENSOR_ENTRY \ 5217c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: discarding bad sensor entry (sensor_id " \ 5227c478bd9Sstevel@tonic-gate "%x sensor '%s') in FRU SEEPROM %s\n") 5237c478bd9Sstevel@tonic-gate 5247c478bd9Sstevel@tonic-gate #define ENV_FRU_SENSOR_MAP_NOMEM \ 5257c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: out of memory, discarding sensor map for " \ 5267c478bd9Sstevel@tonic-gate "sensor_id %x (sensor '%s') in FRU SEEPROM %s\n") 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate #define ENV_ADM_OPEN_FAIL \ 5297c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: can't open hwm path:%s errno:%d %s\n") 5307c478bd9Sstevel@tonic-gate 5317c478bd9Sstevel@tonic-gate #define ENV_ADM_MANUAL_MODE \ 5327c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: Cannot change the ADM Chip to Manual mode") 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate #define ENV_ADM_AUTO_MODE \ 5357c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: Cannot change the ADM Chip to Auto mode") 5367c478bd9Sstevel@tonic-gate 5377c478bd9Sstevel@tonic-gate #define ENV_FAN_FAULT \ 5387c478bd9Sstevel@tonic-gate gettext("SUNW_piclenvd: ADM %s, Fan %s Fault") 5397c478bd9Sstevel@tonic-gate 5407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5417c478bd9Sstevel@tonic-gate } 5427c478bd9Sstevel@tonic-gate #endif 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate #endif /* _ENVD_H */ 545