Example #1
0
static int do_tpm_many(cmd_tbl_t *cmdtp, int flag,
		       int argc, char * const argv[], int repeat_count)

{
	int rv = 0;

	if (argc < 7 && repeat_count == 0) {
		puts("command should be at least six bytes in size\n");
		return -1;
	}

	if (repeat_count > 0) {
		rv = tpm_process_stress(repeat_count);
		return rv;
	}

	if (tis_init()) {
		puts("tis_init() failed!\n");
		return -1;
	}

	if (tis_open()) {
		puts("tis_open() failed!\n");
		return -1;
	}

	rv = tpm_process(argc - 1, argv + 1, cmdtp);

	if (tis_close()) {
		puts("tis_close() failed!\n");
		rv = -1;
	}

	return rv;
}
Example #2
0
static void do_tpm_close(void)
{

	int ret = tis_close();

	if(!ret)
		printf("TPM closed...\n");
	else
		printf("Failed to close the TPM with error: %d\n", ret);
}
Example #3
0
static int tpm_process_stress(int repeat_count)
{
	int i;
	int rv = 0;
	u8 request[] = {0x0, 0xc1,
			0x0, 0x0, 0x0, 0x16,
			0x0, 0x0, 0x0, 0x65,
			0x0, 0x0, 0x0, 0x4,
			0x0, 0x0, 0x0, 0x4,
			0x0, 0x0, 0x1, 0x9};
	u8 response[MAX_TRANSACTION_SIZE];
	u32 rlength = MAX_TRANSACTION_SIZE;

	CHECK(tis_init());

	for (i = 0; i < repeat_count; i++) {
		CHECK(tis_open());
		rv = tis_sendrecv(request, sizeof(request), response, &rlength);
		if (rv) {
			printf("tpm test failed at step %d with 0x%x\n", i, rv);
			CHECK(tis_close());
			break;
		}
		CHECK(tis_close());
		if ((response[6] || response[7] || response[8] || response[9])
		    && response[9] != 0x26) {
			/* Ignore postinit errors */
			printf("tpm command failed at step %d\n"
			       "tpm error code: %02x%02x%02x%02x\n", i,
			       response[6], response[7],
			       response[8], response[9]);
			rv = -1;
			break;
		}
	}
	return rv;
}
VbError_t VbExTpmClose(void)
{
	if (tis_close())
		return TPM_E_IOERROR;
	return TPM_SUCCESS;
}