// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (c) 2013 The Chromium OS Authors.
 */

#include <command.h>
#include <env.h>
#include <malloc.h>
#include <vsprintf.h>
#include <asm/unaligned.h>
#include <tpm-common.h>
#include <tpm-v1.h>
#include "tpm-user-utils.h"
#include <tpm_api.h>

static int do_tpm_startup(struct cmd_tbl *cmdtp, int flag, int argc,
			  char *const argv[])
{
	enum tpm_startup_type mode;
	struct udevice *dev;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;
	if (argc != 2)
		return CMD_RET_USAGE;
	if (!strcasecmp("TPM_ST_CLEAR", argv[1])) {
		mode = TPM_ST_CLEAR;
	} else if (!strcasecmp("TPM_ST_STATE", argv[1])) {
		mode = TPM_ST_STATE;
	} else if (!strcasecmp("TPM_ST_DEACTIVATED", argv[1])) {
		mode = TPM_ST_DEACTIVATED;
	} else {
		printf("Couldn't recognize mode string: %s\n", argv[1]);
		return CMD_RET_FAILURE;
	}

	return report_return_code(tpm_startup(dev, mode));
}

static int do_tpm_nv_define_space(struct cmd_tbl *cmdtp, int flag, int argc,
				  char *const argv[])
{
	u32 index, perm, size;
	struct udevice *dev;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 4)
		return CMD_RET_USAGE;
	index = simple_strtoul(argv[1], NULL, 0);
	perm = simple_strtoul(argv[2], NULL, 0);
	size = simple_strtoul(argv[3], NULL, 0);

	return report_return_code(tpm1_nv_define_space(dev, index, perm, size));
}

static int do_tpm_nv_read_value(struct cmd_tbl *cmdtp, int flag, int argc,
				char *const argv[])
{
	u32 index, count, rc;
	struct udevice *dev;
	void *data;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 4)
		return CMD_RET_USAGE;
	index = simple_strtoul(argv[1], NULL, 0);
	data = (void *)simple_strtoul(argv[2], NULL, 0);
	count = simple_strtoul(argv[3], NULL, 0);

	rc = tpm_nv_read_value(dev, index, data, count);
	if (!rc) {
		puts("area content:\n");
		print_byte_string(data, count);
	}

	return report_return_code(rc);
}

static int do_tpm_nv_write_value(struct cmd_tbl *cmdtp, int flag, int argc,
				 char *const argv[])
{
	struct udevice *dev;
	u32 index, rc;
	size_t count;
	void *data;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 3)
		return CMD_RET_USAGE;
	index = simple_strtoul(argv[1], NULL, 0);
	data = parse_byte_string(argv[2], NULL, &count);
	if (!data) {
		printf("Couldn't parse byte string %s\n", argv[2]);
		return CMD_RET_FAILURE;
	}

	rc = tpm_nv_write_value(dev, index, data, count);
	free(data);

	return report_return_code(rc);
}

static int do_tpm_extend(struct cmd_tbl *cmdtp, int flag, int argc,
			 char *const argv[])
{
	u8 in_digest[20], out_digest[20];
	struct udevice *dev;
	u32 index, rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 3)
		return CMD_RET_USAGE;
	index = simple_strtoul(argv[1], NULL, 0);
	if (!parse_byte_string(argv[2], in_digest, NULL)) {
		printf("Couldn't parse byte string %s\n", argv[2]);
		return CMD_RET_FAILURE;
	}

	rc = tpm_pcr_extend(dev, index, in_digest, sizeof(in_digest),
			    out_digest, "cmd");
	if (!rc) {
		puts("PCR value after execution of the command:\n");
		print_byte_string(out_digest, sizeof(out_digest));
	}

	return report_return_code(rc);
}

static int do_tpm_pcr_read(struct cmd_tbl *cmdtp, int flag, int argc,
			   char *const argv[])
{
	u32 index, count, rc;
	struct udevice *dev;
	void *data;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 4)
		return CMD_RET_USAGE;
	index = simple_strtoul(argv[1], NULL, 0);
	data = (void *)simple_strtoul(argv[2], NULL, 0);
	count = simple_strtoul(argv[3], NULL, 0);

	rc = tpm_pcr_read(dev, index, data, count);
	if (!rc) {
		puts("Named PCR content:\n");
		print_byte_string(data, count);
	}

	return report_return_code(rc);
}

