]> git.proxmox.com Git - qemu.git/blobdiff - tpm/tpm.c
Add a TPM Passthrough backend driver implementation
[qemu.git] / tpm / tpm.c
index 02735493c59711f17eb13c565194a2c8e21ab33a..ffd24956d775ba778ea43dfc4ce737330167763a 100644 (file)
--- a/tpm/tpm.c
+++ b/tpm/tpm.c
@@ -61,6 +61,20 @@ static bool tpm_model_is_registered(enum TpmModel model)
     return false;
 }
 
+/*
+ * Write an error message in the given output buffer.
+ */
+void tpm_write_fatal_error_response(uint8_t *out, uint32_t out_len)
+{
+    if (out_len >= sizeof(struct tpm_resp_hdr)) {
+        struct tpm_resp_hdr *resp = (struct tpm_resp_hdr *)out;
+
+        resp->tag = cpu_to_be16(TPM_TAG_RSP_COMMAND);
+        resp->len = cpu_to_be32(sizeof(struct tpm_resp_hdr));
+        resp->errcode = cpu_to_be32(TPM_FAIL);
+    }
+}
+
 const TPMDriverOps *tpm_get_backend_driver(const char *type)
 {
     int i;