Print this page
5094 Update libsmbios with recent items
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Josef 'Jeff' Sipek<jeffpc@josefsipek.net>
Reviewed by: Garrett D'Amore <garrett@damore.org>


   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # 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 2005 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 #ident  "%Z%%M% %I%     %E% SMI"
  28 
  29 #
  30 # The SMBIOS interfaces defined in <sys/smbios.h> include a set of integer-to-
  31 # string conversion routines for the various constants defined in the SMBIOS
  32 # spec.  These functions are used by smbios(1M) and prtdiag(1M) and can be
  33 # leveraged by other clients as well.  To simplify maintenance of the source
  34 # base, this shell script automatically generates the source code for all of
  35 # these functions from the <sys/smbios.h> header file and its comments.  Each
  36 # set of constants should be given a unique #define prefix, listed in the
  37 # tables below.  The smbios_*_name() functions return the identifier of the
  38 # cpp define, and the smbios_*_desc() functions return the text of the comment.
  39 #
  40 
  41 name_funcs='
  42 SMB_BBFL_       smbios_bboard_flag_name         uint_t
  43 SMB_BIOSFL_     smbios_bios_flag_name           uint64_t
  44 SMB_BIOSXB1_    smbios_bios_xb1_name            uint_t
  45 SMB_BIOSXB2_    smbios_bios_xb2_name            uint_t
  46 SMB_CAT_        smbios_cache_ctype_name         uint_t
  47 SMB_CAF_        smbios_cache_flag_name          uint_t
  48 SMB_EVFL_       smbios_evlog_flag_name          uint_t
  49 SMB_IPMI_F_     smbios_ipmi_flag_name           uint_t
  50 SMB_MDF_        smbios_memdevice_flag_name      uint_t

  51 SMB_TYPE_       smbios_type_name                uint_t
  52 SMB_SLCH1_      smbios_slot_ch1_name            uint_t
  53 SMB_SLCH2_      smbios_slot_ch2_name            uint_t
  54 '
  55 
  56 desc_funcs='
  57 SMB_BBFL_       smbios_bboard_flag_desc         uint_t
  58 SMB_BBT_        smbios_bboard_type_desc         uint_t
  59 SMB_BIOSFL_     smbios_bios_flag_desc           uint64_t
  60 SMB_BIOSXB1_    smbios_bios_xb1_desc            uint_t
  61 SMB_BIOSXB2_    smbios_bios_xb2_desc            uint_t
  62 SMB_BOOT_       smbios_boot_desc                uint_t
  63 SMB_CAA_        smbios_cache_assoc_desc         uint_t
  64 SMB_CAT_        smbios_cache_ctype_desc         uint_t
  65 SMB_CAE_        smbios_cache_ecc_desc           uint_t
  66 SMB_CAF_        smbios_cache_flag_desc          uint_t
  67 SMB_CAL_        smbios_cache_loc_desc           uint_t
  68 SMB_CAG_        smbios_cache_logical_desc       uint_t
  69 SMB_CAM_        smbios_cache_mode_desc          uint_t
  70 SMB_CHST_       smbios_chassis_state_desc       uint_t
  71 SMB_CHT_        smbios_chassis_type_desc        uint_t
  72 SMB_EVFL_       smbios_evlog_flag_desc          uint_t
  73 SMB_EVHF_       smbios_evlog_format_desc        uint_t
  74 SMB_EVM_        smbios_evlog_method_desc        uint_t
  75 SMB_HWSEC_PS_   smbios_hwsec_desc               uint_t
  76 SMB_IPMI_F_     smbios_ipmi_flag_desc           uint_t
  77 SMB_IPMI_T_     smbios_ipmi_type_desc           uint_t
  78 SMB_MAL_        smbios_memarray_loc_desc        uint_t
  79 SMB_MAU_        smbios_memarray_use_desc        uint_t
  80 SMB_MAE_        smbios_memarray_ecc_desc        uint_t
  81 SMB_MDF_        smbios_memdevice_flag_desc      uint_t
  82 SMB_MDFF_       smbios_memdevice_form_desc      uint_t
  83 SMB_MDT_        smbios_memdevice_type_desc      uint_t

  84 SMB_POC_        smbios_port_conn_desc           uint_t
  85 SMB_POT_        smbios_port_type_desc           uint_t

  86 SMB_PRF_        smbios_processor_family_desc    uint_t
  87 SMB_PRS_        smbios_processor_status_desc    uint_t
  88 SMB_PRT_        smbios_processor_type_desc      uint_t
  89 SMB_PRU_        smbios_processor_upgrade_desc   uint_t
  90 SMB_SLCH1_      smbios_slot_ch1_desc            uint_t
  91 SMB_SLCH2_      smbios_slot_ch2_desc            uint_t
  92 SMB_SLL_        smbios_slot_length_desc         uint_t
  93 SMB_SLT_        smbios_slot_type_desc           uint_t
  94 SMB_SLU_        smbios_slot_usage_desc          uint_t
  95 SMB_SLW_        smbios_slot_width_desc          uint_t
  96 SMB_TYPE_       smbios_type_desc                uint_t
  97 SMB_WAKEUP_     smbios_system_wakeup_desc       uint_t
  98 '
  99 
 100 if [ $# -ne 1 ]; then
 101         echo "Usage: $0 file.h > file.c" >&2
 102         exit 2
 103 fi
 104 
 105 echo "\
 106 /*\n\

 107  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.\n\
 108  * Use is subject to license terms.\n\
 109  */\n\
 110 \n\
 111 #pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n\
 112 \n\
 113 #include <smbios.h>"
 114 
 115 echo "$name_funcs" | while read p name type; do
 116         [ -z "$p" ] && continue
 117         pattern="^#define[       ]\($p[A-Za-z0-9_]*\)[   ]*[A-Z0-9]*.*$"
 118         replace='       case \1: return ("\1");'
 119 
 120         echo "\nconst char *\n$name($type x)\n{\n\tswitch (x) {"
 121         sed -n "s@$pattern@$replace@p" < $1 || exit 1
 122         echo "\t}\n\treturn (NULL);\n}"
 123 done
 124 
 125 #
 126 # Generate the description functions based on the comment next to a #define.
 127 # The transformations for descriptive comments are slightly more complicated
 128 # than those used for the identifier->name functions above:
 129 #
 130 # (1) strip any [RO] suffix from the comment (a header file convention)
 131 # (2) replace any " with \" so it is escaped for the final output string
 132 # (3) replace return (...); with return ("..."); to finish the code


   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # 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 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
  25 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  26 # Use is subject to license terms.
  27 #

  28 
  29 #
  30 # The SMBIOS interfaces defined in <sys/smbios.h> include a set of integer-to-
  31 # string conversion routines for the various constants defined in the SMBIOS
  32 # spec.  These functions are used by smbios(1M) and prtdiag(1M) and can be
  33 # leveraged by other clients as well.  To simplify maintenance of the source
  34 # base, this shell script automatically generates the source code for all of
  35 # these functions from the <sys/smbios.h> header file and its comments.  Each
  36 # set of constants should be given a unique #define prefix, listed in the
  37 # tables below.  The smbios_*_name() functions return the identifier of the
  38 # cpp define, and the smbios_*_desc() functions return the text of the comment.
  39 #
  40 
  41 name_funcs='
  42 SMB_BBFL_       smbios_bboard_flag_name         uint_t
  43 SMB_BIOSFL_     smbios_bios_flag_name           uint64_t
  44 SMB_BIOSXB1_    smbios_bios_xb1_name            uint_t
  45 SMB_BIOSXB2_    smbios_bios_xb2_name            uint_t
  46 SMB_CAT_        smbios_cache_ctype_name         uint_t
  47 SMB_CAF_        smbios_cache_flag_name          uint_t
  48 SMB_EVFL_       smbios_evlog_flag_name          uint_t
  49 SMB_IPMI_F_     smbios_ipmi_flag_name           uint_t
  50 SMB_MDF_        smbios_memdevice_flag_name      uint_t
  51 SMB_PRC_        smbios_processor_core_flag_name uint_t
  52 SMB_TYPE_       smbios_type_name                uint_t
  53 SMB_SLCH1_      smbios_slot_ch1_name            uint_t
  54 SMB_SLCH2_      smbios_slot_ch2_name            uint_t
  55 '
  56 
  57 desc_funcs='
  58 SMB_BBFL_       smbios_bboard_flag_desc         uint_t
  59 SMB_BBT_        smbios_bboard_type_desc         uint_t
  60 SMB_BIOSFL_     smbios_bios_flag_desc           uint64_t
  61 SMB_BIOSXB1_    smbios_bios_xb1_desc            uint_t
  62 SMB_BIOSXB2_    smbios_bios_xb2_desc            uint_t
  63 SMB_BOOT_       smbios_boot_desc                uint_t
  64 SMB_CAA_        smbios_cache_assoc_desc         uint_t
  65 SMB_CAT_        smbios_cache_ctype_desc         uint_t
  66 SMB_CAE_        smbios_cache_ecc_desc           uint_t
  67 SMB_CAF_        smbios_cache_flag_desc          uint_t
  68 SMB_CAL_        smbios_cache_loc_desc           uint_t
  69 SMB_CAG_        smbios_cache_logical_desc       uint_t
  70 SMB_CAM_        smbios_cache_mode_desc          uint_t
  71 SMB_CHST_       smbios_chassis_state_desc       uint_t
  72 SMB_CHT_        smbios_chassis_type_desc        uint_t
  73 SMB_EVFL_       smbios_evlog_flag_desc          uint_t
  74 SMB_EVHF_       smbios_evlog_format_desc        uint_t
  75 SMB_EVM_        smbios_evlog_method_desc        uint_t
  76 SMB_HWSEC_PS_   smbios_hwsec_desc               uint_t
  77 SMB_IPMI_F_     smbios_ipmi_flag_desc           uint_t
  78 SMB_IPMI_T_     smbios_ipmi_type_desc           uint_t
  79 SMB_MAL_        smbios_memarray_loc_desc        uint_t
  80 SMB_MAU_        smbios_memarray_use_desc        uint_t
  81 SMB_MAE_        smbios_memarray_ecc_desc        uint_t
  82 SMB_MDF_        smbios_memdevice_flag_desc      uint_t
  83 SMB_MDFF_       smbios_memdevice_form_desc      uint_t
  84 SMB_MDT_        smbios_memdevice_type_desc      uint_t
  85 SMB_MDR_        smbios_memdevice_rank_desc      uint_t
  86 SMB_POC_        smbios_port_conn_desc           uint_t
  87 SMB_POT_        smbios_port_type_desc           uint_t
  88 SMB_PRC_        smbios_processor_core_flag_desc uint_t
  89 SMB_PRF_        smbios_processor_family_desc    uint_t
  90 SMB_PRS_        smbios_processor_status_desc    uint_t
  91 SMB_PRT_        smbios_processor_type_desc      uint_t
  92 SMB_PRU_        smbios_processor_upgrade_desc   uint_t
  93 SMB_SLCH1_      smbios_slot_ch1_desc            uint_t
  94 SMB_SLCH2_      smbios_slot_ch2_desc            uint_t
  95 SMB_SLL_        smbios_slot_length_desc         uint_t
  96 SMB_SLT_        smbios_slot_type_desc           uint_t
  97 SMB_SLU_        smbios_slot_usage_desc          uint_t
  98 SMB_SLW_        smbios_slot_width_desc          uint_t
  99 SMB_TYPE_       smbios_type_desc                uint_t
 100 SMB_WAKEUP_     smbios_system_wakeup_desc       uint_t
 101 '
 102 
 103 if [ $# -ne 1 ]; then
 104         echo "Usage: $0 file.h > file.c" >&2
 105         exit 2
 106 fi
 107 
 108 echo "\
 109 /*\n\
 110  * Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.\n\
 111  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.\n\
 112  * Use is subject to license terms.\n\
 113  */\n\
 114 \n\


 115 #include <smbios.h>"
 116 
 117 echo "$name_funcs" | while read p name type; do
 118         [ -z "$p" ] && continue
 119         pattern="^#define[       ]\($p[A-Za-z0-9_]*\)[   ]*[A-Z0-9]*.*$"
 120         replace='       case \1: return ("\1");'
 121 
 122         echo "\nconst char *\n$name($type x)\n{\n\tswitch (x) {"
 123         sed -n "s@$pattern@$replace@p" < $1 || exit 1
 124         echo "\t}\n\treturn (NULL);\n}"
 125 done
 126 
 127 #
 128 # Generate the description functions based on the comment next to a #define.
 129 # The transformations for descriptive comments are slightly more complicated
 130 # than those used for the identifier->name functions above:
 131 #
 132 # (1) strip any [RO] suffix from the comment (a header file convention)
 133 # (2) replace any " with \" so it is escaped for the final output string
 134 # (3) replace return (...); with return ("..."); to finish the code