static int do_tpm_tsc_physical_presence(struct cmd_tbl *cmdtp, int flag,
					int argc, char *const argv[])
{
	struct udevice *dev;
	u16 presence;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 2)
		return CMD_RET_USAGE;
	presence = (u16)simple_strtoul(argv[1], NULL, 0);

	return report_return_code(tpm_tsc_physical_presence(dev, presence));
}

static int do_tpm_read_pubek(struct cmd_tbl *cmdtp, int flag, int argc,
			     char *const argv[])
{
	struct udevice *dev;
	u32 count, rc;
	void *data;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 3)
		return CMD_RET_USAGE;
	data = (void *)simple_strtoul(argv[1], NULL, 0);
	count = simple_strtoul(argv[2], NULL, 0);

	rc = tpm_read_pubek(dev, data, count);
	if (!rc) {
		puts("pubek value:\n");
		print_byte_string(data, count);
	}

	return report_return_code(rc);
}

static int do_tpm_physical_set_deactivated(struct cmd_tbl *cmdtp, int flag,
					   int argc, char *const argv[])
{
	struct udevice *dev;
	u8 state;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 2)
		return CMD_RET_USAGE;
	state = (u8)simple_strtoul(argv[1], NULL, 0);

	return report_return_code(tpm_physical_set_deactivated(dev, state));
}

static int do_tpm_get_capability(struct cmd_tbl *cmdtp, int flag, int argc,
				 char *const argv[])
{
	u32 cap_area, sub_cap, rc;
	void *cap;
	size_t count;
	struct udevice *dev;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 5)
		return CMD_RET_USAGE;
	cap_area = simple_strtoul(argv[1], NULL, 0);
	sub_cap = simple_strtoul(argv[2], NULL, 0);
	cap = (void *)simple_strtoul(argv[3], NULL, 0);
	count = simple_strtoul(argv[4], NULL, 0);

	rc = tpm_get_capability(dev, cap_area, sub_cap, cap, count);
	if (!rc) {
		puts("capability information:\n");
		print_byte_string(cap, count);
	}

	return report_return_code(rc);
}

static int do_tpm_raw_transfer(struct cmd_tbl *cmdtp, int flag, int argc,
			       char *const argv[])
{
	struct udevice *dev;
	void *command;
	u8 response[1024];
	size_t count, response_length = sizeof(response);
	u32 rc;

	command = parse_byte_string(argv[1], NULL, &count);
	if (!command) {
		printf("Couldn't parse byte string %s\n", argv[1]);
		return CMD_RET_FAILURE;
	}

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	rc = tpm_xfer(dev, command, count, response, &response_length);
	free(command);
	if (!rc) {
		puts("tpm response:\n");
		print_byte_string(response, response_length);
	}

	return report_return_code(rc);
}

static int do_tpm_nv_define(struct cmd_tbl *cmdtp, int flag, int argc,
			    char *const argv[])
{
	u32 index, perm, size;
	struct udevice *dev;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 4)
		return CMD_RET_USAGE;
	size = type_string_get_space_size(argv[1]);
	if (!size) {
		printf("Couldn't parse arguments\n");
		return CMD_RET_USAGE;
	}
	index = simple_strtoul(argv[2], NULL, 0);
	perm = simple_strtoul(argv[3], NULL, 0);

	return report_return_code(tpm1_nv_define_space(dev, index, perm, size));
}

