From 8b5d04e1abd1d7c3b9447385b043b0d902d22a54 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Thu, 10 Nov 2016 09:49:05 -0800 Subject: lib/tlcl: Ensure tlcl library is initialized only once Since tlcl library is used other than just vboot driver, ensure that the library is initialized only once per stage. BUG=chrome-os-partner:59355 BRANCH=None TEST=Verified in recovery mode on reef, tlcl library is initialized only once in romstage. Change-Id: I6245fe9ed34f5c174341b7eea8db456b45113287 Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/17364 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel --- src/lib/tpm2_tlcl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/lib/tpm2_tlcl.c') diff --git a/src/lib/tpm2_tlcl.c b/src/lib/tpm2_tlcl.c index ecf0db6058..adc4c2e990 100644 --- a/src/lib/tpm2_tlcl.c +++ b/src/lib/tpm2_tlcl.c @@ -157,16 +157,22 @@ uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated, return TPM_SUCCESS; } +static uint8_t tlcl_init_done CAR_GLOBAL; + +/* This function is called directly by vboot, uses vboot return types. */ uint32_t tlcl_lib_init(void) { - /* - * This function is called directly by vboot, uses vboot return - * types. - */ + uint8_t done = car_get_var(tlcl_init_done); + if (done) + return VB2_SUCCESS; + if (tis_init()) return VB2_ERROR_UNKNOWN; if (tis_open()) return VB2_ERROR_UNKNOWN; + + car_set_var(tlcl_init_done, 1); + return VB2_SUCCESS; } -- cgit v1.2.3