cmd_tpm.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * Copyright (c) 2013 The Chromium OS Authors.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <command.h>
  24. #include <malloc.h>
  25. #include <tpm.h>
  26. #include <asm/unaligned.h>
  27. #include <linux/string.h>
  28. /**
  29. * Print a byte string in hexdecimal format, 16-bytes per line.
  30. *
  31. * @param data byte string to be printed
  32. * @param count number of bytes to be printed
  33. */
  34. static void print_byte_string(uint8_t *data, size_t count)
  35. {
  36. int i, print_newline = 0;
  37. for (i = 0; i < count; i++) {
  38. printf(" %02x", data[i]);
  39. print_newline = (i % 16 == 15);
  40. if (print_newline)
  41. putc('\n');
  42. }
  43. /* Avoid duplicated newline at the end */
  44. if (!print_newline)
  45. putc('\n');
  46. }
  47. /**
  48. * Convert a text string of hexdecimal values into a byte string.
  49. *
  50. * @param bytes text string of hexdecimal values with no space
  51. * between them
  52. * @param data output buffer for byte string. The caller has to make
  53. * sure it is large enough for storing the output. If
  54. * NULL is passed, a large enough buffer will be allocated,
  55. * and the caller must free it.
  56. * @param count_ptr output variable for the length of byte string
  57. * @return pointer to output buffer
  58. */
  59. static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr)
  60. {
  61. char byte[3];
  62. size_t count, length;
  63. int i;
  64. length = strlen(bytes);
  65. count = length / 2;
  66. if (!data)
  67. data = malloc(count);
  68. if (!data)
  69. return NULL;
  70. byte[2] = '\0';
  71. for (i = 0; i < length; i += 2) {
  72. byte[0] = bytes[i];
  73. byte[1] = bytes[i + 1];
  74. data[i / 2] = (uint8_t)simple_strtoul(byte, NULL, 16);
  75. }
  76. if (count_ptr)
  77. *count_ptr = count;
  78. return data;
  79. }
  80. /**
  81. * Convert TPM command return code to U-Boot command error codes.
  82. *
  83. * @param return_code TPM command return code
  84. * @return value of enum command_ret_t
  85. */
  86. static int convert_return_code(uint32_t return_code)
  87. {
  88. if (return_code)
  89. return CMD_RET_FAILURE;
  90. else
  91. return CMD_RET_SUCCESS;
  92. }
  93. /**
  94. * Return number of values defined by a type string.
  95. *
  96. * @param type_str type string
  97. * @return number of values of type string
  98. */
  99. static int type_string_get_num_values(const char *type_str)
  100. {
  101. return strlen(type_str);
  102. }
  103. /**
  104. * Return total size of values defined by a type string.
  105. *
  106. * @param type_str type string
  107. * @return total size of values of type string, or 0 if type string
  108. * contains illegal type character.
  109. */
  110. static size_t type_string_get_space_size(const char *type_str)
  111. {
  112. size_t size;
  113. for (size = 0; *type_str; type_str++) {
  114. switch (*type_str) {
  115. case 'b':
  116. size += 1;
  117. break;
  118. case 'w':
  119. size += 2;
  120. break;
  121. case 'd':
  122. size += 4;
  123. break;
  124. default:
  125. return 0;
  126. }
  127. }
  128. return size;
  129. }
  130. /**
  131. * Allocate a buffer large enough to hold values defined by a type
  132. * string. The caller has to free the buffer.
  133. *
  134. * @param type_str type string
  135. * @param count pointer for storing size of buffer
  136. * @return pointer to buffer or NULL on error
  137. */
  138. static void *type_string_alloc(const char *type_str, uint32_t *count)
  139. {
  140. void *data;
  141. size_t size;
  142. size = type_string_get_space_size(type_str);
  143. if (!size)
  144. return NULL;
  145. data = malloc(size);
  146. if (data)
  147. *count = size;
  148. return data;
  149. }
  150. /**
  151. * Pack values defined by a type string into a buffer. The buffer must have
  152. * large enough space.
  153. *
  154. * @param type_str type string
  155. * @param values text strings of values to be packed
  156. * @param data output buffer of values
  157. * @return 0 on success, non-0 on error
  158. */
  159. static int type_string_pack(const char *type_str, char * const values[],
  160. uint8_t *data)
  161. {
  162. size_t offset;
  163. uint32_t value;
  164. for (offset = 0; *type_str; type_str++, values++) {
  165. value = simple_strtoul(values[0], NULL, 0);
  166. switch (*type_str) {
  167. case 'b':
  168. data[offset] = value;
  169. offset += 1;
  170. break;
  171. case 'w':
  172. put_unaligned_be16(value, data + offset);
  173. offset += 2;
  174. break;
  175. case 'd':
  176. put_unaligned_be32(value, data + offset);
  177. offset += 4;
  178. break;
  179. default:
  180. return -1;
  181. }
  182. }
  183. return 0;
  184. }
  185. /**
  186. * Read values defined by a type string from a buffer, and write these values
  187. * to environment variables.
  188. *
  189. * @param type_str type string
  190. * @param data input buffer of values
  191. * @param vars names of environment variables
  192. * @return 0 on success, non-0 on error
  193. */
  194. static int type_string_write_vars(const char *type_str, uint8_t *data,
  195. char * const vars[])
  196. {
  197. size_t offset;
  198. uint32_t value;
  199. for (offset = 0; *type_str; type_str++, vars++) {
  200. switch (*type_str) {
  201. case 'b':
  202. value = data[offset];
  203. offset += 1;
  204. break;
  205. case 'w':
  206. value = get_unaligned_be16(data + offset);
  207. offset += 2;
  208. break;
  209. case 'd':
  210. value = get_unaligned_be32(data + offset);
  211. offset += 4;
  212. break;
  213. default:
  214. return -1;
  215. }
  216. if (setenv_ulong(*vars, value))
  217. return -1;
  218. }
  219. return 0;
  220. }
  221. static int do_tpm_startup(cmd_tbl_t *cmdtp, int flag,
  222. int argc, char * const argv[])
  223. {
  224. enum tpm_startup_type mode;
  225. if (argc != 2)
  226. return CMD_RET_USAGE;
  227. if (!strcasecmp("TPM_ST_CLEAR", argv[1])) {
  228. mode = TPM_ST_CLEAR;
  229. } else if (!strcasecmp("TPM_ST_STATE", argv[1])) {
  230. mode = TPM_ST_STATE;
  231. } else if (!strcasecmp("TPM_ST_DEACTIVATED", argv[1])) {
  232. mode = TPM_ST_DEACTIVATED;
  233. } else {
  234. printf("Couldn't recognize mode string: %s\n", argv[1]);
  235. return CMD_RET_FAILURE;
  236. }
  237. return convert_return_code(tpm_startup(mode));
  238. }
  239. static int do_tpm_nv_define_space(cmd_tbl_t *cmdtp, int flag,
  240. int argc, char * const argv[])
  241. {
  242. uint32_t index, perm, size;
  243. if (argc != 4)
  244. return CMD_RET_USAGE;
  245. index = simple_strtoul(argv[1], NULL, 0);
  246. perm = simple_strtoul(argv[2], NULL, 0);
  247. size = simple_strtoul(argv[3], NULL, 0);
  248. return convert_return_code(tpm_nv_define_space(index, perm, size));
  249. }
  250. static int do_tpm_nv_read_value(cmd_tbl_t *cmdtp, int flag,
  251. int argc, char * const argv[])
  252. {
  253. uint32_t index, count, rc;
  254. void *data;
  255. if (argc != 4)
  256. return CMD_RET_USAGE;
  257. index = simple_strtoul(argv[1], NULL, 0);
  258. data = (void *)simple_strtoul(argv[2], NULL, 0);
  259. count = simple_strtoul(argv[3], NULL, 0);
  260. rc = tpm_nv_read_value(index, data, count);
  261. if (!rc) {
  262. puts("area content:\n");
  263. print_byte_string(data, count);
  264. }
  265. return convert_return_code(rc);
  266. }
  267. static int do_tpm_nv_write_value(cmd_tbl_t *cmdtp, int flag,
  268. int argc, char * const argv[])
  269. {
  270. uint32_t index, rc;
  271. size_t count;
  272. void *data;
  273. if (argc != 3)
  274. return CMD_RET_USAGE;
  275. index = simple_strtoul(argv[1], NULL, 0);
  276. data = parse_byte_string(argv[2], NULL, &count);
  277. if (!data) {
  278. printf("Couldn't parse byte string %s\n", argv[2]);
  279. return CMD_RET_FAILURE;
  280. }
  281. rc = tpm_nv_write_value(index, data, count);
  282. free(data);
  283. return convert_return_code(rc);
  284. }
  285. static int do_tpm_extend(cmd_tbl_t *cmdtp, int flag,
  286. int argc, char * const argv[])
  287. {
  288. uint32_t index, rc;
  289. uint8_t in_digest[20], out_digest[20];
  290. if (argc != 3)
  291. return CMD_RET_USAGE;
  292. index = simple_strtoul(argv[1], NULL, 0);
  293. if (!parse_byte_string(argv[2], in_digest, NULL)) {
  294. printf("Couldn't parse byte string %s\n", argv[2]);
  295. return CMD_RET_FAILURE;
  296. }
  297. rc = tpm_extend(index, in_digest, out_digest);
  298. if (!rc) {
  299. puts("PCR value after execution of the command:\n");
  300. print_byte_string(out_digest, sizeof(out_digest));
  301. }
  302. return convert_return_code(rc);
  303. }
  304. static int do_tpm_pcr_read(cmd_tbl_t *cmdtp, int flag,
  305. int argc, char * const argv[])
  306. {
  307. uint32_t index, count, rc;
  308. void *data;
  309. if (argc != 4)
  310. return CMD_RET_USAGE;
  311. index = simple_strtoul(argv[1], NULL, 0);
  312. data = (void *)simple_strtoul(argv[2], NULL, 0);
  313. count = simple_strtoul(argv[3], NULL, 0);
  314. rc = tpm_pcr_read(index, data, count);
  315. if (!rc) {
  316. puts("Named PCR content:\n");
  317. print_byte_string(data, count);
  318. }
  319. return convert_return_code(rc);
  320. }
  321. static int do_tpm_tsc_physical_presence(cmd_tbl_t *cmdtp, int flag,
  322. int argc, char * const argv[])
  323. {
  324. uint16_t presence;
  325. if (argc != 2)
  326. return CMD_RET_USAGE;
  327. presence = (uint16_t)simple_strtoul(argv[1], NULL, 0);
  328. return convert_return_code(tpm_tsc_physical_presence(presence));
  329. }
  330. static int do_tpm_read_pubek(cmd_tbl_t *cmdtp, int flag,
  331. int argc, char * const argv[])
  332. {
  333. uint32_t count, rc;
  334. void *data;
  335. if (argc != 3)
  336. return CMD_RET_USAGE;
  337. data = (void *)simple_strtoul(argv[1], NULL, 0);
  338. count = simple_strtoul(argv[2], NULL, 0);
  339. rc = tpm_read_pubek(data, count);
  340. if (!rc) {
  341. puts("pubek value:\n");
  342. print_byte_string(data, count);
  343. }
  344. return convert_return_code(rc);
  345. }
  346. static int do_tpm_physical_set_deactivated(cmd_tbl_t *cmdtp, int flag,
  347. int argc, char * const argv[])
  348. {
  349. uint8_t state;
  350. if (argc != 2)
  351. return CMD_RET_USAGE;
  352. state = (uint8_t)simple_strtoul(argv[1], NULL, 0);
  353. return convert_return_code(tpm_physical_set_deactivated(state));
  354. }
  355. static int do_tpm_get_capability(cmd_tbl_t *cmdtp, int flag,
  356. int argc, char * const argv[])
  357. {
  358. uint32_t cap_area, sub_cap, rc;
  359. void *cap;
  360. size_t count;
  361. if (argc != 5)
  362. return CMD_RET_USAGE;
  363. cap_area = simple_strtoul(argv[1], NULL, 0);
  364. sub_cap = simple_strtoul(argv[2], NULL, 0);
  365. cap = (void *)simple_strtoul(argv[3], NULL, 0);
  366. count = simple_strtoul(argv[4], NULL, 0);
  367. rc = tpm_get_capability(cap_area, sub_cap, cap, count);
  368. if (!rc) {
  369. puts("capability information:\n");
  370. print_byte_string(cap, count);
  371. }
  372. return convert_return_code(rc);
  373. }
  374. #define TPM_COMMAND_NO_ARG(cmd) \
  375. static int do_##cmd(cmd_tbl_t *cmdtp, int flag, \
  376. int argc, char * const argv[]) \
  377. { \
  378. if (argc != 1) \
  379. return CMD_RET_USAGE; \
  380. return convert_return_code(cmd()); \
  381. }
  382. TPM_COMMAND_NO_ARG(tpm_init)
  383. TPM_COMMAND_NO_ARG(tpm_self_test_full)
  384. TPM_COMMAND_NO_ARG(tpm_continue_self_test)
  385. TPM_COMMAND_NO_ARG(tpm_force_clear)
  386. TPM_COMMAND_NO_ARG(tpm_physical_enable)
  387. TPM_COMMAND_NO_ARG(tpm_physical_disable)
  388. static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
  389. int argc, char * const argv[])
  390. {
  391. void *command;
  392. uint8_t response[1024];
  393. size_t count, response_length = sizeof(response);
  394. uint32_t rc;
  395. command = parse_byte_string(argv[1], NULL, &count);
  396. if (!command) {
  397. printf("Couldn't parse byte string %s\n", argv[1]);
  398. return CMD_RET_FAILURE;
  399. }
  400. rc = tis_sendrecv(command, count, response, &response_length);
  401. free(command);
  402. if (!rc) {
  403. puts("tpm response:\n");
  404. print_byte_string(response, response_length);
  405. }
  406. return convert_return_code(rc);
  407. }
  408. static int do_tpm_nv_define(cmd_tbl_t *cmdtp, int flag,
  409. int argc, char * const argv[])
  410. {
  411. uint32_t index, perm, size;
  412. if (argc != 4)
  413. return CMD_RET_USAGE;
  414. size = type_string_get_space_size(argv[1]);
  415. if (!size) {
  416. printf("Couldn't parse arguments\n");
  417. return CMD_RET_USAGE;
  418. }
  419. index = simple_strtoul(argv[2], NULL, 0);
  420. perm = simple_strtoul(argv[3], NULL, 0);
  421. return convert_return_code(tpm_nv_define_space(index, perm, size));
  422. }
  423. static int do_tpm_nv_read(cmd_tbl_t *cmdtp, int flag,
  424. int argc, char * const argv[])
  425. {
  426. uint32_t index, count, err;
  427. void *data;
  428. if (argc < 3)
  429. return CMD_RET_USAGE;
  430. if (argc != 3 + type_string_get_num_values(argv[1]))
  431. return CMD_RET_USAGE;
  432. index = simple_strtoul(argv[2], NULL, 0);
  433. data = type_string_alloc(argv[1], &count);
  434. if (!data) {
  435. printf("Couldn't parse arguments\n");
  436. return CMD_RET_USAGE;
  437. }
  438. err = tpm_nv_read_value(index, data, count);
  439. if (!err) {
  440. if (type_string_write_vars(argv[1], data, argv + 3)) {
  441. printf("Couldn't write to variables\n");
  442. err = ~0;
  443. }
  444. }
  445. free(data);
  446. return convert_return_code(err);
  447. }
  448. static int do_tpm_nv_write(cmd_tbl_t *cmdtp, int flag,
  449. int argc, char * const argv[])
  450. {
  451. uint32_t index, count, err;
  452. void *data;
  453. if (argc < 3)
  454. return CMD_RET_USAGE;
  455. if (argc != 3 + type_string_get_num_values(argv[1]))
  456. return CMD_RET_USAGE;
  457. index = simple_strtoul(argv[2], NULL, 0);
  458. data = type_string_alloc(argv[1], &count);
  459. if (!data) {
  460. printf("Couldn't parse arguments\n");
  461. return CMD_RET_USAGE;
  462. }
  463. if (type_string_pack(argv[1], argv + 3, data)) {
  464. printf("Couldn't parse arguments\n");
  465. free(data);
  466. return CMD_RET_USAGE;
  467. }
  468. err = tpm_nv_write_value(index, data, count);
  469. free(data);
  470. return convert_return_code(err);
  471. }
  472. #define MAKE_TPM_CMD_ENTRY(cmd) \
  473. U_BOOT_CMD_MKENT(cmd, 0, 1, do_tpm_ ## cmd, "", "")
  474. static cmd_tbl_t tpm_commands[] = {
  475. U_BOOT_CMD_MKENT(init, 0, 1,
  476. do_tpm_init, "", ""),
  477. U_BOOT_CMD_MKENT(startup, 0, 1,
  478. do_tpm_startup, "", ""),
  479. U_BOOT_CMD_MKENT(self_test_full, 0, 1,
  480. do_tpm_self_test_full, "", ""),
  481. U_BOOT_CMD_MKENT(continue_self_test, 0, 1,
  482. do_tpm_continue_self_test, "", ""),
  483. U_BOOT_CMD_MKENT(force_clear, 0, 1,
  484. do_tpm_force_clear, "", ""),
  485. U_BOOT_CMD_MKENT(physical_enable, 0, 1,
  486. do_tpm_physical_enable, "", ""),
  487. U_BOOT_CMD_MKENT(physical_disable, 0, 1,
  488. do_tpm_physical_disable, "", ""),
  489. U_BOOT_CMD_MKENT(nv_define_space, 0, 1,
  490. do_tpm_nv_define_space, "", ""),
  491. U_BOOT_CMD_MKENT(nv_read_value, 0, 1,
  492. do_tpm_nv_read_value, "", ""),
  493. U_BOOT_CMD_MKENT(nv_write_value, 0, 1,
  494. do_tpm_nv_write_value, "", ""),
  495. U_BOOT_CMD_MKENT(extend, 0, 1,
  496. do_tpm_extend, "", ""),
  497. U_BOOT_CMD_MKENT(pcr_read, 0, 1,
  498. do_tpm_pcr_read, "", ""),
  499. U_BOOT_CMD_MKENT(tsc_physical_presence, 0, 1,
  500. do_tpm_tsc_physical_presence, "", ""),
  501. U_BOOT_CMD_MKENT(read_pubek, 0, 1,
  502. do_tpm_read_pubek, "", ""),
  503. U_BOOT_CMD_MKENT(physical_set_deactivated, 0, 1,
  504. do_tpm_physical_set_deactivated, "", ""),
  505. U_BOOT_CMD_MKENT(get_capability, 0, 1,
  506. do_tpm_get_capability, "", ""),
  507. U_BOOT_CMD_MKENT(raw_transfer, 0, 1,
  508. do_tpm_raw_transfer, "", ""),
  509. U_BOOT_CMD_MKENT(nv_define, 0, 1,
  510. do_tpm_nv_define, "", ""),
  511. U_BOOT_CMD_MKENT(nv_read, 0, 1,
  512. do_tpm_nv_read, "", ""),
  513. U_BOOT_CMD_MKENT(nv_write, 0, 1,
  514. do_tpm_nv_write, "", ""),
  515. };
  516. static int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  517. {
  518. cmd_tbl_t *tpm_cmd;
  519. if (argc < 2)
  520. return CMD_RET_USAGE;
  521. tpm_cmd = find_cmd_tbl(argv[1], tpm_commands, ARRAY_SIZE(tpm_commands));
  522. if (!tpm_cmd)
  523. return CMD_RET_USAGE;
  524. return tpm_cmd->cmd(cmdtp, flag, argc - 1, argv + 1);
  525. }
  526. U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm,
  527. "Issue a TPM command",
  528. "cmd args...\n"
  529. " - Issue TPM command <cmd> with arguments <args...>.\n"
  530. "Admin Startup and State Commands:\n"
  531. " init\n"
  532. " - Put TPM into a state where it waits for 'startup' command.\n"
  533. " startup mode\n"
  534. " - Issue TPM_Starup command. <mode> is one of TPM_ST_CLEAR,\n"
  535. " TPM_ST_STATE, and TPM_ST_DEACTIVATED.\n"
  536. "Admin Testing Commands:\n"
  537. " self_test_full\n"
  538. " - Test all of the TPM capabilities.\n"
  539. " continue_self_test\n"
  540. " - Inform TPM that it should complete the self-test.\n"
  541. "Admin Opt-in Commands:\n"
  542. " physical_enable\n"
  543. " - Set the PERMANENT disable flag to FALSE using physical presence as\n"
  544. " authorization.\n"
  545. " physical_disable\n"
  546. " - Set the PERMANENT disable flag to TRUE using physical presence as\n"
  547. " authorization.\n"
  548. " physical_set_deactivated 0|1\n"
  549. " - Set deactivated flag.\n"
  550. "Admin Ownership Commands:\n"
  551. " force_clear\n"
  552. " - Issue TPM_ForceClear command.\n"
  553. " tsc_physical_presence flags\n"
  554. " - Set TPM device's Physical Presence flags to <flags>.\n"
  555. "The Capability Commands:\n"
  556. " get_capability cap_area sub_cap addr count\n"
  557. " - Read <count> bytes of TPM capability indexed by <cap_area> and\n"
  558. " <sub_cap> to memory address <addr>.\n"
  559. "Endorsement Key Handling Commands:\n"
  560. " read_pubek addr count\n"
  561. " - Read <count> bytes of the public endorsement key to memory\n"
  562. " address <addr>\n"
  563. "Integrity Collection and Reporting Commands:\n"
  564. " extend index digest_hex_string\n"
  565. " - Add a new measurement to a PCR. Update PCR <index> with the 20-bytes\n"
  566. " <digest_hex_string>\n"
  567. " pcr_read index addr count\n"
  568. " - Read <count> bytes from PCR <index> to memory address <addr>.\n"
  569. "Non-volatile Storage Commands:\n"
  570. " nv_define_space index permission size\n"
  571. " - Establish a space at index <index> with <permission> of <size> bytes.\n"
  572. " nv_read_value index addr count\n"
  573. " - Read <count> bytes from space <index> to memory address <addr>.\n"
  574. " nv_write_value index addr count\n"
  575. " - Write <count> bytes from memory address <addr> to space <index>.\n"
  576. "Miscellaneous helper functions:\n"
  577. " raw_transfer byte_string\n"
  578. " - Send a byte string <byte_string> to TPM and print the response.\n"
  579. " Non-volatile storage helper functions:\n"
  580. " These helper functions treat a non-volatile space as a non-padded\n"
  581. " sequence of integer values. These integer values are defined by a type\n"
  582. " string, which is a text string of 'bwd' characters: 'b' means a 8-bit\n"
  583. " value, 'w' 16-bit value, 'd' 32-bit value. All helper functions take\n"
  584. " a type string as their first argument.\n"
  585. " nv_define type_string index perm\n"
  586. " - Define a space <index> with permission <perm>.\n"
  587. " nv_read types_string index vars...\n"
  588. " - Read from space <index> to environment variables <vars...>.\n"
  589. " nv_write types_string index values...\n"
  590. " - Write to space <index> from values <values...>.\n"
  591. );