static int do_tpm_nv_read(struct cmd_tbl *cmdtp, int flag, int argc,
			  char *const argv[])
{
	u32 index, count, err;
	struct udevice *dev;
	void *data;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc < 3)
		return CMD_RET_USAGE;
	if (argc != 3 + type_string_get_num_values(argv[1]))
		return CMD_RET_USAGE;
	index = simple_strtoul(argv[2], NULL, 0);
	data = type_string_alloc(argv[1], &count);
	if (!data) {
		printf("Couldn't parse arguments\n");
		return CMD_RET_USAGE;
	}

	err = tpm_nv_read_value(dev, index, data, count);
	if (!err) {
		if (type_string_write_vars(argv[1], data, argv + 3)) {
			printf("Couldn't write to variables\n");
			err = ~0;
		}
	}
	free(data);

	return report_return_code(err);
}

static int do_tpm_nv_write(struct cmd_tbl *cmdtp, int flag, int argc,
			   char *const argv[])
{
	u32 index, count, err;
	struct udevice *dev;
	void *data;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc < 3)
		return CMD_RET_USAGE;
	if (argc != 3 + type_string_get_num_values(argv[1]))
		return CMD_RET_USAGE;
	index = simple_strtoul(argv[2], NULL, 0);
	data = type_string_alloc(argv[1], &count);
	if (!data) {
		printf("Couldn't parse arguments\n");
		return CMD_RET_USAGE;
	}
	if (type_string_pack(argv[1], argv + 3, data)) {
		printf("Couldn't parse arguments\n");
		free(data);
		return CMD_RET_USAGE;
	}

	err = tpm_nv_write_value(dev, index, data, count);
	free(data);

	return report_return_code(err);
}

#ifdef CONFIG_TPM_AUTH_SESSIONS

static int do_tpm_oiap(struct cmd_tbl *cmdtp, int flag, int argc,
		       char *const argv[])
{
	u32 auth_handle, err;
	struct udevice *dev;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	err = tpm1_oiap(dev, &auth_handle);

	return report_return_code(err);
}

#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc,
				   char *const argv[])
{
	u32 parent_handle = 0;
	u32 key_len, key_handle, err;
	u8 usage_auth[DIGEST_LENGTH];
	u8 parent_hash[DIGEST_LENGTH];
	void *key;
	struct udevice *dev;

	err = get_tpm(&dev);
	if (err)
		return err;

	if (argc < 5)
		return CMD_RET_USAGE;

	parse_byte_string(argv[1], parent_hash, NULL);
	key = (void *)simple_strtoul(argv[2], NULL, 0);
	key_len = simple_strtoul(argv[3], NULL, 0);
	if (strlen(argv[4]) != 2 * DIGEST_LENGTH)
		return CMD_RET_FAILURE;
	parse_byte_string(argv[4], usage_auth, NULL);

	err = tpm1_find_key_sha1(dev, usage_auth, parent_hash, &parent_handle);
	if (err) {
		printf("Could not find matching parent key (err = %d)\n", err);
		return CMD_RET_FAILURE;
	}

	printf("Found parent key %08x\n", parent_handle);

	err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth,
				 &key_handle);
	if (!err) {
		printf("Key handle is 0x%x\n", key_handle);
		env_set_hex("key_handle", key_handle);
	}

	return report_return_code(err);
}
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */

static int do_tpm_load_key2_oiap(struct cmd_tbl *cmdtp, int flag, int argc,
				 char *const argv[])
{
	u32 parent_handle, key_len, key_handle, err;
	u8 usage_auth[DIGEST_LENGTH];
	void *key;
	struct udevice *dev;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc < 5)
		return CMD_RET_USAGE;

	parent_handle = simple_strtoul(argv[1], NULL, 0);
	key = (void *)simple_strtoul(argv[2], NULL, 0);
	key_len = simple_strtoul(argv[3], NULL, 0);
	if (strlen(argv[4]) != 2 * DIGEST_LENGTH)
		return CMD_RET_FAILURE;
	parse_byte_string(argv[4], usage_auth, NULL);

	err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth,
				  &key_handle);
	if (!err)
		printf("Key handle is 0x%x\n", key_handle);

	return report_return_code(err);
}

