Skip to content

Commit

Permalink
fw-util: Let platforms choose to specify if they contain a TPM
Browse files Browse the repository at this point in the history
Summary:
Not every platform has a BMC with an attached TPM. Make this a platform specific configuration.
Refactor to move the registration to platform layer.

Test Plan: Build fbtp, fby2 and fbttn which actually have a TPM.

Reviewed By: williamspatrick

fbshipit-source-id: 8bd4d2592e
  • Loading branch information
amithash authored and facebook-github-bot committed Mar 3, 2020
1 parent 91b59e1 commit 2e61cd4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
33 changes: 13 additions & 20 deletions common/recipes-core/fw-util/files/tpm.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "fw-util.h"
#include "tpm.h"
#include <syslog.h>
#include <unistd.h>
#include <cstdio>
Expand Down Expand Up @@ -82,23 +82,16 @@ get_tpm_ver(char *ver) {
return 0;
}

class TpmComponent : public Component {
public:
TpmComponent(string fru, string comp)
: Component(fru, comp) {}
int print_version() {
char ver[MAX_LINE_LENGTH] = {0};

if (get_tpm_ver(ver) == FW_STATUS_SUCCESS) {
printf("TPM Version: %s", ver);
} else if (get_tpm_ver(ver) == FW_STATUS_NOT_SUPPORTED) {
printf("TPM Version: TPM Not Supported\n");
} else {
printf("TPM Version: NA\n");
}

return 0;
}
};
int TpmComponent::print_version()
{
char ver[MAX_LINE_LENGTH] = {0};

TpmComponent tpm("bmc", "tpm");
if (get_tpm_ver(ver) == FW_STATUS_SUCCESS) {
printf("TPM Version: %s", ver);
} else if (get_tpm_ver(ver) == FW_STATUS_NOT_SUPPORTED) {
printf("TPM Version: TPM Not Supported\n");
} else {
printf("TPM Version: NA\n");
}
return 0;
}
13 changes: 13 additions & 0 deletions common/recipes-core/fw-util/files/tpm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef _TPM_H_
#define _TPM_H_
#include <string>
#include "fw-util.h"

class TpmComponent : public Component {
public:
TpmComponent(std::string fru, std::string comp)
: Component(fru, comp) {}
int print_version();
};

#endif
1 change: 1 addition & 0 deletions common/recipes-core/fw-util/fw-util_0.2.bb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SRC_URI =+ "file://Makefile \
file://nic.cpp \
file://fscd.cpp \
file://tpm.cpp \
file://tpm.h \
file://bic_fw.cpp \
file://bic_fw.h \
file://bic_me.cpp \
Expand Down

0 comments on commit 2e61cd4

Please sign in to comment.