Implement a function to translate TPM error codes to strings so that
at least the most common error codes can be translated to human
readable strings.
Signed-off-by: Stefan Berger <address@hidden>
---
hw/tpm/tpm_emulator.c | 50 ++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 10 deletions(-)
diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
index 1288cbcb8d..186dde0838 100644
--- a/hw/tpm/tpm_emulator.c
+++ b/hw/tpm/tpm_emulator.c
@@ -82,6 +82,30 @@ typedef struct TPMEmulator {
TPMBlobBuffers state_blobs;
} TPMEmulator;
+struct tpm_error {
+ uint32_t tpm_result;
+ const char *string;
+};
+
+static const struct tpm_error tpm_errors[] = {
+ { 9 , "operation failed" },
+ { 32, "encryption error" },
+ { 33, "decryption error" },
+ /* TPM 2 codes */
+ { 0x101, "operation failed" },
+};