static int do_tpm_get_pub_key_oiap(struct cmd_tbl *cmdtp, int flag, int argc,
				   char *const argv[])
{
	u32 key_handle, err;
	u8 usage_auth[DIGEST_LENGTH];
	u8 pub_key_buffer[TPM_PUBKEY_MAX_LENGTH];
	size_t pub_key_len = sizeof(pub_key_buffer);
	struct udevice *dev;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc < 3)
		return CMD_RET_USAGE;

	key_handle = simple_strtoul(argv[1], NULL, 0);
	if (strlen(argv[2]) != 2 * DIGEST_LENGTH)
		return CMD_RET_FAILURE;
	parse_byte_string(argv[2], usage_auth, NULL);

	err = tpm1_get_pub_key_oiap(dev, key_handle, usage_auth, pub_key_buffer,
				    &pub_key_len);
	if (!err) {
		printf("dump of received pub key structure:\n");
		print_byte_string(pub_key_buffer, pub_key_len);
	}
	return report_return_code(err);
}

TPM_COMMAND_NO_ARG(tpm1_end_oiap)

#endif /* CONFIG_TPM_AUTH_SESSIONS */

#ifdef CONFIG_TPM_FLUSH_RESOURCES
static int do_tpm_flush(struct cmd_tbl *cmdtp, int flag, int argc,
			char *const argv[])
{
	struct udevice *dev;
	int type = 0;
	int rc;

	rc = get_tpm(&dev);
	if (rc)
		return rc;

	if (argc != 3)
		return CMD_RET_USAGE;

	if (!strcasecmp(argv[1], "key"))
		type = TPM_RT_KEY;
	else if (!strcasecmp(argv[1], "auth"))
		type = TPM_RT_AUTH;
	else if (!strcasecmp(argv[1], "hash"))
		type = TPM_RT_HASH;
	else if (!strcasecmp(argv[1], "trans"))
		type = TPM_RT_TRANS;
	else if (!strcasecmp(argv[1], "context"))
		type = TPM_RT_CONTEXT;
	else if (!strcasecmp(argv[1], "counter"))
		type = TPM_RT_COUNTER;
	else if (!strcasecmp(argv[1], "delegate"))
		type = TPM_RT_DELEGATE;
	else if (!strcasecmp(argv[1], "daa_tpm"))
		type = TPM_RT_DAA_TPM;
	else if (!strcasecmp(argv[1], "daa_v0"))
		type = TPM_RT_DAA_V0;
	else if (!strcasecmp(argv[1], "daa_v1"))
		type = TPM_RT_DAA_V1;

	if (!type) {
		printf("Resource type %s unknown.\n", argv[1]);
		return -1;
	}

	if (!strcasecmp(argv[2], "all")) {
		u16 res_count;
		u8 buf[288];
		u8 *ptr;
		int err;
		uint i;

		/* fetch list of already loaded resources in the TPM */
		err = tpm_get_capability(dev, TPM_CAP_HANDLE, type, buf,
					 sizeof(buf));
		if (err) {
			printf("tpm_get_capability returned error %d.\n", err);
			return -1;
		}
		res_count = get_unaligned_be16(buf);
		ptr = buf + 2;
		for (i = 0; i < res_count; ++i, ptr += 4)
			tpm1_flush_specific(dev, get_unaligned_be32(ptr), type);
	} else {
		u32 handle = simple_strtoul(argv[2], NULL, 0);

		if (!handle) {
			printf("Illegal resource handle %s\n", argv[2]);
			return -1;
		}
		tpm1_flush_specific(dev, cpu_to_be32(handle), type);
	}

	return 0;
}
#endif /* CONFIG_TPM_FLUSH_RESOURCES */

