summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/lom_priv.h
blob: 5c786690a2abf63325fdafe9c0a28f72bcb1fa8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_LOM_PRIV_H
#define	_SYS_LOM_PRIV_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * Project private LOMlite definitions.
 * The definitions here are not used by the end user.
 */

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _KERNEL
#ifdef __sparc
#include <sys/cpu_sgnblk_defs.h>
#endif /* __sparc */
#endif /* _KERNEL */

/*
 * Data structures which are passed to the driver via the LOMIOCPROG ioctl.
 *
 * The userland utility constructs an image which begins with a
 * lom_prog_data_t structure and is followed by platform specific data
 * the contents of which are identified by the 'platmagic' value.
 */
typedef struct {
	union {
		uint32_t	magic;
		struct {
			uint16_t	size;
			uint16_t	loadaddr;
		} old_prog;
	}		header;
	uint32_t	platmagic;
	/* Platform specific */
	union {
		struct {
			uint32_t	loadaddr;
			uint32_t	size;
		} bscv;
	} platform;
} lom_prog_data_t;

/*
 * header.magic value - this is chosen because it never occurs on the old
 * programming data
 */
#define	PROG_MAGIC	0

/*
 * platmagic values.
 * Top two bytes assigned to specific lom implementations/platform
 * Bottom two bytes assigned by the implementations/platform.
 *
 * 0x4c56 "LV" - bscv and derivatives.
 *	0x4c564c4f "LVLO" - firmware downloader.
 *	0x4c56494d "LVIM" - firmware image.
 * 0x5347 "SG" - serengeti based lom.
 *	Not specified here.
 */

#define	PROG_PLAT_BSCV_LOADER	0x4c564c4f
#define	PROG_PLAT_BSCV_IMAGE	0x4c56494d
#define	PROG_PLAT_SG_IMAGE	0x5347494d

/* defn for top byte of 16bit event code */
#define	EVENT_SUBSYS_NONE	0x00
#define	EVENT_SUBSYS_ALARM	0x01
#define	EVENT_SUBSYS_TEMP	0x02
#define	EVENT_SUBSYS_OVERTEMP	0x03
#define	EVENT_SUBSYS_FAN	0x04
#define	EVENT_SUBSYS_SUPPLY	0x05
#define	EVENT_SUBSYS_BREAKER	0x06
#define	EVENT_SUBSYS_PSU	0x07
#define	EVENT_SUBSYS_USER	0x08
#define	EVENT_SUBSYS_PHONEHOME	0x09
#define	EVENT_SUBSYS_LOM	0x0a
#define	EVENT_SUBSYS_HOST	0x0b
#define	EVENT_SUBSYS_EVENTLOG	0x0c
#define	EVENT_SUBSYS_EXTRA	0x0d	/* reserved for future use */
#define	EVENT_SUBSYS_LED	0x0e

#define	EVENT_MASK_SHUTDOWN_REQD	0x20
#define	EVENT_MASK_FAULT		0x40
#define	EVENT_MASK_FATAL		0x80


#define	EVENT_NONE			0x00
#define	EVENT_STATE_ON			0x01
#define	EVENT_STATE_OFF			0x02
#define	EVENT_STATE_CHANGE		0x03
#define	EVENT_POWER_ON			0x04
#define	EVENT_POWER_OFF			0x05
#define	EVENT_UNEXPECTED_POWER_OFF	0x06
#define	EVENT_UNEXPECTED_RESET		0x07
#define	EVENT_BOOTED			0x08
#define	EVENT_WATCHDOG_ON		0x09
#define	EVENT_WATCHDOG_OFF		0x0a
#define	EVENT_WATCHDOG_TRIGGER		0x0b
#define	EVENT_FAILED			0x0c
#define	EVENT_RECOVERED			0x0d
#define	EVENT_RESET			0x0e
#define	EVENT_ABORT			0x0f
#define	EVENT_CONSOLE_SELECT		0x10
#define	EVENT_TIME_REFERENCE		0x11
#define	EVENT_SCRIPT_FAILURE		0x12
#define	EVENT_MODEM_ACCESS_FAIL		0x13
#define	EVENT_MODEM_DIAL_FAIL		0x14
#define	EVENT_BAD_CHECKSUM		0x15
#define	EVENT_USER_ADDED		0x16
#define	EVENT_USER_REMOVED		0x17
#define	EVENT_USER_PERMSCHANGED		0x18
#define	EVENT_USER_LOGIN		0x19
#define	EVENT_USER_PASSWORD_CHANGE	0x1a
#define	EVENT_USER_LOGINFAIL		0x1b
#define	EVENT_USER_LOGOUT		0x1c
#define	EVENT_FLASH_DOWNLOAD		0x1d
#define	EVENT_DATA_LOST			0x1e
#define	EVENT_DEVICE_BUSY		0x1f
#define	EVENT_FAULT_LED			0x20
#define	EVENT_OVERHEAT			0x21
#define	EVENT_SEVERE_OVERHEAT		0x22
#define	EVENT_NO_OVERHEAT		0x23
#define	EVENT_SCC_STATUS		0x24
/* bscv only */
#define	EVENT_DEVICE_INACCESSIBLE	0x25
#define	EVENT_HOSTNAME_CHANGE		0x26
#define	EVENT_CPUSIG_TIMEOUT		0x27
#define	EVENT_BOOTMODE_CHANGE		0x28
#define	EVENT_WATCHDOG_CHANGE_POLICY	0x29
#define	EVENT_WATCHDOG_CHANGE_TIMEOUT	0x2a

