Lines Matching refs:tpm_pt
76 static void tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt, in tpm_passthrough_unix_tx_bufs() argument
85 tpm_pt->tpm_op_canceled = false; in tpm_passthrough_unix_tx_bufs()
86 tpm_pt->tpm_executing = true; in tpm_passthrough_unix_tx_bufs()
91 ret = qemu_write_full(tpm_pt->tpm_fd, in, in_len); in tpm_passthrough_unix_tx_bufs()
93 if (!tpm_pt->tpm_op_canceled || errno != ECANCELED) { in tpm_passthrough_unix_tx_bufs()
100 tpm_pt->tpm_executing = false; in tpm_passthrough_unix_tx_bufs()
102 ret = tpm_passthrough_unix_read(tpm_pt->tpm_fd, out, out_len); in tpm_passthrough_unix_tx_bufs()
104 if (!tpm_pt->tpm_op_canceled || errno != ECANCELED) { in tpm_passthrough_unix_tx_bufs()
124 tpm_pt->tpm_executing = false; in tpm_passthrough_unix_tx_bufs()
130 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); in tpm_passthrough_handle_request() local
134 tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len, in tpm_passthrough_handle_request()
160 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); in tpm_passthrough_cancel_cmd() local
169 if (tpm_pt->tpm_executing) { in tpm_passthrough_cancel_cmd()
170 if (tpm_pt->cancel_fd >= 0) { in tpm_passthrough_cancel_cmd()
171 tpm_pt->tpm_op_canceled = true; in tpm_passthrough_cancel_cmd()
172 n = write(tpm_pt->cancel_fd, "-", 1); in tpm_passthrough_cancel_cmd()
186 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); in tpm_passthrough_get_tpm_version() local
188 return tpm_pt->tpm_version; in tpm_passthrough_get_tpm_version()
193 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); in tpm_passthrough_get_buffer_size() local
196 ret = tpm_util_get_buffer_size(tpm_pt->tpm_fd, tpm_pt->tpm_version, in tpm_passthrough_get_buffer_size()
197 &tpm_pt->tpm_buffersize); in tpm_passthrough_get_buffer_size()
199 tpm_pt->tpm_buffersize = 4096; in tpm_passthrough_get_buffer_size()
201 return tpm_pt->tpm_buffersize; in tpm_passthrough_get_buffer_size()
211 static int tpm_passthrough_open_sysfs_cancel(TPMPassthruState *tpm_pt) in tpm_passthrough_open_sysfs_cancel() argument
217 if (tpm_pt->options->cancel_path) { in tpm_passthrough_open_sysfs_cancel()
218 fd = qemu_open_old(tpm_pt->options->cancel_path, O_WRONLY); in tpm_passthrough_open_sysfs_cancel()
226 dev = strrchr(tpm_pt->tpm_dev, '/'); in tpm_passthrough_open_sysfs_cancel()
229 tpm_pt->tpm_dev); in tpm_passthrough_open_sysfs_cancel()
248 tpm_pt->options->cancel_path = g_strdup(path); in tpm_passthrough_open_sysfs_cancel()
255 tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, QemuOpts *opts) in tpm_passthrough_handle_device_opts() argument
261 tpm_pt->options->cancel_path = g_strdup(value); in tpm_passthrough_handle_device_opts()
266 tpm_pt->options->path = g_strdup(value); in tpm_passthrough_handle_device_opts()
269 tpm_pt->tpm_dev = value ? value : TPM_PASSTHROUGH_DEFAULT_DEVICE; in tpm_passthrough_handle_device_opts()
270 tpm_pt->tpm_fd = qemu_open_old(tpm_pt->tpm_dev, O_RDWR); in tpm_passthrough_handle_device_opts()
271 if (tpm_pt->tpm_fd < 0) { in tpm_passthrough_handle_device_opts()
273 tpm_pt->tpm_dev, strerror(errno)); in tpm_passthrough_handle_device_opts()
277 if (tpm_util_test_tpmdev(tpm_pt->tpm_fd, &tpm_pt->tpm_version)) { in tpm_passthrough_handle_device_opts()
279 tpm_pt->tpm_dev); in tpm_passthrough_handle_device_opts()
283 tpm_pt->cancel_fd = tpm_passthrough_open_sysfs_cancel(tpm_pt); in tpm_passthrough_handle_device_opts()
284 if (tpm_pt->cancel_fd < 0) { in tpm_passthrough_handle_device_opts()
305 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); in tpm_passthrough_startup_tpm() local
307 if (buffersize && buffersize < tpm_pt->tpm_buffersize) { in tpm_passthrough_startup_tpm()
310 buffersize, tpm_pt->tpm_buffersize); in tpm_passthrough_startup_tpm()
345 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj); in tpm_passthrough_inst_init() local
347 tpm_pt->options = g_new0(TPMPassthroughOptions, 1); in tpm_passthrough_inst_init()
348 tpm_pt->tpm_fd = -1; in tpm_passthrough_inst_init()
349 tpm_pt->cancel_fd = -1; in tpm_passthrough_inst_init()
354 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj); in tpm_passthrough_inst_finalize() local
358 if (tpm_pt->tpm_fd >= 0) { in tpm_passthrough_inst_finalize()
359 qemu_close(tpm_pt->tpm_fd); in tpm_passthrough_inst_finalize()
361 if (tpm_pt->cancel_fd >= 0) { in tpm_passthrough_inst_finalize()
362 qemu_close(tpm_pt->cancel_fd); in tpm_passthrough_inst_finalize()
364 qapi_free_TPMPassthroughOptions(tpm_pt->options); in tpm_passthrough_inst_finalize()