@@ -364,7 +364,11 @@ log-base LOG-SIZE tpm-set-log-parameters
;
: vtpm-menu
- vtpm12-menu
+ tpm-get-tpm-version CASE
+ 1 OF
+ vtpm12-menu
+ ENDOF
+ ENDCASE
;
: open true ;
@@ -60,6 +60,8 @@ static struct tpm_state tpm_state;
typedef uint8_t tpm_ppi_op;
+#define TPM_version spapr_get_tpm_version()
+
/********************************************************
Extensions for TCG-enabled BIOS
*******************************************************/
@@ -926,3 +928,8 @@ void tpm_driver_set_failure_reason(uint32_t errcode)
spapr_vtpm_set_error(errcode);
}
+
+uint32_t tpm_get_tpm_version(void)
+{
+ return TPM_version;
+}
@@ -39,6 +39,7 @@ uint32_t tpm_pass_through_to_tpm(unsigned char *buf, uint32_t cmdlen);
uint32_t tpm_driver_get_state(void);
uint32_t tpm_driver_get_failure_reason(void);
void tpm_driver_set_failure_reason(uint32_t errcode);
+uint32_t tpm_get_tpm_version(void);
/* flags returned by tpm_get_state */
#define TPM_STATE_ENABLED 1
@@ -213,3 +213,13 @@ PRIM(tpm_X2d_pass_X2d_through_X2d_to_X2d_tpm)
void *buf = TOS.a;
TOS.n = tpm_pass_through_to_tpm(buf, cmdsize);
MIRP
+
+/*******************************************************************/
+/* Firmware API */
+/* SLOF: tpm-get-tpm-version ( -- tpm-version ) */
+/* LIBTPM: tpm_version = tpm_get_tpm_version() */
+/*******************************************************************/
+PRIM(tpm_X2d_get_X2d_tpm_X2d_version)
+ PUSH;
+ TOS.n = tpm_get_tpm_version();
+MIRP
@@ -32,3 +32,4 @@ cod(tpm-pass-through-to-tpm)
cod(tpm-driver-get-state)
cod(tpm-driver-get-failure-reason)
cod(tpm-driver-set-failure-reason)
+cod(tpm-get-tpm-version)
@@ -469,6 +469,11 @@ void spapr_vtpm_set_error(vtpm_drv_error errcode)
spapr_vtpm.driver_error = errcode;
}
+uint32_t spapr_get_tpm_version(void)
+{
+ return spapr_vtpm.tpm_version;
+}
+
/**** higher layer interface ****/
bool spapr_is_vtpm_present(void)
@@ -73,6 +73,10 @@ typedef enum {
/* the max. buffer size by the external TPM is 4k */
#define PAPR_VTPM_MAX_BUFFER_SIZE 4096
+/* TPM version */
+#define TPM_VERSION_1_2 1
+#define TPM_VERSION_2 2
+
/* exported functions */
bool spapr_is_vtpm_present(void);
void spapr_vtpm_finalize(void);
@@ -81,6 +85,7 @@ uint32_t spapr_vtpm_get_buffersize(void);
vtpm_drv_state spapr_vtpm_get_state(void);
vtpm_drv_error spapr_vtpm_get_error(void);
void spapr_vtpm_set_error(vtpm_drv_error errcode);
+uint32_t spapr_get_tpm_version(void);
struct tpm_req_header;
int tpmhw_transmit(uint8_t locty, struct tpm_req_header *req,
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> --- board-qemu/slof/vtpm-sml.fs | 6 +++++- lib/libtpm/tcgbios.c | 7 +++++++ lib/libtpm/tcgbios.h | 1 + lib/libtpm/tpm.code | 10 ++++++++++ lib/libtpm/tpm.in | 1 + lib/libtpm/tpm_drivers.c | 5 +++++ lib/libtpm/tpm_drivers.h | 5 +++++ 7 files changed, 34 insertions(+), 1 deletion(-)