xref: /titanic_41/usr/src/uts/common/sys/lom_priv.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_LOM_PRIV_H
28 #define	_SYS_LOM_PRIV_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Project private LOMlite definitions.
34  * The definitions here are not used by the end user.
35  */
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #ifdef _KERNEL
42 #ifdef __sparc
43 #include <sys/cpu_sgnblk_defs.h>
44 #endif /* __sparc */
45 #endif /* _KERNEL */
46 
47 /*
48  * Data structures which are passed to the driver via the LOMIOCPROG ioctl.
49  *
50  * The userland utility constructs an image which begins with a
51  * lom_prog_data_t structure and is followed by platform specific data
52  * the contents of which are identified by the 'platmagic' value.
53  */
54 typedef struct {
55 	union {
56 		uint32_t	magic;
57 		struct {
58 			uint16_t	size;
59 			uint16_t	loadaddr;
60 		} old_prog;
61 	}		header;
62 	uint32_t	platmagic;
63 	/* Platform specific */
64 	union {
65 		struct {
66 			uint32_t	loadaddr;
67 			uint32_t	size;
68 		} bscv;
69 	} platform;
70 } lom_prog_data_t;
71 
72 /*
73  * header.magic value - this is chosen because it never occurs on the old
74  * programming data
75  */
76 #define	PROG_MAGIC	0
77 
78 /*
79  * platmagic values.
80  * Top two bytes assigned to specific lom implementations/platform
81  * Bottom two bytes assigned by the implementations/platform.
82  *
83  * 0x4c56 "LV" - bscv and derivatives.
84  *	0x4c564c4f "LVLO" - firmware downloader.
85  *	0x4c56494d "LVIM" - firmware image.
86  * 0x5347 "SG" - serengeti based lom.
87  *	Not specified here.
88  */
89 
90 #define	PROG_PLAT_BSCV_LOADER	0x4c564c4f
91 #define	PROG_PLAT_BSCV_IMAGE	0x4c56494d
92 #define	PROG_PLAT_SG_IMAGE	0x5347494d
93 
94 /* defn for top byte of 16bit event code */
95 #define	EVENT_SUBSYS_NONE	0x00
96 #define	EVENT_SUBSYS_ALARM	0x01
97 #define	EVENT_SUBSYS_TEMP	0x02
98 #define	EVENT_SUBSYS_OVERTEMP	0x03
99 #define	EVENT_SUBSYS_FAN	0x04
100 #define	EVENT_SUBSYS_SUPPLY	0x05
101 #define	EVENT_SUBSYS_BREAKER	0x06
102 #define	EVENT_SUBSYS_PSU	0x07
103 #define	EVENT_SUBSYS_USER	0x08
104 #define	EVENT_SUBSYS_PHONEHOME	0x09
105 #define	EVENT_SUBSYS_LOM	0x0a
106 #define	EVENT_SUBSYS_HOST	0x0b
107 #define	EVENT_SUBSYS_EVENTLOG	0x0c
108 #define	EVENT_SUBSYS_EXTRA	0x0d	/* reserved for future use */
109 #define	EVENT_SUBSYS_LED	0x0e
110 
111 #define	EVENT_MASK_SHUTDOWN_REQD	0x20
112 #define	EVENT_MASK_FAULT		0x40
113 #define	EVENT_MASK_FATAL		0x80
114 
115 
116 #define	EVENT_NONE			0x00
117 #define	EVENT_STATE_ON			0x01
118 #define	EVENT_STATE_OFF			0x02
119 #define	EVENT_STATE_CHANGE		0x03
120 #define	EVENT_POWER_ON			0x04
121 #define	EVENT_POWER_OFF			0x05
122 #define	EVENT_UNEXPECTED_POWER_OFF	0x06
123 #define	EVENT_UNEXPECTED_RESET		0x07
124 #define	EVENT_BOOTED			0x08
125 #define	EVENT_WATCHDOG_ON		0x09
126 #define	EVENT_WATCHDOG_OFF		0x0a
127 #define	EVENT_WATCHDOG_TRIGGER		0x0b
128 #define	EVENT_FAILED			0x0c
129 #define	EVENT_RECOVERED			0x0d
130 #define	EVENT_RESET			0x0e
131 #define	EVENT_ABORT			0x0f
132 #define	EVENT_CONSOLE_SELECT		0x10
133 #define	EVENT_TIME_REFERENCE		0x11
134 #define	EVENT_SCRIPT_FAILURE		0x12
135 #define	EVENT_MODEM_ACCESS_FAIL		0x13
136 #define	EVENT_MODEM_DIAL_FAIL		0x14
137 #define	EVENT_BAD_CHECKSUM		0x15
138 #define	EVENT_USER_ADDED		0x16
139 #define	EVENT_USER_REMOVED		0x17
140 #define	EVENT_USER_PERMSCHANGED		0x18
141 #define	EVENT_USER_LOGIN		0x19
142 #define	EVENT_USER_PASSWORD_CHANGE	0x1a
143 #define	EVENT_USER_LOGINFAIL		0x1b
144 #define	EVENT_USER_LOGOUT		0x1c
145 #define	EVENT_FLASH_DOWNLOAD		0x1d
146 #define	EVENT_DATA_LOST			0x1e
147 #define	EVENT_DEVICE_BUSY		0x1f
148 #define	EVENT_FAULT_LED			0x20
149 #define	EVENT_OVERHEAT			0x21
150 #define	EVENT_SEVERE_OVERHEAT		0x22
151 #define	EVENT_NO_OVERHEAT		0x23
152 #define	EVENT_SCC_STATUS		0x24
153 /* bscv only */
154 #define	EVENT_DEVICE_INACCESSIBLE	0x25
155 #define	EVENT_HOSTNAME_CHANGE		0x26
156 #define	EVENT_CPUSIG_TIMEOUT		0x27
157 #define	EVENT_BOOTMODE_CHANGE		0x28
158 #define	EVENT_WATCHDOG_CHANGE_POLICY	0x29
159 #define	EVENT_WATCHDOG_CHANGE_TIMEOUT	0x2a
160 
161 /*
162  * Event "detail" information - bscv only
163  */
164 #define	LOM_RESET_DETAIL_BYUSER			1
165 #define	LOM_RESET_DETAIL_REPROGRAMMING 		2
166 
167 #define	LOM_WDOGTRIGGER_DETAIL_HARD		0
168 #define	LOM_WDOGTRIGGER_DETAIL_SOFT		1
169 
170 #define	LOM_UNEXPECTEDRESET_MASK_BADTRAP	0x80
171 #define	EBUS_BOOTMODE_FORCE_CONSOLE		0x01
172 
173 /*
174  * Event log filtering
175  */
176 #define	EVENT_LEVEL_USER		4
177 #define	EVENT_LEVEL_NOTICE		3
178 #define	EVENT_LEVEL_FAULT		2
179 #define	EVENT_LEVEL_FATAL		1
180 
181 /*
182  * Event data
183  */
184 typedef struct {
185 	uint8_t		ev_subsys;
186 	uint8_t		ev_event;
187 	uint8_t		ev_resource;
188 	uint8_t		ev_detail;
189 	uint8_t		ev_data[4];
190 } lom_event_t;
191 
192 
193 #define	EVENT_DECODE_SUBSYS(evcode)	((evcode) & 0x1f)
194 #define	EVENT_DECODE_FAULT(evcode)	((evcode) & (EVENT_MASK_FAULT| \
195 						EVENT_MASK_FATAL| \
196 						EVENT_MASK_SHUTDOWN_REQD))
197 
198 /* Magic numbers for reading values from conf files */
199 #define	LOM_TEMP_PROP_NOT_SET	0x80000000	/* Use current setting */
200 #define	LOM_TEMP_PROP_MIN	40		/* Minimum temp settable */
201 #define	LOM_TEMP_PROP_MAX	120		/* Maximum temp settable */
202 
203 #define	LOM_SERIAL_TOUT_DEFAULT	0		/* Default value */
204 #define	LOM_SERIAL_TOUT_MIN	5		/* Minimum timeout period */
205 #define	LOM_SERIAL_TOUT_MAX	0xff		/* Maximum timeout period */
206 
207 #ifdef	_KERNEL
208 /* Inter Driver Interface */
209 
210 #define	SUNW_KERN_BSCV_MODULENAME		"bscv"
211 #define	SUNW_KERN_BSCV_IDI_FN			"bscv_idi_set"
212 
213 enum bscv_idi_type    {
214 	BSCV_IDI_NULL = 0,
215 	BSCV_IDI_NODENAME,
216 	BSCV_IDI_SIG,
217 	BSCV_IDI_WDOG_PAT,
218 	BSCV_IDI_WDOG_CFG
219 };
220 
221 #ifdef __sparc
222 typedef
223 struct {
224 	uint32_t	cpu;
225 	sig_state_t	sig_info;
226 } bscv_sig_t;
227 #endif /* __sparc */
228 
229 typedef
230 struct {
231 	/*
232 	 * Enable the watchdog.  This must be done before patting is done.
233 	 */
234 	uint8_t			enable_wdog;
235 
236 	/*
237 	 * wdog_timeout_s seconds before watchdog expires; minimum
238 	 * value is 1, maximum value is 127.  The dog must be patted
239 	 * once per second.
240 	 */
241 	uint_t			wdog_timeout_s;
242 
243 	/*
244 	 * reset_system_on_timeout false means the microcontroller will only
245 	 * log the fact that the watchdog expired, rather than actually
246 	 * resetting the host.
247 	 */
248 	uint8_t			reset_system_on_timeout;
249 
250 } bscv_wdog_t;
251 
252 struct bscv_idi_info  {
253 	enum bscv_idi_type	type;
254 	void			*data;
255 	size_t			size;
256 };
257 
258 void bscv_idi_set(struct bscv_idi_info info);
259 
260 #endif	/* _KERNEL */
261 
262 #ifdef __cplusplus
263 }
264 #endif
265 
266 #endif	/* _SYS_LOM_PRIV_H */
267