Print this page
SKU fix for 5094
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>

Split Close
Expand all
Collapse all
          --- old/usr/src/common/smbios/smb_info.c
          +++ new/usr/src/common/smbios/smb_info.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
       23 + * Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
  23   24   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   25   * Use is subject to license terms.
  25   26   */
  26   27  
  27   28  /*
  28   29   * SMBIOS Information Routines
  29   30   *
  30   31   * The routines in this file are used to convert from the SMBIOS data format to
  31   32   * a more reasonable and stable set of structures offered as part of our ABI.
  32   33   * These functions take the general form:
↓ open down ↓ 371 lines elided ↑ open up ↑
 404  405          bbp->smbb_type = bb.smbbb_type;
 405  406          bbp->smbb_contn = bb.smbbb_cn;
 406  407  
 407  408          return (0);
 408  409  }
 409  410  
 410  411  int
 411  412  smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp)
 412  413  {
 413  414          const smb_struct_t *stp = smb_lookup_id(shp, id);
 414      -        smb_chassis_t ch;
      415 +        /* Length is measurable by one byte, so it'll be no more than 255. */
      416 +        uint8_t buf[256]
      417 +        smb_chassis_t *ch = (smb_chassis_t *)&(buf[0]);
 415  418  
 416  419          if (stp == NULL)
 417  420                  return (-1); /* errno is set for us */
 418  421  
 419  422          if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS)
 420  423                  return (smb_set_errno(shp, ESMB_TYPE));
 421  424  
 422      -        smb_info_bcopy(stp->smbst_hdr, &ch, sizeof (ch));
      425 +        smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf));
 423  426          bzero(chp, sizeof (smbios_chassis_t));
 424  427  
 425      -        chp->smbc_oemdata = ch.smbch_oemdata;
 426      -        chp->smbc_lock = (ch.smbch_type & SMB_CHT_LOCK) != 0;
 427      -        chp->smbc_type = ch.smbch_type & ~SMB_CHT_LOCK;
 428      -        chp->smbc_bustate = ch.smbch_bustate;
 429      -        chp->smbc_psstate = ch.smbch_psstate;
 430      -        chp->smbc_thstate = ch.smbch_thstate;
 431      -        chp->smbc_security = ch.smbch_security;
 432      -        chp->smbc_uheight = ch.smbch_uheight;
 433      -        chp->smbc_cords = ch.smbch_cords;
 434      -        chp->smbc_elems = ch.smbch_cn;
 435      -        chp->smbc_elemlen = ch.smbch_cm;
      428 +        chp->smbc_oemdata = ch->smbch_oemdata;
      429 +        chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0;
      430 +        chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK;
      431 +        chp->smbc_bustate = ch->smbch_bustate;
      432 +        chp->smbc_psstate = ch->smbch_psstate;
      433 +        chp->smbc_thstate = ch->smbch_thstate;
      434 +        chp->smbc_security = ch->smbch_security;
      435 +        chp->smbc_uheight = ch->smbch_uheight;
      436 +        chp->smbc_cords = ch->smbch_cords;
      437 +        chp->smbc_elems = ch->smbch_cn;
      438 +        chp->smbc_elemlen = ch->smbch_cm;
 436  439  
      440 +        if (shp->sh_smbvers >= SMB_VERSION_27) {
      441 +                (void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch),
      442 +                    sizeof (chp->smbc_sku));
      443 +        }
      444 +
 437  445          return (0);
 438  446  }
 439  447  
 440  448  int
 441  449  smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp)
 442  450  {
 443  451          const smb_struct_t *stp = smb_lookup_id(shp, id);
 444  452          smb_processor_t p;
 445  453  
 446  454          if (stp == NULL)
↓ open down ↓ 10 lines elided ↑ open up ↑
 457  465          pp->smbp_family = p.smbpr_family;
 458  466          pp->smbp_voltage = p.smbpr_voltage;
 459  467          pp->smbp_maxspeed = p.smbpr_maxspeed;
 460  468          pp->smbp_curspeed = p.smbpr_curspeed;
 461  469          pp->smbp_status = p.smbpr_status;
 462  470          pp->smbp_upgrade = p.smbpr_upgrade;
 463  471          pp->smbp_l1cache = p.smbpr_l1cache;
 464  472          pp->smbp_l2cache = p.smbpr_l2cache;
 465  473          pp->smbp_l3cache = p.smbpr_l3cache;
 466  474  
      475 +        if (shp->sh_smbvers >= SMB_VERSION_25) {
      476 +                pp->smbp_corecount = p.smbpr_corecount;
      477 +                pp->smbp_coresenabled = p.smbpr_coresenabled;
      478 +                pp->smbp_threadcount = p.smbpr_threadcount;
      479 +                pp->smbp_cflags = p.smbpr_cflags;
      480 +        }
      481 +
      482 +        if (shp->sh_smbvers >= SMB_VERSION_26)
      483 +                pp->smbp_family2 = p.smbpr_family2;
      484 +
 467  485          return (0);
 468  486  }
 469  487  
 470  488  int
 471  489  smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap)
 472  490  {
 473  491          const smb_struct_t *stp = smb_lookup_id(shp, id);
 474  492          smb_cache_t c;
 475  493  
 476  494          if (stp == NULL)
↓ open down ↓ 234 lines elided ↑ open up ↑
 711  729          bzero(map, sizeof (smbios_memarray_t));
 712  730  
 713  731          map->smbma_location = m.smbmarr_loc;
 714  732          map->smbma_use = m.smbmarr_use;
 715  733          map->smbma_ecc = m.smbmarr_ecc;
 716  734          map->smbma_ndevs = m.smbmarr_ndevs;
 717  735          map->smbma_err = m.smbmarr_err;
 718  736  
 719  737          if (m.smbmarr_cap != 0x80000000)
 720  738                  map->smbma_size = (uint64_t)m.smbmarr_cap * 1024;
      739 +        else if (m.smbmarr_extcap != 0)
      740 +                map->smbma_size = m.smbmarr_extcap;
 721  741          else
 722  742                  map->smbma_size = 0; /* unknown */
 723  743  
 724  744          return (0);
 725  745  }
 726  746  
 727  747  int
 728  748  smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map)
 729  749  {
 730  750          const smb_struct_t *stp = smb_lookup_id(shp, id);
↓ open down ↓ 3 lines elided ↑ open up ↑
 734  754                  return (-1); /* errno is set for us */
 735  755  
 736  756          if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP)
 737  757                  return (smb_set_errno(shp, ESMB_TYPE));
 738  758  
 739  759          smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
 740  760          bzero(map, sizeof (smbios_memarrmap_t));
 741  761  
 742  762          map->smbmam_array = m.smbamap_array;
 743  763          map->smbmam_width = m.smbamap_width;
 744      -        map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
 745      -        map->smbmam_size = (uint64_t)
 746      -            (m.smbamap_end - m.smbamap_start + 1) * 1024;
 747  764  
      765 +        if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) {
      766 +                map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
      767 +                map->smbmam_size = (uint64_t)
      768 +                    (m.smbamap_end - m.smbamap_start + 1) * 1024;
      769 +        } else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) {
      770 +                map->smbmam_addr = m.smbamap_extstart;
      771 +                map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1;
      772 +        }
      773 +
 748  774          return (0);
 749  775  }
 750  776  
 751  777  int
 752  778  smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp)
 753  779  {
 754  780          const smb_struct_t *stp = smb_lookup_id(shp, id);
 755  781          smb_memdevice_t m;
 756  782  
 757  783          if (stp == NULL)
↓ open down ↓ 3 lines elided ↑ open up ↑
 761  787                  return (smb_set_errno(shp, ESMB_TYPE));
 762  788  
 763  789          smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
 764  790          bzero(mdp, sizeof (smbios_memdevice_t));
 765  791  
 766  792          mdp->smbmd_array = m.smbmdev_array;
 767  793          mdp->smbmd_error = m.smbmdev_error;
 768  794          mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth;
 769  795          mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth;
 770  796  
 771      -        if (mdp->smbmd_size != 0xFFFF) {
      797 +        if (m.smbmdev_size == 0x7FFF) {
      798 +                mdp->smbmd_size = (uint64_t)m.smbmdev_extsize;
      799 +                mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */
      800 +        } else if (m.smbmdev_size != 0xFFFF) {
 772  801                  mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES);
 773  802                  if (m.smbmdev_size & SMB_MDS_KBYTES)
 774  803                          mdp->smbmd_size *= 1024;
 775  804                  else
 776  805                          mdp->smbmd_size *= 1024 * 1024;
 777  806          } else
 778  807                  mdp->smbmd_size = -1ULL; /* size unknown */
 779  808  
 780  809          mdp->smbmd_form = m.smbmdev_form;
 781  810          mdp->smbmd_set = m.smbmdev_set;
 782  811          mdp->smbmd_type = m.smbmdev_type;
      812 +        mdp->smbmd_speed = m.smbmdev_speed;
 783  813          mdp->smbmd_flags = m.smbmdev_flags;
 784  814          mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc);
 785  815          mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc);
 786  816  
 787      -        if (m.smbmdev_speed != 0)
 788      -                mdp->smbmd_speed = 1000 / m.smbmdev_speed; /* MHz -> nsec */
      817 +        if (shp->sh_smbvers >= SMB_VERSION_26)
      818 +                mdp->smbmd_rank = m.smbmdev_attrs & 0x0F;
 789  819  
      820 +        if (shp->sh_smbvers >= SMB_VERSION_27)
      821 +                mdp->smbmd_clkspeed = m.smbmdev_clkspeed;
      822 +
      823 +        if (shp->sh_smbvers >= SMB_VERSION_28) {
      824 +                mdp->smbmd_minvolt = m.smbmdev_minvolt;
      825 +                mdp->smbmd_maxvolt = m.smbmdev_maxvolt;
      826 +                mdp->smbmd_confvolt = m.smbmdev_confvolt;
      827 +        }
      828 +
 790  829          return (0);
 791  830  }
 792  831  
 793  832  int
 794  833  smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp)
 795  834  {
 796  835          const smb_struct_t *stp = smb_lookup_id(shp, id);
 797  836          smb_memdevmap_t m;
 798  837  
 799  838          if (stp == NULL)
 800  839                  return (-1); /* errno is set for us */
 801  840  
 802  841          if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP)
 803  842                  return (smb_set_errno(shp, ESMB_TYPE));
 804  843  
 805  844          smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
 806  845          bzero(mdp, sizeof (smbios_memdevmap_t));
 807  846  
 808  847          mdp->smbmdm_device = m.smbdmap_device;
 809  848          mdp->smbmdm_arrmap = m.smbdmap_array;
 810      -        mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
 811      -        mdp->smbmdm_size = (uint64_t)
 812      -            (m.smbdmap_end - m.smbdmap_start + 1) * 1024;
 813  849          mdp->smbmdm_rpos = m.smbdmap_rpos;
 814  850          mdp->smbmdm_ipos = m.smbdmap_ipos;
 815  851          mdp->smbmdm_idepth = m.smbdmap_idepth;
 816  852  
      853 +        if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) {
      854 +                mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
      855 +                mdp->smbmdm_size = (uint64_t)
      856 +                    (m.smbdmap_end - m.smbdmap_start + 1) * 1024;
      857 +        } else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) {
      858 +                mdp->smbmdm_addr = m.smbdmap_extstart;
      859 +                mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1;
      860 +        }
      861 +
 817  862          return (0);
 818  863  }
 819  864  
 820  865  id_t
 821  866  smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp)
 822  867  {
 823  868          const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY);
 824  869          smb_hwsec_t hs;
 825  870  
 826  871          if (stp == NULL)
↓ open down ↓ 299 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX