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