#ifdef CONFIG_TPM_LIST_RESOURCES
static int do_tpm_list(struct cmd_tbl *cmdtp, int flag, int argc,
		       char *const argv[])
{
	struct udevice *dev;
	int type = 0;
	u16 res_count;
	u8 buf[288];
	u8 *ptr;
	int err;
	uint i;

	err = get_tpm(&dev);
	if (err)
		return err;

	if (argc != 2)
		return CMD_RET_USAGE;

	if (!strcasecmp(argv[1], "key"))
		type = TPM_RT_KEY;
	else if (!strcasecmp(argv[1], "auth"))
		type = TPM_RT_AUTH;
	else if (!strcasecmp(argv[1], "hash"))
		type = TPM_RT_HASH;
	else if (!strcasecmp(argv[1], "trans"))
		type = TPM_RT_TRANS;
	else if (!strcasecmp(argv[1], "context"))
		type = TPM_RT_CONTEXT;
	else if (!strcasecmp(argv[1], "counter"))
		type = TPM_RT_COUNTER;
	else if (!strcasecmp(argv[1], "delegate"))
		type = TPM_RT_DELEGATE;
	else if (!strcasecmp(argv[1], "daa_tpm"))
		type = TPM_RT_DAA_TPM;
	else if (!strcasecmp(argv[1], "daa_v0"))
		type = TPM_RT_DAA_V0;
	else if (!strcasecmp(argv[1], "daa_v1"))
		type = TPM_RT_DAA_V1;

	if (!type) {
		printf("Resource type %s unknown.\n", argv[1]);
		return -1;
	}

	/* fetch list of already loaded resources in the TPM */
	err = tpm_get_capability(dev, TPM_CAP_HANDLE, type, buf,
				 sizeof(buf));
	if (err) {
		printf("tpm_get_capability returned error %d.\n", err);
		return -1;
	}
	res_count = get_unaligned_be16(buf);
	ptr = buf + 2;

	printf("Resources of type %s (%02x):\n", argv[1], type);
	if (!res_count) {
		puts("None\n");
	} else {
		for (i = 0; i < res_count; ++i, ptr += 4)
			printf("Index %d: %08x\n", i, get_unaligned_be32(ptr));
	}

	return 0;
}
#endif /* CONFIG_TPM_LIST_RESOURCES */

TPM_COMMAND_NO_ARG(tpm_self_test_full)
TPM_COMMAND_NO_ARG(tpm_continue_self_test)
TPM_COMMAND_NO_ARG(tpm_force_clear)
TPM_COMMAND_NO_ARG(tpm_physical_enable)
TPM_COMMAND_NO_ARG(tpm_physical_disable)

static struct cmd_tbl tpm1_commands[] = {
	U_BOOT_CMD_MKENT(device, 0, 1, do_tpm_device, "", ""),
	U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""),
	U_BOOT_CMD_MKENT(autostart, 0, 1, do_tpm_autostart, "", ""),
	U_BOOT_CMD_MKENT(init, 0, 1, do_tpm_init, "", ""),
	U_BOOT_CMD_MKENT(startup, 0, 1,
			 do_tpm_startup, "", ""),
	U_BOOT_CMD_MKENT(self_test_full, 0, 1,
			 do_tpm_self_test_full, "", ""),
	U_BOOT_CMD_MKENT(continue_self_test, 0, 1,
			 do_tpm_continue_self_test, "", ""),
	U_BOOT_CMD_MKENT(force_clear, 0, 1,
			 do_tpm_force_clear, "", ""),
	U_BOOT_CMD_MKENT(physical_enable, 0, 1,
			 do_tpm_physical_enable, "", ""),
	U_BOOT_CMD_MKENT(physical_disable, 0, 1,
			 do_tpm_physical_disable, "", ""),
	U_BOOT_CMD_MKENT(nv_define_space, 0, 1,
			 do_tpm_nv_define_space, "", ""),
	U_BOOT_CMD_MKENT(nv_read_value, 0, 1,
			 do_tpm_nv_read_value, "", ""),
	U_BOOT_CMD_MKENT(nv_write_value, 0, 1,
			 do_tpm_nv_write_value, "", ""),
	U_BOOT_CMD_MKENT(extend, 0, 1,
			 do_tpm_extend, "", ""),
	U_BOOT_CMD_MKENT(pcr_read, 0, 1,
			 do_tpm_pcr_read, "", ""),
	U_BOOT_CMD_MKENT(tsc_physical_presence, 0, 1,
			 do_tpm_tsc_physical_presence, "", ""),
	U_BOOT_CMD_MKENT(read_pubek, 0, 1,
			 do_tpm_read_pubek, "", ""),
	U_BOOT_CMD_MKENT(physical_set_deactivated, 0, 1,
			 do_tpm_physical_set_deactivated, "", ""),
	U_BOOT_CMD_MKENT(get_capability, 0, 1,
			 do_tpm_get_capability, "", ""),
	U_BOOT_CMD_MKENT(raw_transfer, 0, 1,
			 do_tpm_raw_transfer, "", ""),
	U_BOOT_CMD_MKENT(nv_define, 0, 1,
			 do_tpm_nv_define, "", ""),
	U_BOOT_CMD_MKENT(nv_read, 0, 1,
			 do_tpm_nv_read, "", ""),
	U_BOOT_CMD_MKENT(nv_write, 0, 1,
			 do_tpm_nv_write, "", ""),
