summaryrefslogtreecommitdiff
path: root/src/drivers/crb/tis.c
diff options
context:
space:
mode:
authorSergii Dmytruk <sergii.dmytruk@3mdeb.com>2022-12-22 19:35:25 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-12-23 21:31:11 +0000
commit4ee03170e058313477b8f0bbfc81d093a6197d98 (patch)
treec7a86dddbaa044167ac0ba7916cf4ebf76889118 /src/drivers/crb/tis.c
parent025d20eaebb4680396a7e9e558295d28f7ad0988 (diff)
Revert "security/tpm/: turn tis_{init,open} into tis_probe"
This reverts commit d43154486d27323f64334203e9bc8baf08af6845. From CB:68991: This causes CraterLake boot up process to die. Investigation in progress. Change-Id: I4a6c11b0e638a891108fe230bdaea92d5fbca020 Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/71205 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Tested-by: siemens-bot Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Diffstat (limited to 'src/drivers/crb/tis.c')
-rw-r--r--src/drivers/crb/tis.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/drivers/crb/tis.c b/src/drivers/crb/tis.c
index 0bb53c726d..a7d4fa7347 100644
--- a/src/drivers/crb/tis.c
+++ b/src/drivers/crb/tis.c
@@ -14,6 +14,8 @@
#include "tpm.h"
#include "chip.h"
+static unsigned int tpm_is_open;
+
static const struct {
uint16_t vid;
uint16_t did;
@@ -33,41 +35,50 @@ static const char *tis_get_dev_name(struct tpm2_info *info)
return "Unknown";
}
-static int crb_tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, uint8_t *recvbuf,
- size_t *rbuf_len)
+int tis_open(void)
{
- int len = tpm2_process_command(sendbuf, sbuf_size, recvbuf, *rbuf_len);
-
- if (len == 0)
+ if (tpm_is_open) {
+ printk(BIOS_ERR, "%s called twice.\n", __func__);
return -1;
+ }
- *rbuf_len = len;
+ if (CONFIG(HAVE_INTEL_PTT)) {
+ if (!ptt_active()) {
+ printk(BIOS_ERR, "%s: Intel PTT is not active.\n", __func__);
+ return -1;
+ }
+ printk(BIOS_DEBUG, "%s: Intel PTT is active.\n", __func__);
+ }
return 0;
}
-tis_sendrecv_fn tis_probe(void)
+int tis_init(void)
{
struct tpm2_info info;
- /* Wake TPM up (if necessary) */
+ // Wake TPM up (if necessary)
if (tpm2_init() != 0)
- return NULL;
+ return -1;
tpm2_get_info(&info);
printk(BIOS_INFO, "Initialized TPM device %s revision %d\n", tis_get_dev_name(&info),
info.revision);
- if (CONFIG(HAVE_INTEL_PTT)) {
- if (!ptt_active()) {
- printk(BIOS_ERR, "%s: Intel PTT is not active.\n", __func__);
- return NULL;
- }
- printk(BIOS_DEBUG, "%s: Intel PTT is active.\n", __func__);
- }
+ return 0;
+}
- return &crb_tpm_sendrecv;
+int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, uint8_t *recvbuf, size_t *rbuf_len)
+{
+ int len = tpm2_process_command(sendbuf, sbuf_size, recvbuf, *rbuf_len);
+
+ if (len == 0)
+ return -1;
+
+ *rbuf_len = len;
+
+ return 0;
}
static void crb_tpm_fill_ssdt(const struct device *dev)