xref: /titanic_52/usr/src/lib/fm/topo/libtopo/common/mktables.sh (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1#!/bin/sh
2
3#
4# CDDL HEADER START
5#
6# The contents of this file are subject to the terms of the
7# Common Development and Distribution License (the "License").
8# You may not use this file except in compliance with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#ident	"%Z%%M%	%I%	%E% SMI"
28
29#
30# Construct translation tables for defines in libtopo.h to translate to readable
31# strings.
32#
33
34if [ $# -ne 1 ]; then
35	echo >&2 "USAGE: $0 <path to libtopo.h>"
36	exit 1
37fi
38
39if [ -r $1 ]; then
40	libtopo_h=$1
41else
42	echo >&2 "USAGE: $0 <path to libtopo.h>"
43	echo >&2 "Make sure libtopo.h exists and is readable"
44	exit 1
45fi
46
47echo "\
48/*
49 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
50 * Use is subject to license terms.
51 */
52
53#pragma ident	\"%Z%%M%	%I%	%E% SMI\"
54
55#include <libtopo.h>
56#include \"topo_mod.h\"
57#include \"topo_subr.h\""
58
59#
60# Sensor types.
61#
62echo "\ntopo_name_trans_t topo_sensor_type_table[] = {"
63
64pattern="#define	TOPO_SENSOR_TYPE_\([A-Z0-9_]*\).*\$"
65replace="	{ TOPO_SENSOR_TYPE_\1, \"\1\" },"
66
67cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
68
69echo "\t{ 0, NULL }
70};"
71
72#
73# Units
74#
75echo "\ntopo_name_trans_t topo_units_type_table[] = {"
76
77pattern="	TOPO_SENSOR_UNITS_\([A-Z0-9_]*\).*\$"
78replace="	{ TOPO_SENSOR_UNITS_\1, \"\1\" },"
79
80cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
81
82echo "\t{ 0, NULL }
83};"
84
85#
86# Indicator (LED) types
87#
88echo "\ntopo_name_trans_t topo_led_type_table[] = {"
89
90pattern="	TOPO_LED_TYPE_\([A-Z0-9_]*\).*\$"
91replace="	{ TOPO_LED_TYPE_\1, \"\1\" },"
92
93cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
94
95echo "\t{ 0, NULL }
96};"
97
98#
99# Indicator (LED) states
100#
101echo "\ntopo_name_trans_t topo_led_states_table[] = {"
102
103pattern="	TOPO_LED_STATE_\([A-Z0-9_]*\).*\$"
104replace="	{ TOPO_LED_STATE_\1, \"\1\" },"
105
106cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
107
108echo "\t{ 0, NULL }
109};"
110
111#
112# Discrete sensor states
113#
114echo "\ntopo_name_trans_t topo_sensor_states_physical_table[] = {"
115
116pattern="#define	TOPO_SENSOR_STATE_PHYSICAL_\([A-Z0-9_]*\).*\$"
117replace="	{ TOPO_SENSOR_STATE_PHYSICAL_\1, \"\1\" },"
118
119cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
120
121echo "\t{ 0, NULL }
122};"
123
124echo "\ntopo_name_trans_t topo_sensor_states_platform_table[] = {"
125
126pattern="#define	TOPO_SENSOR_STATE_PLATFORM_\([A-Z0-9_]*\).*\$"
127replace="	{ TOPO_SENSOR_STATE_PLATFORM_\1, \"\1\" },"
128
129cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
130
131echo "\t{ 0, NULL }
132};"
133
134echo "\ntopo_name_trans_t topo_sensor_states_processor_table[] = {"
135
136pattern="#define	TOPO_SENSOR_STATE_PROCESSOR_\([A-Z0-9_]*\).*\$"
137replace="	{ TOPO_SENSOR_STATE_PROCESSOR_\1, \"\1\" },"
138
139cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
140
141echo "\t{ 0, NULL }
142};"
143
144echo "\ntopo_name_trans_t topo_sensor_states_power_supply_table[] = {"
145
146pattern="#define	TOPO_SENSOR_STATE_POWER_SUPPLY_\([A-Z0-9_]*\).*\$"
147replace="	{ TOPO_SENSOR_STATE_POWER_SUPPLY_\1, \"\1\" },"
148
149cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
150
151echo "\t{ 0, NULL }
152};"
153
154echo "\ntopo_name_trans_t topo_sensor_states_power_unit_table[] = {"
155
156pattern="#define	TOPO_SENSOR_STATE_POWER_UNIT_\([A-Z0-9_]*\).*\$"
157replace="	{ TOPO_SENSOR_STATE_POWER_UNIT_\1, \"\1\" },"
158
159cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
160
161echo "\t{ 0, NULL }
162};"
163
164echo "\ntopo_name_trans_t topo_sensor_states_memory_table[] = {"
165
166pattern="#define	TOPO_SENSOR_STATE_MEMORY_\([A-Z0-9_]*\).*\$"
167replace="	{ TOPO_SENSOR_STATE_MEMORY_\1, \"\1\" },"
168
169cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
170
171echo "\t{ 0, NULL }
172};"
173
174echo "\ntopo_name_trans_t topo_sensor_states_bay_table[] = {"
175
176pattern="#define	TOPO_SENSOR_STATE_BAY_\([A-Z0-9_]*\).*\$"
177replace="	{ TOPO_SENSOR_STATE_BAY_\1, \"\1\" },"
178
179cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
180
181echo "\t{ 0, NULL }
182};"
183
184echo "\ntopo_name_trans_t topo_sensor_states_firmware_table[] = {"
185
186pattern="#define	TOPO_SENSOR_STATE_FIRMWARE_\([A-Z0-9_]*\).*\$"
187replace="	{ TOPO_SENSOR_STATE_FIRMWARE_\1, \"\1\" },"
188
189cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
190
191echo "\t{ 0, NULL }
192};"
193
194echo "\ntopo_name_trans_t topo_sensor_states_event_log_table[] = {"
195
196pattern="#define	TOPO_SENSOR_STATE_EVENT_LOG_\([A-Z0-9_]*\).*\$"
197replace="	{ TOPO_SENSOR_STATE_EVENT_LOG_\1, \"\1\" },"
198
199cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
200
201echo "\t{ 0, NULL }
202};"
203
204echo "\ntopo_name_trans_t topo_sensor_states_watchdog1_table[] = {"
205
206pattern="#define	TOPO_SENSOR_STATE_WATCHDOG_\([A-Z0-9_]*\).*\$"
207replace="	{ TOPO_SENSOR_STATE_WATCHDOG_\1, \"\1\" },"
208
209cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
210
211echo "\t{ 0, NULL }
212};"
213
214echo "\ntopo_name_trans_t topo_sensor_states_system_table[] = {"
215
216pattern="#define	TOPO_SENSOR_STATE_SYSTEM_\([A-Z0-9_]*\).*\$"
217replace="	{ TOPO_SENSOR_STATE_SYSTEM_\1, \"\1\" },"
218
219cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
220
221echo "\t{ 0, NULL }
222};"
223
224echo "\ntopo_name_trans_t topo_sensor_states_critical_table[] = {"
225
226pattern="#define	TOPO_SENSOR_STATE_CRITICAL_\([A-Z0-9_]*\).*\$"
227replace="	{ TOPO_SENSOR_STATE_CRITICAL_\1, \"\1\" },"
228
229cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
230
231echo "\t{ 0, NULL }
232};"
233
234echo "\ntopo_name_trans_t topo_sensor_states_button_table[] = {"
235
236pattern="#define	TOPO_SENSOR_STATE_BUTTON_\([A-Z0-9_]*\).*\$"
237replace="	{ TOPO_SENSOR_STATE_BUTTON_\1, \"\1\" },"
238
239cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
240
241echo "\t{ 0, NULL }
242};"
243
244echo "\ntopo_name_trans_t topo_sensor_states_cable_table[] = {"
245
246pattern="#define	TOPO_SENSOR_STATE_CABLE_\([A-Z0-9_]*\).*\$"
247replace="	{ TOPO_SENSOR_STATE_CABLE_\1, \"\1\" },"
248
249cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
250
251echo "\t{ 0, NULL }
252};"
253
254echo "\ntopo_name_trans_t topo_sensor_states_boot_state_table[] = {"
255
256pattern="#define	TOPO_SENSOR_STATE_BOOT_STATE_\([A-Z0-9_]*\).*\$"
257replace="	{ TOPO_SENSOR_STATE_BOOT_STATE_\1, \"\1\" },"
258
259cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
260
261echo "\t{ 0, NULL }
262};"
263
264echo "\ntopo_name_trans_t topo_sensor_states_boot_error_table[] = {"
265
266pattern="#define	TOPO_SENSOR_STATE_BOOT_ERROR_\([A-Z0-9_]*\).*\$"
267replace="	{ TOPO_SENSOR_STATE_BOOT_ERROR_\1, \"\1\" },"
268
269cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
270
271echo "\t{ 0, NULL }
272};"
273
274echo "\ntopo_name_trans_t topo_sensor_states_boot_os_table[] = {"
275
276pattern="#define	TOPO_SENSOR_STATE_BOOT_OS_\([A-Z0-9_]*\).*\$"
277replace="	{ TOPO_SENSOR_STATE_BOOT_OS_\1, \"\1\" },"
278
279cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
280
281echo "\t{ 0, NULL }
282};"
283
284echo "\ntopo_name_trans_t topo_sensor_states_os_table[] = {"
285
286pattern="#define	TOPO_SENSOR_STATE_OS_\([A-Z0-9_]*\).*\$"
287replace="	{ TOPO_SENSOR_STATE_OS_\1, \"\1\" },"
288
289cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
290
291echo "\t{ 0, NULL }
292};"
293
294echo "\ntopo_name_trans_t topo_sensor_states_slot_table[] = {"
295
296pattern="#define	TOPO_SENSOR_STATE_SLOT_\([A-Z0-9_]*\).*\$"
297replace="	{ TOPO_SENSOR_STATE_SLOT_\1, \"\1\" },"
298
299cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
300
301echo "\t{ 0, NULL }
302};"
303
304echo "\ntopo_name_trans_t topo_sensor_states_acpi_table[] = {"
305
306pattern="#define	TOPO_SENSOR_STATE_ACPI_\([A-Z0-9_]*\).*\$"
307replace="	{ TOPO_SENSOR_STATE_ACPI_\1, \"\1\" },"
308
309cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
310
311echo "\t{ 0, NULL }
312};"
313
314echo "\ntopo_name_trans_t topo_sensor_states_watchdog2_table[] = {"
315
316pattern="#define	TOPO_SENSOR_STATE_WATCHDOG2_\([A-Z0-9_]*\).*\$"
317replace="	{ TOPO_SENSOR_STATE_WATCHDOG2_\1, \"\1\" },"
318
319cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
320
321echo "\t{ 0, NULL }
322};"
323
324echo "\ntopo_name_trans_t topo_sensor_states_alert_table[] = {"
325
326pattern="#define	TOPO_SENSOR_STATE_ALERT_\([A-Z0-9_]*\).*\$"
327replace="	{ TOPO_SENSOR_STATE_ALERT_\1, \"\1\" },"
328
329cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
330
331echo "\t{ 0, NULL }
332};"
333
334echo "\ntopo_name_trans_t topo_sensor_states_presence_table[] = {"
335
336pattern="#define	TOPO_SENSOR_STATE_PRESENCE_\([A-Z0-9_]*\).*\$"
337replace="	{ TOPO_SENSOR_STATE_PRESENCE_\1, \"\1\" },"
338
339cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
340
341echo "\t{ 0, NULL }
342};"
343
344echo "\ntopo_name_trans_t topo_sensor_states_lan_table[] = {"
345
346pattern="#define	TOPO_SENSOR_STATE_LAN_\([A-Z0-9_]*\).*\$"
347replace="	{ TOPO_SENSOR_STATE_LAN_\1, \"\1\" },"
348
349cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
350
351echo "\t{ 0, NULL }
352};"
353
354echo "\ntopo_name_trans_t topo_sensor_states_health_table[] = {"
355
356pattern="#define	TOPO_SENSOR_STATE_HEALTH_\([A-Z0-9_]*\).*\$"
357replace="	{ TOPO_SENSOR_STATE_HEALTH_\1, \"\1\" },"
358
359cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
360
361echo "\t{ 0, NULL }
362};"
363
364echo "\ntopo_name_trans_t topo_sensor_states_battery_table[] = {"
365
366pattern="#define	TOPO_SENSOR_STATE_BATTERY_\([A-Z0-9_]*\).*\$"
367replace="	{ TOPO_SENSOR_STATE_BATTERY_\1, \"\1\" },"
368
369cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
370
371echo "\t{ 0, NULL }
372};"
373
374echo "\ntopo_name_trans_t topo_sensor_states_audit_table[] = {"
375
376pattern="#define	TOPO_SENSOR_STATE_AUDIT_\([A-Z0-9_]*\).*\$"
377replace="	{ TOPO_SENSOR_STATE_AUDIT_\1, \"\1\" },"
378
379cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
380
381echo "\t{ 0, NULL }
382};"
383
384echo "\ntopo_name_trans_t topo_sensor_states_version_table[] = {"
385
386pattern="#define	TOPO_SENSOR_STATE_VERSION_\([A-Z0-9_]*\).*\$"
387replace="	{ TOPO_SENSOR_STATE_VERSION_\1, \"\1\" },"
388
389cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
390
391echo "\t{ 0, NULL }
392};"
393
394echo "\ntopo_name_trans_t topo_sensor_states_fru_state_table[] = {"
395
396pattern="#define	TOPO_SENSOR_STATE_FRU_STATE_\([A-Z0-9_]*\).*\$"
397replace="	{ TOPO_SENSOR_STATE_FRU_STATE_\1, \"\1\" },"
398
399cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
400
401echo "\t{ 0, NULL }
402};"
403
404echo "\ntopo_name_trans_t topo_sensor_states_thresh_table[] = {"
405
406pattern="#define	TOPO_SENSOR_STATE_THRESH_\([A-Z0-9_]*\).*\$"
407replace="	{ TOPO_SENSOR_STATE_THRESH_\1, \"\1\" },"
408
409cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
410
411echo "\t{ 0, NULL }
412};"
413
414echo "\ntopo_name_trans_t topo_sensor_states_generic_usage_table[] = {"
415
416pattern="#define	TOPO_SENSOR_STATE_GENERIC_USAGE_\([A-Z0-9_]*\).*\$"
417replace="	{ TOPO_SENSOR_STATE_GENERIC_USAGE_\1, \"\1\" },"
418
419cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
420
421echo "\t{ 0, NULL }
422};"
423
424echo "\ntopo_name_trans_t topo_sensor_states_generic_state_table[] = {"
425
426pattern="#define	TOPO_SENSOR_STATE_GENERIC_STATE_\([A-Z0-9_]*\).*\$"
427replace="	{ TOPO_SENSOR_STATE_GENERIC_STATE_\1, \"\1\" },"
428
429cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
430
431echo "\t{ 0, NULL }
432};"
433
434
435echo "\ntopo_name_trans_t topo_sensor_states_generic_predfail_table[] = {"
436
437pattern="#define	TOPO_SENSOR_STATE_GENERIC_PREDFAIL_\([A-Z0-9_]*\).*\$"
438replace="	{ TOPO_SENSOR_STATE_GENERIC_PREDFAIL_\1, \"\1\" },"
439
440cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
441
442echo "\t{ 0, NULL }
443};"
444
445echo "\ntopo_name_trans_t topo_sensor_states_generic_limit_table[] = {"
446
447pattern="#define	TOPO_SENSOR_STATE_GENERIC_LIMIT_\([A-Z0-9_]*\).*\$"
448replace="	{ TOPO_SENSOR_STATE_GENERIC_LIMIT_\1, \"\1\" },"
449
450cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
451
452echo "\t{ 0, NULL }
453};"
454
455echo "\ntopo_name_trans_t topo_sensor_states_generic_perf_table[] = {"
456
457pattern="#define	TOPO_SENSOR_STATE_GENERIC_PERFORMANCE_\([A-Z0-9_]*\).*\$"
458replace="	{ TOPO_SENSOR_STATE_GENERIC_PERFORMANCE_\1, \"\1\" },"
459
460cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
461
462echo "\t{ 0, NULL }
463};"
464
465echo "\ntopo_name_trans_t topo_sensor_states_severity_table[] = {"
466
467pattern="#define	TOPO_SENSOR_STATE_SEVERITY_\([A-Z0-9_]*\).*\$"
468replace="	{ TOPO_SENSOR_STATE_SEVERITY_\1, \"\1\" },"
469
470cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
471
472echo "\t{ 0, NULL }
473};"
474
475echo "\ntopo_name_trans_t topo_sensor_states_generic_presence_table[] = {"
476
477pattern="#define	TOPO_SENSOR_STATE_GENERIC_PRESENCE_\([A-Z0-9_]*\).*\$"
478replace="	{ TOPO_SENSOR_STATE_GENERIC_PRESENCE_\1, \"\1\" },"
479
480cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
481
482echo "\t{ 0, NULL }
483};"
484
485echo "\ntopo_name_trans_t topo_sensor_states_generic_avail_table[] = {"
486
487pattern="#define	TOPO_SENSOR_STATE_GENERIC_AVAILABILITY_\([A-Z0-9_]*\).*\$"
488replace="	{ TOPO_SENSOR_STATE_GENERIC_AVAILABILITY_\1, \"\1\" },"
489
490cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
491
492echo "\t{ 0, NULL }
493};"
494
495echo "\ntopo_name_trans_t topo_sensor_states_generic_status_table[] = {"
496
497pattern="#define	TOPO_SENSOR_STATE_GENERIC_STATUS_\([A-Z0-9_]*\).*\$"
498replace="	{ TOPO_SENSOR_STATE_GENERIC_STATUS_\1, \"\1\" },"
499
500cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
501
502echo "\t{ 0, NULL }
503};"
504
505echo "\ntopo_name_trans_t topo_sensor_states_generic_acpi_pwr_table[] = {"
506
507pattern="#define	TOPO_SENSOR_STATE_GENERIC_ACPI_PWR_STATE_\([A-Z0-9_]*\).*\$"
508replace="	{ TOPO_SENSOR_STATE_GENERIC_ACPI_PWR_STATE_\1, \"\1\" },"
509
510cat $libtopo_h | sed -n "s/$pattern/$replace/p" || exit 1
511
512echo "\t{ 0, NULL }
513};"
514