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