@@ -20,6 +20,8 @@ false VALUE vtpm-debug?
0 VALUE log-base
40000 CONSTANT LOG-SIZE \ 256k per VTPM FW spec.
+e CONSTANT VTPM_DRV_ERROR_SML_HANDED_OVER
+
LOG-SIZE BUFFER: log-base
\ create /ibm,vtpm
@@ -50,6 +52,8 @@ log-base LOG-SIZE tpm-set-log-parameters
log-base ( dest size src )
-rot ( src dest size )
move
+
+ VTPM_DRV_ERROR_SML_HANDED_OVER tpm-driver-set-failure-reason
;
: get-state ( -- state )
@@ -914,3 +914,15 @@ uint32_t tpm_driver_get_failure_reason(void)
return spapr_vtpm_get_error();
}
+
+/*
+ * tpm_driver_set_failure_reason: Function for interfacing with the firmware
+ * API
+ */
+void tpm_driver_set_failure_reason(uint32_t errcode)
+{
+ if (!tpm_state.tpm_found)
+ return;
+
+ spapr_vtpm_set_error(errcode);
+}
@@ -38,6 +38,7 @@ uint32_t tpm_get_maximum_cmd_size(void);
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);
/* flags returned by tpm_get_state */
#define TPM_STATE_ENABLED 1
@@ -97,6 +97,16 @@ PRIM(tpm_X2d_driver_X2d_get_X2d_failure_X2d_reason)
TOS.n = tpm_driver_get_failure_reason();
MIRP
+/********************************************************/
+/* Firmware API */
+/* SLOF: tpm-driver-set-failure_reason ( errcode -- ) */
+/* LIBTPM: tpm_driver_set_failure_reason(errcode) */
+/********************************************************/
+PRIM(tpm_X2d_driver_X2d_set_X2d_failure_X2d_reason)
+ int errcode = TOS.u; POP;
+ tpm_driver_set_failure_reason(errcode);
+MIRP
+
/*****************************************************************/
/* Firmware API */
/* SLOF: tpm-hash-all ( data-ptr data-len hash-ptr -- errcode) */
@@ -31,3 +31,4 @@ cod(tpm-get-maximum-cmd-size)
cod(tpm-pass-through-to-tpm)
cod(tpm-driver-get-state)
cod(tpm-driver-get-failure-reason)
+cod(tpm-driver-set-failure-reason)
@@ -464,6 +464,11 @@ vtpm_drv_error spapr_vtpm_get_error(void)
return vtpm_drv_error_get();
}
+void spapr_vtpm_set_error(vtpm_drv_error errcode)
+{
+ spapr_vtpm.driver_error = errcode;
+}
+
/**** higher layer interface ****/
bool spapr_is_vtpm_present(void)
@@ -80,6 +80,7 @@ void spapr_vtpm_set_durations(const uint32_t durations[TPM_NUM_DURATIONS]);
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);
struct tpm_req_header;
int tpmhw_transmit(uint8_t locty, struct tpm_req_header *req,