dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / picl / plugins / sun4u / snowbird / watchdog / piclwatchdog.h
blob7870fc0363b9a1609e4479aeb13a6863c6e18de3
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _PICL_WATCHDOG_H
28 #define _PICL_WATCHDOG_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #include <libintl.h>
37 #include <sys/inttypes.h>
38 #include <smclib.h>
40 #define WD_DEBUG0(fmt) \
41 if (wd_debug) { \
42 syslog(LOG_DEBUG, fmt); \
44 #define WD_DEBUG1(fmt, d1) \
45 if (wd_debug) { \
46 syslog(LOG_DEBUG, fmt, d1); \
49 /* environment variable defs */
50 #define WATCHDOG_DEBUG "SUNW_WATCHDOG_DEBUG"
52 /* debug flags */
53 #define WD_GENERAL_MSGS 0x1
54 #define WD_TIME_DEBUG 0x2
56 /* tunables */
57 #define WD_DEFAULT_THREAD_PRIORITY 0
58 #define WD_POLL_TIMEOUT 10000 /* 10 sec */
59 #define WD_PAT_TIME 5000
61 /* constants */
62 #define WD_SET_CMD_DATA_LEN 6 /* size for set cmd */
63 #define PICL_WD_PROPVAL_MAX 20
64 #define SUPER_USER 0
66 /* watchdog status */
67 #define WD_ARMED 0x1 /* watchdog is running */
68 #define WD_EXPIRED 0x2 /* watchdog is expired */
69 #define WD_DISARMED 0x4 /* watchdog is stopped */
71 /* patting status */
72 #define WD_RESET 0x8 /* client chose to pat. */
73 #define WD_NORESET 0x0 /* pat state initial value. */
75 /* auto pat feature for SMC f/w */
76 #define ENABLE_AUTO_PAT 0x1
77 #define DISABLE_AUTO_PAT 0x0
79 /* flags used to track user actions */
80 #define USER_ARMED_WD 0x1 /* user armed the watchdog */
81 #define USER_ARMED_PAT_WD 0x2 /* debug feature */
82 #define USER_PAT_WD 0x3 /* debug feature */
83 #define USER_DISARMED_WD 0x4 /* user disarmed watchdog */
85 /* bit masks */
86 #define WD_ACTION_NONE1 0x30 /* action none with interrupt */
87 #define WD_ACTION_NONE2 0x00 /* no action */
88 #define WD_ACTION_HARD_RESET 0x01 /* hard reset */
89 #define WD_ACTION_HEALTHY_DOWN_HOST 0x50 /* dont put bridge in reset */
90 #define WD_ACTION_HEALTHY_DOWN_SAT 0x40 /* healthy down, bridge reset */
91 #define WD_USEFLAG_OS 0x04 /* set os as user of wd */
92 #define WD_XPR_FLG_CLR_OS 0x10 /* to clear sms/os expiry bit */
93 #define WD_WD_RUNNING 0x40 /* to check wd running or not */
94 #define WD_ENABLE_AUTO_PAT 0x20 /* enable auto pat feature */
96 /* timer max values */
97 #define WD_MAX_L2 0xff /* 255 sec */
98 #define WD_MAX_L1 0xffff /* 109.22 min */
99 #define WD_L1_RESOLUTION 100 /* 100ms/cnt */
100 #define WD_L2_RESOLUTION 1000 /* 1000ms/cnt */
102 #define WD1 0x1 /* wd level 1 */
103 #define WD2 0x2 /* wd level 2 */
104 #define WD1_2 0x3 /* wd level 1 and level 2 */
105 #define WD_MAX_SEQN 255
107 /* PICL node names */
108 #define PICL_NODE_CHASSIS "chassis"
109 #define PICL_NODE_SYSMGMT "sysmgmt"
110 #define PICL_NODE_WD_CONTROLLER "watchdog"
111 #define PICL_NODE_WD_L1 "watchdog-level1"
112 #define PICL_NODE_WD_L2 "watchdog-level2"
114 /* debug value for wd_op */
115 #define WD_ARM_PAT "arm-pat"
117 /* HEALTHY# status */
118 #define WD_HEALTHY_DOWN 0x0
119 #define WD_HEALTHY_UP 0x1
121 #define SHUTDOWN_CMD "shutdown -y -i 6 -g 60 watchdog "\
122 "expired.. rebooting"
123 /* watchdog config file variables */
124 #define PICL_CONFIG_DIR "/etc/picl/config"
125 #define WD_CONF_FILE "watchdog.conf"
126 #define WD_CONF_MAXSIZE 100
127 #define WD_DELIMETER " \t\n"
129 /* The following values can be tuned using config file */
130 #define WD_PAT_THREAD_PRIORITY "wd_thread_priority"
131 #define WD_PATTING_TIME "wd_pat_time"
132 #define WD_ENABLE "watchdog-enable"
134 #define WD_HOST 1
135 #define WD_STANDALONE 2
137 /* HEALTHY# bitmask */
138 #define IS_HEALTHY 0x01
140 #define DEFAULT_SEQN 15
141 #define DEFAULT_FD -1
142 #define SMC_NODE "/dev/ctsmc"
144 #define WD_REGISTER_LEN 8
146 typedef struct {
147 /* properties values */
148 uint8_t wd1_run_state; /* L1 status */
149 uint8_t wd1_action; /* L1 action */
150 uint8_t wd2_run_state; /* L2 status */
151 uint8_t wd2_action; /* L2 action */
152 int32_t wd1_timeout; /* L1 timeout */
153 int32_t wd2_timeout; /* L2 timeout */
154 uchar_t wd_pat_state; /* pat state */
155 boolean_t reboot_action; /* is reboot action set */
156 boolean_t is_host; /* is a host or standalone CPU */
158 /* Cache for PICL handles */
159 picl_nodehdl_t wd_ctrl_nodehdl; /* watchdog controller */
160 /* prop handle for op */
161 picl_prophdl_t wd_ops_hdl;
163 picl_prophdl_t wd1_state_hdl;
164 picl_prophdl_t wd1_timeout_hdl;
165 picl_prophdl_t wd1_action_hdl;
166 picl_nodehdl_t wd1_nodehdl; /* L1 node handle */
168 picl_prophdl_t wd2_state_hdl;
169 picl_prophdl_t wd2_timeout_hdl;
170 picl_prophdl_t wd2_action_hdl;
171 picl_nodehdl_t wd2_nodehdl; /* L2 node handle */
172 } wd_data_t;
174 /* structure to hold watchdog status */
175 typedef struct {
176 int present_state;
177 uint8_t action1;
178 uint8_t action2;
179 uint8_t timeout1[2];
180 uint8_t timeout2;
181 uint8_t present_t1[2];
182 } wd_state_t;
184 /* Error messages */
185 #define WD_PICL_NOSPACE \
186 gettext("SUNW_piclwatchdog: Error in memory allocation")
187 #define WD_PICL_REG_ERR \
188 gettext("SUNW_piclwatchdog: Failed to register with picl framework,"\
189 " error = %d")
190 #define WD_PICL_SMC_OPEN_ERR \
191 gettext("SUNW_piclwatchdog: Error in opening SMC drv")
192 #define WD_PICL_EXCLUSIVE_ACCESS_ERR \
193 gettext("SUNW_piclwatchdog: Error in getting exclusive access "\
194 "for watchdog commands")
195 #define WD_PICL_THREAD_CREATE_FAILED \
196 gettext("SUNW_piclwatchdog: Error in creating %s thread")
197 #define WD_PICL_PROP_INIT_ERR \
198 gettext("SUNW_piclwatchdog: ptree prop init call failed:%d")
199 #define WD_NODE_INIT_ERR \
200 gettext("SUNW_piclwatchdog: Error in creating watchdog nodes(%d):%d")
201 #define WD_PICL_GET_STAT_ERR \
202 gettext("SUNW_piclwatchdog: Error in getting the watchdog status")
203 #define WD_PICL_GET_ERR \
204 gettext("SUNW_piclwatchdog: Error in getting watchdog status,"\
205 " error = %d")
206 #define WD_PICL_PAT_ERR \
207 gettext("SUNW_piclwatchdog: Error in patting the watchdog"\
208 " error = %d")
209 #define WD_PICL_START_ERR \
210 gettext("SUNW_piclwatchdog: Error in starting the watchdog, error = %d")
211 #define WD_PICL_STOP_ERR \
212 gettext("SUNW_piclwatchdog: Error in stopping the watchdog,"\
213 " error = %d")
214 #define WD_PICL_SET_ATTR_FAILED \
215 gettext("SUNW_piclwatchdog: Error in setting attributes for a stream")
216 #define WD_PICL_RT_THRD_FAIL \
217 gettext("SUNW_piclwatchdog: Error in creating real time thread")
218 #define WD_PICL_RT_THRD_NO_PERM_ERR \
219 gettext("SUNW_piclwatchdog: No perm to change the priority of thread")
220 #define WD_PICL_NO_WD_ERR \
221 gettext("SUNW_piclwatchdog: Watchdog is not running")
222 #define WD_PICL_WD1_RUNNING_ERR \
223 gettext("SUNW_piclwatchdog: Disarm the Watchdog level 1")
224 #define WD_PICL_WD2_RUNNING_ERR \
225 gettext("SUNW_piclwatchdog: Disarm the Watchdog level 2")
226 #define WD_PICL_SMC_READ_ERR \
227 gettext("SUNW_piclwatchdog: Error in reading from SMC")
228 #define WD_PICL_SMC_WRITE_ERR \
229 gettext("SUNW_piclwatchdog: Error in writing to SMC")
230 #define WD_NO_ROOT_PERM \
231 gettext("SUNW_piclwatchdog: Root perm are reqd to perform this op.")
232 #define WD_PICL_POLL_ERR \
233 gettext("SUNW_piclwatchdog: Error in poll system call")
234 #define WD_PICL_INVALID_T1 \
235 gettext("SUNW_piclwatchdog: Invalid timeout value for wd level 1")
236 #define WD_PICL_INVALID_T2 \
237 gettext("SUNW_piclwatchdog: Invalid timeout value for wd level 2")
238 #define WD_PICL_TMOUT_LV1_LV2_SETTO_0 \
239 gettext("SUNW_piclwatchdog: Invalid timeout val for wd level 1 & 2")
240 #define WD_PICL_INVALID_ACTION1 \
241 gettext("SUNW_piclwatchdog: Invalid action for level one")
242 #define WD_PICL_INVALID_ACTION2 \
243 gettext("SUNW_piclwatchdog: Invalid action for level two")
244 #define WD_PICL_CLEAR_EXCL_ERR \
245 gettext("SUNW_piclwatchdog: Error in clearing exclusive "\
246 "access for watchdog commands")
247 #define WD_PICL_POST_EVENT_ERR \
248 gettext("SUNW_piclwatchdog: Error in posting wd expiry event,"\
249 " error = %d")
250 #define WD_PICL_COND_SIGNAL_ERR \
251 gettext("SUNW_piclwatchdog: Error in cond_signal")
252 #define WD_PICL_IS_NOT_SUPPORTED \
253 gettext("SUNW_piclwatchdog: This feature is not supported")
254 #define WD_PICL_TRY_PAT_ERR \
255 gettext("SUNW_piclwatchdog: OS is already patting the watchdog")
256 #define WD_PICL_GET_TIMEOUT_ERR \
257 gettext("SUNW_piclwatchdog: Error in getting the timeout values")
258 #define WD_PICL_ARM_PAT_ERR \
259 gettext("SUNW_piclwatchdog: Illegal timeout values for arm-pat op")
260 #define WD_PICL_PERM_DENIED \
261 gettext("SUNW_piclwatchdog: This client is not the owner of watchdog")
262 #define WD_PICL_PAT_TIME_ERR \
263 gettext("SUNW_piclwatchdog: Negative value for pat_time \
264 is not allowed")
265 #define WD_PICL_STATE_INVALID \
266 gettext("SUNW_piclwatchdog: WD operations not allowed while "\
267 "chassis state is configuring")
268 #define WD_HEALTHY_ERR \
269 gettext("SUNW_piclwatchdog: Cannot arm the watchdog, "\
270 "action already taken")
271 #define WD_GET_OWN_FAILED \
272 gettext("SUNW_piclwatchdog: Error in finding active owner of watchdog,"\
273 " error = %d")
274 #define WD_NVLIST_ERR \
275 gettext("SUNW_piclwatchdog: Error in posting watchdog event"\
276 "(nvlist error), error = %d")
277 #define WD_GET_HEALTH_ERR \
278 gettext("SUNW_piclwatchdog: Error in getting HEALTHY# status")
279 #define WD_UPDATE_STATE_ERR \
280 gettext("SUNW_piclwatchdog: Error in updating watchdog state,"\
281 "error = %d")
282 #define WD_WD1_EXPIRED \
283 gettext("SUNW_piclwatchdog: watchdog level 1 expired")
284 #ifdef __cplusplus
286 #endif
288 #endif /* _PICL_WATCHDOG_H */