#ifdef CONFIG_TPM_AUTH_SESSIONS
	U_BOOT_CMD_MKENT(oiap, 0, 1,
			 do_tpm_oiap, "", ""),
	U_BOOT_CMD_MKENT(end_oiap, 0, 1,
			 do_tpm1_end_oiap, "", ""),
	U_BOOT_CMD_MKENT(load_key2_oiap, 0, 1,
			 do_tpm_load_key2_oiap, "", ""),
#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
	U_BOOT_CMD_MKENT(load_key_by_sha1, 0, 1,
			 do_tpm_load_key_by_sha1, "", ""),
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
	U_BOOT_CMD_MKENT(get_pub_key_oiap, 0, 1,
			 do_tpm_get_pub_key_oiap, "", ""),
#endif /* CONFIG_TPM_AUTH_SESSIONS */
#ifdef CONFIG_TPM_FLUSH_RESOURCES
	U_BOOT_CMD_MKENT(flush, 0, 1,
			 do_tpm_flush, "", ""),
#endif /* CONFIG_TPM_FLUSH_RESOURCES */
#ifdef CONFIG_TPM_LIST_RESOURCES
	U_BOOT_CMD_MKENT(list, 0, 1,
			 do_tpm_list, "", ""),
#endif /* CONFIG_TPM_LIST_RESOURCES */
};

struct cmd_tbl *get_tpm1_commands(unsigned int *size)
{
	*size = ARRAY_SIZE(tpm1_commands);

	return tpm1_commands;
}

