From 349ccdc89c1b76f6cdd9f8cdc412f0d806046d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:44 +0200 Subject: tpm: make tpm_get_backend_driver() static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to export the function. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 2c798a1eb4..c6e5637f68 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -215,7 +215,6 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s); TPMBackend *qemu_find_tpm(const char *id); -const TPMDriverOps *tpm_get_backend_driver(const char *type); void tpm_register_model(enum TpmModel model); void tpm_register_driver(const TPMDriverOps *tdo); -- cgit v1.2.3 From ed836d9d6bf0c89bf2e43e300fd2254237a39ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:47 +0200 Subject: tpm: remove tpm_register_driver() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No more users of be_drivers[], drop that too. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index c6e5637f68..adb6a68076 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -216,6 +216,5 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s); TPMBackend *qemu_find_tpm(const char *id); void tpm_register_model(enum TpmModel model); -void tpm_register_driver(const TPMDriverOps *tdo); #endif -- cgit v1.2.3 From cfab6da8a7d3e9d825ea284a0ebbf6579e204f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:48 +0200 Subject: tpm: move TPMSizedBuffer to tpm_tis.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close to where it's being used. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index adb6a68076..63093551a1 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -66,11 +66,6 @@ struct TPMBackendClass { void (*handle_request)(TPMBackend *s, TPMBackendCmd cmd); }; -typedef struct TPMSizedBuffer { - uint32_t size; - uint8_t *buffer; -} TPMSizedBuffer; - struct TPMDriverOps { enum TpmType type; const QemuOptDesc *opts; -- cgit v1.2.3 From d31076ba75d4239928282143efd30d08730c8845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:49 +0200 Subject: tpm: remove TPMDriverOps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use TPMBackendClass to hold class methods/fields. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 63093551a1..a4288df038 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -29,7 +29,7 @@ typedef struct TPMBackendClass TPMBackendClass; typedef struct TPMBackend TPMBackend; -typedef struct TPMDriverOps TPMDriverOps; + typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty, bool selftest_done); typedef enum TPMBackendCmd { @@ -59,14 +59,6 @@ struct TPMBackend { struct TPMBackendClass { ObjectClass parent_class; - const TPMDriverOps *ops; - - void (*opened)(TPMBackend *s, Error **errp); - - void (*handle_request)(TPMBackend *s, TPMBackendCmd cmd); -}; - -struct TPMDriverOps { enum TpmType type; const QemuOptDesc *opts; /* get a descriptive text of the backend to display to the user */ @@ -90,8 +82,11 @@ struct TPMDriverOps { TPMVersion (*get_tpm_version)(TPMBackend *t); TpmTypeOptions *(*get_tpm_options)(TPMBackend *t); -}; + void (*opened)(TPMBackend *s, Error **errp); + + void (*handle_request)(TPMBackend *s, TPMBackendCmd cmd); +}; /** * tpm_backend_get_type: -- cgit v1.2.3 From 27a79d96b42a819122c83745a5d837c9664ba915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:50 +0200 Subject: tpm: remove init() class method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No backend use it. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index a4288df038..b08f985500 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -66,8 +66,6 @@ struct TPMBackendClass { TPMBackend *(*create)(QemuOpts *opts, const char *id); - /* initialize the backend */ - int (*init)(TPMBackend *t); /* start up the TPM on the backend */ int (*startup_tpm)(TPMBackend *t); -- cgit v1.2.3 From 905e78ba25c613a9daa7adb4e8fb3aec0fa4a2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:52 +0200 Subject: tpm: remove unused TPMBackendCmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is only handling of request so far in both backends. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index b08f985500..7d7ebfc21d 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -32,13 +32,6 @@ typedef struct TPMBackend TPMBackend; typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty, bool selftest_done); -typedef enum TPMBackendCmd { - TPM_BACKEND_CMD_INIT = 1, - TPM_BACKEND_CMD_PROCESS_CMD, - TPM_BACKEND_CMD_END, - TPM_BACKEND_CMD_TPM_RESET, -} TPMBackendCmd; - struct TPMBackend { Object parent; @@ -83,7 +76,7 @@ struct TPMBackendClass { void (*opened)(TPMBackend *s, Error **errp); - void (*handle_request)(TPMBackend *s, TPMBackendCmd cmd); + void (*handle_request)(TPMBackend *s); }; /** -- cgit v1.2.3 From d1fd6b563d44a1132f8a5758f8f7bafba548502c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:54 +0200 Subject: tpm: remove locty argument from receive_cb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tpm_state is passed as argument, the assert() is pointless since we give it the value of tpm_state->locty_number already. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 7d7ebfc21d..9c83a512e1 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -30,7 +30,7 @@ typedef struct TPMBackendClass TPMBackendClass; typedef struct TPMBackend TPMBackend; -typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty, bool selftest_done); +typedef void (TPMRecvDataCB)(TPMState *, bool selftest_done); struct TPMBackend { Object parent; -- cgit v1.2.3 From 0e43b7e61ce677e154584523943c1651779baccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:55 +0200 Subject: tpm: add TPMBackendCmd to hold the request state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simplifies a bit locality handling, and argument passing, and could pave the way to queuing requests (if that makes sense). Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 9c83a512e1..3bb90be3de 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -30,7 +30,16 @@ typedef struct TPMBackendClass TPMBackendClass; typedef struct TPMBackend TPMBackend; -typedef void (TPMRecvDataCB)(TPMState *, bool selftest_done); +typedef void (TPMRecvDataCB)(TPMState *); + +typedef struct TPMBackendCmd { + uint8_t locty; + const uint8_t *in; + uint32_t in_len; + uint8_t *out; + uint32_t out_len; + bool selftest_done; +} TPMBackendCmd; struct TPMBackend { Object parent; @@ -76,7 +85,7 @@ struct TPMBackendClass { void (*opened)(TPMBackend *s, Error **errp); - void (*handle_request)(TPMBackend *s); + void (*handle_request)(TPMBackend *s, TPMBackendCmd *cmd); }; /** @@ -121,11 +130,12 @@ bool tpm_backend_had_startup_error(TPMBackend *s); /** * tpm_backend_deliver_request: * @s: the backend to send the request to + * @cmd: the command to deliver * * Send a request to the backend. The backend will then send the request * to the TPM implementation. */ -void tpm_backend_deliver_request(TPMBackend *s); +void tpm_backend_deliver_request(TPMBackend *s, TPMBackendCmd *cmd); /** * tpm_backend_reset: -- cgit v1.2.3 From 05a699985c001927a50f8f276251f2af1e0c5b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:56:02 +0200 Subject: tpm: move recv_data_callback to TPM interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the TPM backend setup, move callback to TPM interface. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- include/sysemu/tpm_backend.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include') diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 3bb90be3de..03ea5a3400 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -30,8 +30,6 @@ typedef struct TPMBackendClass TPMBackendClass; typedef struct TPMBackend TPMBackend; -typedef void (TPMRecvDataCB)(TPMState *); - typedef struct TPMBackendCmd { uint8_t locty; const uint8_t *in; @@ -48,7 +46,6 @@ struct TPMBackend { bool opened; TPMState *tpm_state; GThreadPool *thread_pool; - TPMRecvDataCB *recv_data_callback; bool had_startup_error; /* */ @@ -106,8 +103,7 @@ enum TpmType tpm_backend_get_type(TPMBackend *s); * * Returns 0 on success. */ -int tpm_backend_init(TPMBackend *s, TPMState *state, - TPMRecvDataCB *datacb); +int tpm_backend_init(TPMBackend *s, TPMState *state); /** * tpm_backend_startup_tpm: -- cgit v1.2.3