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