dmidecode-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dmidecode] [PATCH 09/10] dmidecode: Add support for structure type 43 (


From: Jean Delvare
Subject: [dmidecode] [PATCH 09/10] dmidecode: Add support for structure type 43 (TPM Device)
Date: Mon, 10 Apr 2017 11:58:11 +0200

SMBIOS 3.1.0 introduces a new structure type (43) for TPM devices.
Add support for it.

Signed-off-by: Jean Delvare <address@hidden>
---
Note 1: this is untested, as I do not have access to any system
implementing this structure.
Note 2: if someone can make any sense of the TPM_VERSION structure,
as described in the TPM part 2 v1.2 specification, please let me
know. It looks to me like the engineers in charge were drunk when
they updated that part of the TPM specification. All I can see is
that they tried to solve a problem which did not exist, and created
one instead.

 dmidecode.c |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 98 insertions(+), 3 deletions(-)

--- dmidecode.orig/dmidecode.c  2017-04-06 16:13:11.568686604 +0200
+++ dmidecode/dmidecode.c       2017-04-07 10:46:05.378964261 +0200
@@ -2,7 +2,7 @@
  * DMI Decode
  *
  *   Copyright (C) 2000-2002 Alan Cox <address@hidden>
- *   Copyright (C) 2002-2015 Jean Delvare <address@hidden>
+ *   Copyright (C) 2002-2017 Jean Delvare <address@hidden>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -50,6 +50,12 @@
  *  - DMTF DSP0239 version 1.1.0
  *    "Management Component Transport Protocol (MCTP) IDs and Codes"
  *    http://www.dmtf.org/standards/pmci
+ *  - "TPM Main, Part 2 TPM Structures"
+ *    Specification version 1.2, level 2, revision 116
+ *    https://trustedcomputinggroup.org/tpm-main-specification/
+ *  - "PC Client Platform TPM Profile (PTP) Specification"
+ *    Family "2.0", Level 00, Revision 00.43, January 26, 2015
+ *    
https://trustedcomputinggroup.org/pc-client-platform-tpm-profile-ptp-specification/
  */
 
 #include <stdio.h>
@@ -170,12 +176,13 @@ static const char *dmi_smbios_structure_
                "Power Supply",
                "Additional Information",
                "Onboard Device",
-               "Management Controller Host Interface", /* 42 */
+               "Management Controller Host Interface",
+               "TPM Device", /* 43 */
        };
 
        if (code >= 128)
                return "OEM-specific";
-       if (code <= 42)
+       if (code <= 43)
                return type[code];
        return out_of_spec;
 }
@@ -3310,6 +3317,57 @@ static const char *dmi_management_contro
 }
 
 /*
+ * 7.44 TPM Device (Type 43)
+ */
+
+static void dmi_tpm_vendor_id(const u8 *p)
+{
+       char vendor_id[5];
+       int i;
+
+       /* ASCII filtering */
+       for (i = 0; i < 4 && p[i] != 0; i++)
+       {
+               if (p[i] < 32 || p[i] >= 127)
+                       vendor_id[i] = '.';
+               else
+                       vendor_id[i] = p[i];
+       }
+
+       /* Terminate the string */
+       vendor_id[i] = '\0';
+
+       printf(" %s", vendor_id);
+}
+
+static void dmi_tpm_characteristics(u64 code, const char *prefix)
+{
+       /* 7.1.1 */
+       static const char *characteristics[] = {
+               "TPM Device characteristics not supported", /* 2 */
+               "Family configurable via firmware update",
+               "Family configurable via platform software support",
+               "Family configurable via OEM proprietary mechanism" /* 5 */
+       };
+       int i;
+
+       /*
+        * This isn't very clear what this bit is supposed to mean
+        */
+       if (code.l & (1 << 2))
+       {
+               printf("%s%s\n",
+                       prefix, characteristics[0]);
+               return;
+       }
+
+       for (i = 3; i <= 5; i++)
+               if (code.l & (1 << i))
+                       printf("%s%s\n",
+                               prefix, characteristics[i - 2]);
+}
+
+/*
  * Main
  */
 
@@ -4425,6 +4483,43 @@ static void dmi_decode(const struct dmi_
                        }
                        break;
 
+               case 43: /* 7.44 TPM Device */
+                       printf("TPM Device\n");
+                       if (h->length < 0x1B) break;
+                       printf("\tVendor ID:");
+                       dmi_tpm_vendor_id(data + 0x04);
+                       printf("\n");
+                       printf("\tSpecification Version: %d.%d", data[0x08], 
data[0x09]);
+                       switch (data[0x08])
+                       {
+                               case 0x01:
+                                       /*
+                                        * We skip the first 2 bytes, which are
+                                        * redundant with the above, and uncoded
+                                        * in a silly way.
+                                        */
+                                       printf("\tFirmware Revision: %u.%u\n",
+                                               data[0x0C], data[0x0D]);
+                                       break;
+                               case 0x02:
+                                       printf("\tFirmware Revision: %u.%u\n",
+                                               DWORD(data + 0x0A) >> 16,
+                                               DWORD(data + 0x0A) && 0xFF);
+                                       /*
+                                        * We skip the next 4 bytes, as their
+                                        * format is not standardized and their
+                                        * usefulness seems limited anyway.
+                                        */
+                                       break;
+                       }
+                       printf("\tDescription: %s", dmi_string(h, data[0x12]));
+                       printf("\tCharacteristics:\n");
+                       dmi_tpm_characteristics(QWORD(data + 0x13), "\t\t");
+                       if (h->length < 0x1F) break;
+                       printf("\tOEM-specific Information: 0x%08X\n",
+                               DWORD(data + 0x1B));
+                       break;
+
                case 126: /* 7.44 Inactive */
                        printf("Inactive\n");
                        break;

-- 
Jean Delvare
SUSE L3 Support



reply via email to

[Prev in Thread] Current Thread [Next in Thread]