Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 48a8132

Browse files
committed
dmidecode: Add support for structure type 43 (TPM Device)
SMBIOS 3.1.0 introduces a new structure type (43) for TPM devices. Add support for it. Signed-off-by: Jean Delvare <jdelvare@suse.de>
1 parent 1aef508 commit 48a8132

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed

‎CHANGELOG‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* dmidecode.c: Add Mini PCIe system slot enumerated values
1515
(DMI type 9).
1616
* dmidecode.c: Clarify the memory speed unit (DMI type 17).
17+
* dmidecode.c: Add support for structure type 43 (TPM Device).
1718

1819
2017年04月11日 Jean Delvare <jdelvare@suse.de>
1920

‎dmidecode.c‎

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* DMI Decode
33
*
44
* Copyright (C) 2000-2002 Alan Cox <alan@redhat.com>
5-
* Copyright (C) 2002-2015 Jean Delvare <jdelvare@suse.de>
5+
* Copyright (C) 2002-2017 Jean Delvare <jdelvare@suse.de>
66
*
77
* This program is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
@@ -50,6 +50,12 @@
5050
* - DMTF DSP0239 version 1.1.0
5151
* "Management Component Transport Protocol (MCTP) IDs and Codes"
5252
* http://www.dmtf.org/standards/pmci
53+
* - "TPM Main, Part 2 TPM Structures"
54+
* Specification version 1.2, level 2, revision 116
55+
* https://trustedcomputinggroup.org/tpm-main-specification/
56+
* - "PC Client Platform TPM Profile (PTP) Specification"
57+
* Family "2.0", Level 00, Revision 00.43, January 26, 2015
58+
* https://trustedcomputinggroup.org/pc-client-platform-tpm-profile-ptp-specification/
5359
*/
5460

5561
#include <stdio.h>
@@ -170,12 +176,13 @@ static const char *dmi_smbios_structure_type(u8 code)
170176
"Power Supply",
171177
"Additional Information",
172178
"Onboard Device",
173-
"Management Controller Host Interface", /* 42 */
179+
"Management Controller Host Interface",
180+
"TPM Device", /* 43 */
174181
};
175182

176183
if (code >= 128)
177184
return "OEM-specific";
178-
if (code <= 42)
185+
if (code <= 43)
179186
return type[code];
180187
return out_of_spec;
181188
}
@@ -3309,6 +3316,57 @@ static const char *dmi_management_controller_host_type(u8 code)
33093316
return out_of_spec;
33103317
}
33113318

3319+
/*
3320+
* 7.44 TPM Device (Type 43)
3321+
*/
3322+
3323+
static void dmi_tpm_vendor_id(const u8 *p)
3324+
{
3325+
char vendor_id[5];
3326+
int i;
3327+
3328+
/* ASCII filtering */
3329+
for (i = 0; i < 4 && p[i] != 0; i++)
3330+
{
3331+
if (p[i] < 32 || p[i] >= 127)
3332+
vendor_id[i] = '.';
3333+
else
3334+
vendor_id[i] = p[i];
3335+
}
3336+
3337+
/* Terminate the string */
3338+
vendor_id[i] = '0円';
3339+
3340+
printf(" %s", vendor_id);
3341+
}
3342+
3343+
static void dmi_tpm_characteristics(u64 code, const char *prefix)
3344+
{
3345+
/* 7.1.1 */
3346+
static const char *characteristics[] = {
3347+
"TPM Device characteristics not supported", /* 2 */
3348+
"Family configurable via firmware update",
3349+
"Family configurable via platform software support",
3350+
"Family configurable via OEM proprietary mechanism" /* 5 */
3351+
};
3352+
int i;
3353+
3354+
/*
3355+
* This isn't very clear what this bit is supposed to mean
3356+
*/
3357+
if (code.l & (1 << 2))
3358+
{
3359+
printf("%s%s\n",
3360+
prefix, characteristics[0]);
3361+
return;
3362+
}
3363+
3364+
for (i = 3; i <= 5; i++)
3365+
if (code.l & (1 << i))
3366+
printf("%s%s\n",
3367+
prefix, characteristics[i - 2]);
3368+
}
3369+
33123370
/*
33133371
* Main
33143372
*/
@@ -4425,6 +4483,43 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
44254483
}
44264484
break;
44274485

4486+
case 43: /* 7.44 TPM Device */
4487+
printf("TPM Device\n");
4488+
if (h->length < 0x1B) break;
4489+
printf("\tVendor ID:");
4490+
dmi_tpm_vendor_id(data + 0x04);
4491+
printf("\n");
4492+
printf("\tSpecification Version: %d.%d", data[0x08], data[0x09]);
4493+
switch (data[0x08])
4494+
{
4495+
case 0x01:
4496+
/*
4497+
* We skip the first 2 bytes, which are
4498+
* redundant with the above, and uncoded
4499+
* in a silly way.
4500+
*/
4501+
printf("\tFirmware Revision: %u.%u\n",
4502+
data[0x0C], data[0x0D]);
4503+
break;
4504+
case 0x02:
4505+
printf("\tFirmware Revision: %u.%u\n",
4506+
DWORD(data + 0x0A) >> 16,
4507+
DWORD(data + 0x0A) && 0xFF);
4508+
/*
4509+
* We skip the next 4 bytes, as their
4510+
* format is not standardized and their
4511+
* usefulness seems limited anyway.
4512+
*/
4513+
break;
4514+
}
4515+
printf("\tDescription: %s", dmi_string(h, data[0x12]));
4516+
printf("\tCharacteristics:\n");
4517+
dmi_tpm_characteristics(QWORD(data + 0x13), "\t\t");
4518+
if (h->length < 0x1F) break;
4519+
printf("\tOEM-specific Information: 0x%08X\n",
4520+
DWORD(data + 0x1B));
4521+
break;
4522+
44284523
case 126: /* 7.44 Inactive */
44294524
printf("Inactive\n");
44304525
break;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /