hw/ppc: Introduce functions for conversion between timebase and nanoseconds
[qemu/kevin.git] / softmmu / tpm-hmp-cmds.c
blob9ed6ad6c4d462514aa17c67b3f99b164cb7e73e2
1 /*
2 * HMP commands related to TPM
4 * This work is licensed under the terms of the GNU GPL, version 2 or
5 * (at your option) any later version.
6 */
8 #include "qemu/osdep.h"
9 #include "qapi/qapi-commands-tpm.h"
10 #include "monitor/monitor.h"
11 #include "monitor/hmp.h"
12 #include "qapi/error.h"
14 void hmp_info_tpm(Monitor *mon, const QDict *qdict)
16 #ifdef CONFIG_TPM
17 TPMInfoList *info_list, *info;
18 Error *err = NULL;
19 unsigned int c = 0;
20 TPMPassthroughOptions *tpo;
21 TPMEmulatorOptions *teo;
23 info_list = qmp_query_tpm(&err);
24 if (err) {
25 monitor_printf(mon, "TPM device not supported\n");
26 error_free(err);
27 return;
30 if (info_list) {
31 monitor_printf(mon, "TPM device:\n");
34 for (info = info_list; info; info = info->next) {
35 TPMInfo *ti = info->value;
36 monitor_printf(mon, " tpm%d: model=%s\n",
37 c, TpmModel_str(ti->model));
39 monitor_printf(mon, " \\ %s: type=%s",
40 ti->id, TpmType_str(ti->options->type));
42 switch (ti->options->type) {
43 case TPM_TYPE_PASSTHROUGH:
44 tpo = ti->options->u.passthrough.data;
45 monitor_printf(mon, "%s%s%s%s",
46 tpo->path ? ",path=" : "",
47 tpo->path ?: "",
48 tpo->cancel_path ? ",cancel-path=" : "",
49 tpo->cancel_path ?: "");
50 break;
51 case TPM_TYPE_EMULATOR:
52 teo = ti->options->u.emulator.data;
53 monitor_printf(mon, ",chardev=%s", teo->chardev);
54 break;
55 case TPM_TYPE__MAX:
56 break;
58 monitor_printf(mon, "\n");
59 c++;
61 qapi_free_TPMInfoList(info_list);
62 #else
63 monitor_printf(mon, "TPM device not supported\n");
64 #endif /* CONFIG_TPM */