/*
 * Event "detail" information - bscv only
 */
#define	LOM_RESET_DETAIL_BYUSER			1
#define	LOM_RESET_DETAIL_REPROGRAMMING 		2

#define	LOM_WDOGTRIGGER_DETAIL_HARD		0
#define	LOM_WDOGTRIGGER_DETAIL_SOFT		1

#define	LOM_UNEXPECTEDRESET_MASK_BADTRAP	0x80
#define	EBUS_BOOTMODE_FORCE_CONSOLE		0x01

/*
 * Event log filtering
 */
#define	EVENT_LEVEL_USER		4
#define	EVENT_LEVEL_NOTICE		3
#define	EVENT_LEVEL_FAULT		2
#define	EVENT_LEVEL_FATAL		1

/*
 * Event data
 */
typedef struct {
	uint8_t		ev_subsys;
	uint8_t		ev_event;
	uint8_t		ev_resource;
	uint8_t		ev_detail;
	uint8_t		ev_data[4];
} lom_event_t;


#define	EVENT_DECODE_SUBSYS(evcode)	((evcode) & 0x1f)
#define	EVENT_DECODE_FAULT(evcode)	((evcode) & (EVENT_MASK_FAULT| \
						EVENT_MASK_FATAL| \
						EVENT_MASK_SHUTDOWN_REQD))

/* Magic numbers for reading values from conf files */
#define	LOM_TEMP_PROP_NOT_SET	0x80000000	/* Use current setting */
#define	LOM_TEMP_PROP_MIN	40		/* Minimum temp settable */
#define	LOM_TEMP_PROP_MAX	120		/* Maximum temp settable */

#define	LOM_SERIAL_TOUT_DEFAULT	0		/* Default value */
#define	LOM_SERIAL_TOUT_MIN	5		/* Minimum timeout period */
#define	LOM_SERIAL_TOUT_MAX	0xff		/* Maximum timeout period */

#ifdef	_KERNEL
/* Inter Driver Interface */

#define	SUNW_KERN_BSCV_MODULENAME		"bscv"
#define	SUNW_KERN_BSCV_IDI_FN			"bscv_idi_set"

enum bscv_idi_type    {
	BSCV_IDI_NULL = 0,
	BSCV_IDI_NODENAME,
	BSCV_IDI_SIG,
	BSCV_IDI_WDOG_PAT,
	BSCV_IDI_WDOG_CFG
};

#ifdef __sparc
typedef
struct {
	uint32_t	cpu;
	sig_state_t	sig_info;
} bscv_sig_t;
#endif /* __sparc */

typedef
struct {
	/*
	 * Enable the watchdog.  This must be done before patting is done.
	 */
	uint8_t			enable_wdog;

	/*
	 * wdog_timeout_s seconds before watchdog expires; minimum
	 * value is 1, maximum value is 127.  The dog must be patted
	 * once per second.
	 */
	uint_t			wdog_timeout_s;

	/*
	 * reset_system_on_timeout false means the microcontroller will only
	 * log the fact that the watchdog expired, rather than actually
	 * resetting the host.
	 */
	uint8_t			reset_system_on_timeout;

} bscv_wdog_t;

struct bscv_idi_info  {
	enum bscv_idi_type	type;
	void			*data;
	size_t			size;
};

void bscv_idi_set(struct bscv_idi_info info);

#endif	/* _KERNEL */

#ifdef __cplusplus
}
#endif

#endif	/* _SYS_LOM_PRIV_H */