U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm,
"Issue a TPMv1.x command",
"cmd args...\n"
"    - Issue TPM command <cmd> with arguments <args...>.\n"
"Admin Startup and State Commands:\n"
"  device [num device]\n"
"    - Show all devices or set the specified device\n"
"  info - Show information about the TPM\n"
"  autostart\n"
"    - Initalize the tpm, perform a Startup(clear) and run a full selftest\n"
"      sequence\n"
"  init\n"
"    - Put TPM into a state where it waits for 'startup' command.\n"
"      startup mode\n"
"    - Issue TPM_Starup command.  <mode> is one of TPM_ST_CLEAR,\n"
"      TPM_ST_STATE, and TPM_ST_DEACTIVATED.\n"
"Admin Testing Commands:\n"
"  self_test_full\n"
"    - Test all of the TPM capabilities.\n"
"  continue_self_test\n"
"    - Inform TPM that it should complete the self-test.\n"
"Admin Opt-in Commands:\n"
"  physical_enable\n"
"    - Set the PERMANENT disable flag to FALSE using physical presence as\n"
"      authorization.\n"
"  physical_disable\n"
"    - Set the PERMANENT disable flag to TRUE using physical presence as\n"
"      authorization.\n"
"  physical_set_deactivated 0|1\n"
"    - Set deactivated flag.\n"
"Admin Ownership Commands:\n"
"  force_clear\n"
"    - Issue TPM_ForceClear command.\n"
"  tsc_physical_presence flags\n"
"    - Set TPM device's Physical Presence flags to <flags>.\n"
"The Capability Commands:\n"
"  get_capability cap_area sub_cap addr count\n"
"    - Read <count> bytes of TPM capability indexed by <cap_area> and\n"
"      <sub_cap> to memory address <addr>.\n"
#if defined(CONFIG_TPM_FLUSH_RESOURCES) || defined(CONFIG_TPM_LIST_RESOURCES)
"Resource management functions\n"
#endif
#ifdef CONFIG_TPM_FLUSH_RESOURCES
"  flush resource_type id\n"
"    - flushes a resource of type <resource_type> (may be one of key, auth,\n"
"      hash, trans, context, counter, delegate, daa_tpm, daa_v0, daa_v1),\n"
"      and id <id> from the TPM. Use an <id> of \"all\" to flush all\n"
"      resources of that type.\n"
#endif /* CONFIG_TPM_FLUSH_RESOURCES */
#ifdef CONFIG_TPM_LIST_RESOURCES
"  list resource_type\n"
"    - lists resources of type <resource_type> (may be one of key, auth,\n"
"      hash, trans, context, counter, delegate, daa_tpm, daa_v0, daa_v1),\n"
"      contained in the TPM.\n"
#endif /* CONFIG_TPM_LIST_RESOURCES */
#ifdef CONFIG_TPM_AUTH_SESSIONS
"Storage functions\n"
"  loadkey2_oiap parent_handle key_addr key_len usage_auth\n"
"    - loads a key data from memory address <key_addr>, <key_len> bytes\n"
"      into TPM using the parent key <parent_handle> with authorization\n"
"      <usage_auth> (20 bytes hex string).\n"
#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
"  load_key_by_sha1 parent_hash key_addr key_len usage_auth\n"
"    - loads a key data from memory address <key_addr>, <key_len> bytes\n"
"      into TPM using the parent hash <parent_hash> (20 bytes hex string)\n"
"      with authorization <usage_auth> (20 bytes hex string).\n"
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
"  get_pub_key_oiap key_handle usage_auth\n"
"    - get the public key portion of a loaded key <key_handle> using\n"
"      authorization <usage auth> (20 bytes hex string)\n"
#endif /* CONFIG_TPM_AUTH_SESSIONS */
"Endorsement Key Handling Commands:\n"
"  read_pubek addr count\n"
"    - Read <count> bytes of the public endorsement key to memory\n"
"      address <addr>\n"
"Integrity Collection and Reporting Commands:\n"
"  extend index digest_hex_string\n"
"    - Add a new measurement to a PCR.  Update PCR <index> with the 20-bytes\n"
"      <digest_hex_string>\n"
"  pcr_read index addr count\n"
"    - Read <count> bytes from PCR <index> to memory address <addr>.\n"
#ifdef CONFIG_TPM_AUTH_SESSIONS
"Authorization Sessions\n"
"  oiap\n"
"    - setup an OIAP session\n"
"  end_oiap\n"
"    - terminates an active OIAP session\n"
#endif /* CONFIG_TPM_AUTH_SESSIONS */
"Non-volatile Storage Commands:\n"
"  nv_define_space index permission size\n"
"    - Establish a space at index <index> with <permission> of <size> bytes.\n"
"  nv_read_value index addr count\n"
"    - Read <count> bytes from space <index> to memory address <addr>.\n"
"  nv_write_value index addr count\n"
"    - Write <count> bytes from memory address <addr> to space <index>.\n"
"Miscellaneous helper functions:\n"
"  raw_transfer byte_string\n"
"    - Send a byte string <byte_string> to TPM and print the response.\n"
" Non-volatile storage helper functions:\n"
"    These helper functions treat a non-volatile space as a non-padded\n"
"    sequence of integer values.  These integer values are defined by a type\n"
"    string, which is a text string of 'bwd' characters: 'b' means a 8-bit\n"
"    value, 'w' 16-bit value, 'd' 32-bit value.  All helper functions take\n"
"    a type string as their first argument.\n"
"  nv_define type_string index perm\n"
"    - Define a space <index> with permission <perm>.\n"
"  nv_read types_string index vars...\n"
"    - Read from space <index> to environment variables <vars...>.\n"
"  nv_write types_string index values...\n"
"    - Write to space <index> from values <values...>.\n"
);
