Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vadim Bendebury | 576fb1e | 2011-10-15 15:13:34 +0000 | [diff] [blame] | 2 | /* |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013 The Chromium OS Authors. |
Vadim Bendebury | 576fb1e | 2011-10-15 15:13:34 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 7 | #include <command.h> |
Simon Glass | c7694dd | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 8 | #include <env.h> |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 9 | #include <malloc.h> |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 10 | #include <asm/unaligned.h> |
Miquel Raynal | d677bfe | 2018-05-15 11:57:06 +0200 | [diff] [blame] | 11 | #include <tpm-common.h> |
| 12 | #include <tpm-v1.h> |
| 13 | #include "tpm-user-utils.h" |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 14 | #include <tpm_api.h> |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 15 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 16 | static int do_tpm_startup(struct cmd_tbl *cmdtp, int flag, int argc, |
| 17 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 18 | { |
| 19 | enum tpm_startup_type mode; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 20 | struct udevice *dev; |
| 21 | int rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 22 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 23 | rc = get_tpm(&dev); |
| 24 | if (rc) |
| 25 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 26 | if (argc != 2) |
| 27 | return CMD_RET_USAGE; |
| 28 | if (!strcasecmp("TPM_ST_CLEAR", argv[1])) { |
| 29 | mode = TPM_ST_CLEAR; |
| 30 | } else if (!strcasecmp("TPM_ST_STATE", argv[1])) { |
| 31 | mode = TPM_ST_STATE; |
| 32 | } else if (!strcasecmp("TPM_ST_DEACTIVATED", argv[1])) { |
| 33 | mode = TPM_ST_DEACTIVATED; |
| 34 | } else { |
| 35 | printf("Couldn't recognize mode string: %s\n", argv[1]); |
| 36 | return CMD_RET_FAILURE; |
| 37 | } |
| 38 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 39 | return report_return_code(tpm_startup(dev, mode)); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 42 | static int do_tpm_nv_define_space(struct cmd_tbl *cmdtp, int flag, int argc, |
| 43 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 44 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 45 | u32 index, perm, size; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 46 | struct udevice *dev; |
| 47 | int rc; |
| 48 | |
| 49 | rc = get_tpm(&dev); |
| 50 | if (rc) |
| 51 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 52 | |
| 53 | if (argc != 4) |
| 54 | return CMD_RET_USAGE; |
| 55 | index = simple_strtoul(argv[1], NULL, 0); |
| 56 | perm = simple_strtoul(argv[2], NULL, 0); |
| 57 | size = simple_strtoul(argv[3], NULL, 0); |
| 58 | |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 59 | return report_return_code(tpm1_nv_define_space(dev, index, perm, size)); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 62 | static int do_tpm_nv_read_value(struct cmd_tbl *cmdtp, int flag, int argc, |
| 63 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 64 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 65 | u32 index, count, rc; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 66 | struct udevice *dev; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 67 | void *data; |
| 68 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 69 | rc = get_tpm(&dev); |
| 70 | if (rc) |
| 71 | return rc; |
| 72 | |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 73 | if (argc != 4) |
| 74 | return CMD_RET_USAGE; |
| 75 | index = simple_strtoul(argv[1], NULL, 0); |
| 76 | data = (void *)simple_strtoul(argv[2], NULL, 0); |
| 77 | count = simple_strtoul(argv[3], NULL, 0); |
| 78 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 79 | rc = tpm_nv_read_value(dev, index, data, count); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 80 | if (!rc) { |
| 81 | puts("area content:\n"); |
| 82 | print_byte_string(data, count); |
| 83 | } |
| 84 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 85 | return report_return_code(rc); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 88 | static int do_tpm_nv_write_value(struct cmd_tbl *cmdtp, int flag, int argc, |
| 89 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 90 | { |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 91 | struct udevice *dev; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 92 | u32 index, rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 93 | size_t count; |
| 94 | void *data; |
| 95 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 96 | rc = get_tpm(&dev); |
| 97 | if (rc) |
| 98 | return rc; |
| 99 | |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 100 | if (argc != 3) |
| 101 | return CMD_RET_USAGE; |
| 102 | index = simple_strtoul(argv[1], NULL, 0); |
| 103 | data = parse_byte_string(argv[2], NULL, &count); |
| 104 | if (!data) { |
| 105 | printf("Couldn't parse byte string %s\n", argv[2]); |
| 106 | return CMD_RET_FAILURE; |
| 107 | } |
| 108 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 109 | rc = tpm_nv_write_value(dev, index, data, count); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 110 | free(data); |
| 111 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 112 | return report_return_code(rc); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 115 | static int do_tpm_extend(struct cmd_tbl *cmdtp, int flag, int argc, |
| 116 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 117 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 118 | u8 in_digest[20], out_digest[20]; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 119 | struct udevice *dev; |
| 120 | u32 index, rc; |
| 121 | |
| 122 | rc = get_tpm(&dev); |
| 123 | if (rc) |
| 124 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 125 | |
| 126 | if (argc != 3) |
| 127 | return CMD_RET_USAGE; |
| 128 | index = simple_strtoul(argv[1], NULL, 0); |
| 129 | if (!parse_byte_string(argv[2], in_digest, NULL)) { |
| 130 | printf("Couldn't parse byte string %s\n", argv[2]); |
| 131 | return CMD_RET_FAILURE; |
| 132 | } |
| 133 | |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 134 | rc = tpm_pcr_extend(dev, index, in_digest, out_digest); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 135 | if (!rc) { |
| 136 | puts("PCR value after execution of the command:\n"); |
| 137 | print_byte_string(out_digest, sizeof(out_digest)); |
| 138 | } |
| 139 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 140 | return report_return_code(rc); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 143 | static int do_tpm_pcr_read(struct cmd_tbl *cmdtp, int flag, int argc, |
| 144 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 145 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 146 | u32 index, count, rc; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 147 | struct udevice *dev; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 148 | void *data; |
| 149 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 150 | rc = get_tpm(&dev); |
| 151 | if (rc) |
| 152 | return rc; |
| 153 | |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 154 | if (argc != 4) |
| 155 | return CMD_RET_USAGE; |
| 156 | index = simple_strtoul(argv[1], NULL, 0); |
| 157 | data = (void *)simple_strtoul(argv[2], NULL, 0); |
| 158 | count = simple_strtoul(argv[3], NULL, 0); |
| 159 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 160 | rc = tpm_pcr_read(dev, index, data, count); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 161 | if (!rc) { |
| 162 | puts("Named PCR content:\n"); |
| 163 | print_byte_string(data, count); |
| 164 | } |
| 165 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 166 | return report_return_code(rc); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 169 | static int do_tpm_tsc_physical_presence(struct cmd_tbl *cmdtp, int flag, |
| 170 | int argc, char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 171 | { |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 172 | struct udevice *dev; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 173 | u16 presence; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 174 | int rc; |
| 175 | |
| 176 | rc = get_tpm(&dev); |
| 177 | if (rc) |
| 178 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 179 | |
| 180 | if (argc != 2) |
| 181 | return CMD_RET_USAGE; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 182 | presence = (u16)simple_strtoul(argv[1], NULL, 0); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 183 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 184 | return report_return_code(tpm_tsc_physical_presence(dev, presence)); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 187 | static int do_tpm_read_pubek(struct cmd_tbl *cmdtp, int flag, int argc, |
| 188 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 189 | { |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 190 | struct udevice *dev; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 191 | u32 count, rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 192 | void *data; |
| 193 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 194 | rc = get_tpm(&dev); |
| 195 | if (rc) |
| 196 | return rc; |
| 197 | |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 198 | if (argc != 3) |
| 199 | return CMD_RET_USAGE; |
| 200 | data = (void *)simple_strtoul(argv[1], NULL, 0); |
| 201 | count = simple_strtoul(argv[2], NULL, 0); |
| 202 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 203 | rc = tpm_read_pubek(dev, data, count); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 204 | if (!rc) { |
| 205 | puts("pubek value:\n"); |
| 206 | print_byte_string(data, count); |
| 207 | } |
| 208 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 209 | return report_return_code(rc); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 212 | static int do_tpm_physical_set_deactivated(struct cmd_tbl *cmdtp, int flag, |
| 213 | int argc, char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 214 | { |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 215 | struct udevice *dev; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 216 | u8 state; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 217 | int rc; |
| 218 | |
| 219 | rc = get_tpm(&dev); |
| 220 | if (rc) |
| 221 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 222 | |
| 223 | if (argc != 2) |
| 224 | return CMD_RET_USAGE; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 225 | state = (u8)simple_strtoul(argv[1], NULL, 0); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 226 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 227 | return report_return_code(tpm_physical_set_deactivated(dev, state)); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 230 | static int do_tpm_get_capability(struct cmd_tbl *cmdtp, int flag, int argc, |
| 231 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 232 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 233 | u32 cap_area, sub_cap, rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 234 | void *cap; |
| 235 | size_t count; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 236 | struct udevice *dev; |
| 237 | |
| 238 | rc = get_tpm(&dev); |
| 239 | if (rc) |
| 240 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 241 | |
| 242 | if (argc != 5) |
| 243 | return CMD_RET_USAGE; |
| 244 | cap_area = simple_strtoul(argv[1], NULL, 0); |
| 245 | sub_cap = simple_strtoul(argv[2], NULL, 0); |
| 246 | cap = (void *)simple_strtoul(argv[3], NULL, 0); |
| 247 | count = simple_strtoul(argv[4], NULL, 0); |
| 248 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 249 | rc = tpm_get_capability(dev, cap_area, sub_cap, cap, count); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 250 | if (!rc) { |
| 251 | puts("capability information:\n"); |
| 252 | print_byte_string(cap, count); |
| 253 | } |
| 254 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 255 | return report_return_code(rc); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 258 | static int do_tpm_raw_transfer(struct cmd_tbl *cmdtp, int flag, int argc, |
| 259 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 260 | { |
Christophe Ricard | c2b0f60 | 2015-10-06 22:54:43 +0200 | [diff] [blame] | 261 | struct udevice *dev; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 262 | void *command; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 263 | u8 response[1024]; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 264 | size_t count, response_length = sizeof(response); |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 265 | u32 rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 266 | |
| 267 | command = parse_byte_string(argv[1], NULL, &count); |
| 268 | if (!command) { |
| 269 | printf("Couldn't parse byte string %s\n", argv[1]); |
| 270 | return CMD_RET_FAILURE; |
| 271 | } |
| 272 | |
Simon Glass | c8a8c51 | 2015-08-22 18:31:32 -0600 | [diff] [blame] | 273 | rc = get_tpm(&dev); |
| 274 | if (rc) |
| 275 | return rc; |
| 276 | |
| 277 | rc = tpm_xfer(dev, command, count, response, &response_length); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 278 | free(command); |
| 279 | if (!rc) { |
| 280 | puts("tpm response:\n"); |
| 281 | print_byte_string(response, response_length); |
| 282 | } |
| 283 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 284 | return report_return_code(rc); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 287 | static int do_tpm_nv_define(struct cmd_tbl *cmdtp, int flag, int argc, |
| 288 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 289 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 290 | u32 index, perm, size; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 291 | struct udevice *dev; |
| 292 | int rc; |
| 293 | |
| 294 | rc = get_tpm(&dev); |
| 295 | if (rc) |
| 296 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 297 | |
| 298 | if (argc != 4) |
| 299 | return CMD_RET_USAGE; |
| 300 | size = type_string_get_space_size(argv[1]); |
| 301 | if (!size) { |
| 302 | printf("Couldn't parse arguments\n"); |
| 303 | return CMD_RET_USAGE; |
| 304 | } |
| 305 | index = simple_strtoul(argv[2], NULL, 0); |
| 306 | perm = simple_strtoul(argv[3], NULL, 0); |
| 307 | |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 308 | return report_return_code(tpm1_nv_define_space(dev, index, perm, size)); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 311 | static int do_tpm_nv_read(struct cmd_tbl *cmdtp, int flag, int argc, |
| 312 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 313 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 314 | u32 index, count, err; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 315 | struct udevice *dev; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 316 | void *data; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 317 | int rc; |
| 318 | |
| 319 | rc = get_tpm(&dev); |
| 320 | if (rc) |
| 321 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 322 | |
| 323 | if (argc < 3) |
| 324 | return CMD_RET_USAGE; |
| 325 | if (argc != 3 + type_string_get_num_values(argv[1])) |
| 326 | return CMD_RET_USAGE; |
| 327 | index = simple_strtoul(argv[2], NULL, 0); |
| 328 | data = type_string_alloc(argv[1], &count); |
| 329 | if (!data) { |
| 330 | printf("Couldn't parse arguments\n"); |
| 331 | return CMD_RET_USAGE; |
| 332 | } |
| 333 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 334 | err = tpm_nv_read_value(dev, index, data, count); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 335 | if (!err) { |
| 336 | if (type_string_write_vars(argv[1], data, argv + 3)) { |
| 337 | printf("Couldn't write to variables\n"); |
| 338 | err = ~0; |
| 339 | } |
| 340 | } |
| 341 | free(data); |
| 342 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 343 | return report_return_code(err); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 344 | } |
| 345 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 346 | static int do_tpm_nv_write(struct cmd_tbl *cmdtp, int flag, int argc, |
| 347 | char *const argv[]) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 348 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 349 | u32 index, count, err; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 350 | struct udevice *dev; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 351 | void *data; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 352 | int rc; |
| 353 | |
| 354 | rc = get_tpm(&dev); |
| 355 | if (rc) |
| 356 | return rc; |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 357 | |
| 358 | if (argc < 3) |
| 359 | return CMD_RET_USAGE; |
| 360 | if (argc != 3 + type_string_get_num_values(argv[1])) |
| 361 | return CMD_RET_USAGE; |
| 362 | index = simple_strtoul(argv[2], NULL, 0); |
| 363 | data = type_string_alloc(argv[1], &count); |
| 364 | if (!data) { |
| 365 | printf("Couldn't parse arguments\n"); |
| 366 | return CMD_RET_USAGE; |
| 367 | } |
| 368 | if (type_string_pack(argv[1], argv + 3, data)) { |
| 369 | printf("Couldn't parse arguments\n"); |
| 370 | free(data); |
| 371 | return CMD_RET_USAGE; |
| 372 | } |
| 373 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 374 | err = tpm_nv_write_value(dev, index, data, count); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 375 | free(data); |
| 376 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 377 | return report_return_code(err); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 378 | } |
| 379 | |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 380 | #ifdef CONFIG_TPM_AUTH_SESSIONS |
| 381 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 382 | static int do_tpm_oiap(struct cmd_tbl *cmdtp, int flag, int argc, |
| 383 | char *const argv[]) |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 384 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 385 | u32 auth_handle, err; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 386 | struct udevice *dev; |
| 387 | int rc; |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 388 | |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 389 | rc = get_tpm(&dev); |
| 390 | if (rc) |
| 391 | return rc; |
| 392 | |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 393 | err = tpm1_oiap(dev, &auth_handle); |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 394 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 395 | return report_return_code(err); |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 396 | } |
| 397 | |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 398 | #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1 |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 399 | static int do_tpm_load_key_by_sha1(struct cmd_tbl *cmdtp, int flag, int argc, |
| 400 | char *const argv[]) |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 401 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 402 | u32 parent_handle = 0; |
| 403 | u32 key_len, key_handle, err; |
| 404 | u8 usage_auth[DIGEST_LENGTH]; |
| 405 | u8 parent_hash[DIGEST_LENGTH]; |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 406 | void *key; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 407 | struct udevice *dev; |
| 408 | |
Mathew McBride | e845dd7 | 2021-11-11 04:06:27 +0000 | [diff] [blame] | 409 | err = get_tpm(&dev); |
| 410 | if (err) |
| 411 | return err; |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 412 | |
| 413 | if (argc < 5) |
| 414 | return CMD_RET_USAGE; |
| 415 | |
| 416 | parse_byte_string(argv[1], parent_hash, NULL); |
| 417 | key = (void *)simple_strtoul(argv[2], NULL, 0); |
| 418 | key_len = simple_strtoul(argv[3], NULL, 0); |
| 419 | if (strlen(argv[4]) != 2 * DIGEST_LENGTH) |
| 420 | return CMD_RET_FAILURE; |
| 421 | parse_byte_string(argv[4], usage_auth, NULL); |
| 422 | |
Mathew McBride | e845dd7 | 2021-11-11 04:06:27 +0000 | [diff] [blame] | 423 | err = tpm1_find_key_sha1(dev, usage_auth, parent_hash, &parent_handle); |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 424 | if (err) { |
| 425 | printf("Could not find matching parent key (err = %d)\n", err); |
| 426 | return CMD_RET_FAILURE; |
| 427 | } |
| 428 | |
| 429 | printf("Found parent key %08x\n", parent_handle); |
| 430 | |
Mathew McBride | e845dd7 | 2021-11-11 04:06:27 +0000 | [diff] [blame] | 431 | err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth, |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 432 | &key_handle); |
| 433 | if (!err) { |
| 434 | printf("Key handle is 0x%x\n", key_handle); |
Simon Glass | 018f530 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 435 | env_set_hex("key_handle", key_handle); |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | return report_return_code(err); |
| 439 | } |
| 440 | #endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */ |
| 441 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 442 | static int do_tpm_load_key2_oiap(struct cmd_tbl *cmdtp, int flag, int argc, |
| 443 | char *const argv[]) |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 444 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 445 | u32 parent_handle, key_len, key_handle, err; |
| 446 | u8 usage_auth[DIGEST_LENGTH]; |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 447 | void *key; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 448 | struct udevice *dev; |
| 449 | int rc; |
| 450 | |
| 451 | rc = get_tpm(&dev); |
| 452 | if (rc) |
| 453 | return rc; |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 454 | |
| 455 | if (argc < 5) |
| 456 | return CMD_RET_USAGE; |
| 457 | |
| 458 | parent_handle = simple_strtoul(argv[1], NULL, 0); |
| 459 | key = (void *)simple_strtoul(argv[2], NULL, 0); |
| 460 | key_len = simple_strtoul(argv[3], NULL, 0); |
| 461 | if (strlen(argv[4]) != 2 * DIGEST_LENGTH) |
| 462 | return CMD_RET_FAILURE; |
| 463 | parse_byte_string(argv[4], usage_auth, NULL); |
| 464 | |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 465 | err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth, |
| 466 | &key_handle); |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 467 | if (!err) |
| 468 | printf("Key handle is 0x%x\n", key_handle); |
| 469 | |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 470 | return report_return_code(err); |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 471 | } |
| 472 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 473 | static int do_tpm_get_pub_key_oiap(struct cmd_tbl *cmdtp, int flag, int argc, |
| 474 | char *const argv[]) |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 475 | { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 476 | u32 key_handle, err; |
| 477 | u8 usage_auth[DIGEST_LENGTH]; |
| 478 | u8 pub_key_buffer[TPM_PUBKEY_MAX_LENGTH]; |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 479 | size_t pub_key_len = sizeof(pub_key_buffer); |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 480 | struct udevice *dev; |
| 481 | int rc; |
| 482 | |
| 483 | rc = get_tpm(&dev); |
| 484 | if (rc) |
| 485 | return rc; |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 486 | |
| 487 | if (argc < 3) |
| 488 | return CMD_RET_USAGE; |
| 489 | |
| 490 | key_handle = simple_strtoul(argv[1], NULL, 0); |
| 491 | if (strlen(argv[2]) != 2 * DIGEST_LENGTH) |
| 492 | return CMD_RET_FAILURE; |
| 493 | parse_byte_string(argv[2], usage_auth, NULL); |
| 494 | |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 495 | err = tpm1_get_pub_key_oiap(dev, key_handle, usage_auth, pub_key_buffer, |
| 496 | &pub_key_len); |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 497 | if (!err) { |
| 498 | printf("dump of received pub key structure:\n"); |
| 499 | print_byte_string(pub_key_buffer, pub_key_len); |
| 500 | } |
Simon Glass | f8f1fe1 | 2015-08-22 18:31:34 -0600 | [diff] [blame] | 501 | return report_return_code(err); |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 502 | } |
| 503 | |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 504 | TPM_COMMAND_NO_ARG(tpm1_end_oiap) |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 505 | |
| 506 | #endif /* CONFIG_TPM_AUTH_SESSIONS */ |
| 507 | |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 508 | #ifdef CONFIG_TPM_FLUSH_RESOURCES |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 509 | static int do_tpm_flush(struct cmd_tbl *cmdtp, int flag, int argc, |
| 510 | char *const argv[]) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 511 | { |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 512 | struct udevice *dev; |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 513 | int type = 0; |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 514 | int rc; |
| 515 | |
| 516 | rc = get_tpm(&dev); |
| 517 | if (rc) |
| 518 | return rc; |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 519 | |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 520 | if (argc != 3) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 521 | return CMD_RET_USAGE; |
| 522 | |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 523 | if (!strcasecmp(argv[1], "key")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 524 | type = TPM_RT_KEY; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 525 | else if (!strcasecmp(argv[1], "auth")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 526 | type = TPM_RT_AUTH; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 527 | else if (!strcasecmp(argv[1], "hash")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 528 | type = TPM_RT_HASH; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 529 | else if (!strcasecmp(argv[1], "trans")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 530 | type = TPM_RT_TRANS; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 531 | else if (!strcasecmp(argv[1], "context")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 532 | type = TPM_RT_CONTEXT; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 533 | else if (!strcasecmp(argv[1], "counter")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 534 | type = TPM_RT_COUNTER; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 535 | else if (!strcasecmp(argv[1], "delegate")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 536 | type = TPM_RT_DELEGATE; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 537 | else if (!strcasecmp(argv[1], "daa_tpm")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 538 | type = TPM_RT_DAA_TPM; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 539 | else if (!strcasecmp(argv[1], "daa_v0")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 540 | type = TPM_RT_DAA_V0; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 541 | else if (!strcasecmp(argv[1], "daa_v1")) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 542 | type = TPM_RT_DAA_V1; |
| 543 | |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 544 | if (!type) { |
| 545 | printf("Resource type %s unknown.\n", argv[1]); |
| 546 | return -1; |
| 547 | } |
| 548 | |
| 549 | if (!strcasecmp(argv[2], "all")) { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 550 | u16 res_count; |
| 551 | u8 buf[288]; |
| 552 | u8 *ptr; |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 553 | int err; |
| 554 | uint i; |
| 555 | |
| 556 | /* fetch list of already loaded resources in the TPM */ |
Simon Glass | abdc7b8 | 2018-11-18 14:22:27 -0700 | [diff] [blame] | 557 | err = tpm_get_capability(dev, TPM_CAP_HANDLE, type, buf, |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 558 | sizeof(buf)); |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 559 | if (err) { |
| 560 | printf("tpm_get_capability returned error %d.\n", err); |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 561 | return -1; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 562 | } |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 563 | res_count = get_unaligned_be16(buf); |
| 564 | ptr = buf + 2; |
| 565 | for (i = 0; i < res_count; ++i, ptr += 4) |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 566 | tpm1_flush_specific(dev, get_unaligned_be32(ptr), type); |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 567 | } else { |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 568 | u32 handle = simple_strtoul(argv[2], NULL, 0); |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 569 | |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 570 | if (!handle) { |
| 571 | printf("Illegal resource handle %s\n", argv[2]); |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 572 | return -1; |
mario.six@gdsys.cc | 1c08b21 | 2017-03-20 10:28:29 +0100 | [diff] [blame] | 573 | } |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 574 | tpm1_flush_specific(dev, cpu_to_be32(handle), type); |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | return 0; |
| 578 | } |
| 579 | #endif /* CONFIG_TPM_FLUSH_RESOURCES */ |
| 580 | |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 581 | #ifdef CONFIG_TPM_LIST_RESOURCES |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 582 | static int do_tpm_list(struct cmd_tbl *cmdtp, int flag, int argc, |
| 583 | char *const argv[]) |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 584 | { |
Mathew McBride | ebb6d74 | 2021-11-11 04:06:26 +0000 | [diff] [blame] | 585 | struct udevice *dev; |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 586 | int type = 0; |
Miquel Raynal | b9804e5 | 2018-05-15 11:56:59 +0200 | [diff] [blame] | 587 | u16 res_count; |
| 588 | u8 buf[288]; |
| 589 | u8 *ptr; |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 590 | int err; |
| 591 | uint i; |
| 592 | |
Mathew McBride | ebb6d74 | 2021-11-11 04:06:26 +0000 | [diff] [blame] | 593 | err = get_tpm(&dev); |
| 594 | if (err) |
| 595 | return err; |
| 596 | |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 597 | if (argc != 2) |
| 598 | return CMD_RET_USAGE; |
| 599 | |
| 600 | if (!strcasecmp(argv[1], "key")) |
| 601 | type = TPM_RT_KEY; |
| 602 | else if (!strcasecmp(argv[1], "auth")) |
| 603 | type = TPM_RT_AUTH; |
| 604 | else if (!strcasecmp(argv[1], "hash")) |
| 605 | type = TPM_RT_HASH; |
| 606 | else if (!strcasecmp(argv[1], "trans")) |
| 607 | type = TPM_RT_TRANS; |
| 608 | else if (!strcasecmp(argv[1], "context")) |
| 609 | type = TPM_RT_CONTEXT; |
| 610 | else if (!strcasecmp(argv[1], "counter")) |
| 611 | type = TPM_RT_COUNTER; |
| 612 | else if (!strcasecmp(argv[1], "delegate")) |
| 613 | type = TPM_RT_DELEGATE; |
| 614 | else if (!strcasecmp(argv[1], "daa_tpm")) |
| 615 | type = TPM_RT_DAA_TPM; |
| 616 | else if (!strcasecmp(argv[1], "daa_v0")) |
| 617 | type = TPM_RT_DAA_V0; |
| 618 | else if (!strcasecmp(argv[1], "daa_v1")) |
| 619 | type = TPM_RT_DAA_V1; |
| 620 | |
| 621 | if (!type) { |
| 622 | printf("Resource type %s unknown.\n", argv[1]); |
| 623 | return -1; |
| 624 | } |
| 625 | |
| 626 | /* fetch list of already loaded resources in the TPM */ |
Mathew McBride | ebb6d74 | 2021-11-11 04:06:26 +0000 | [diff] [blame] | 627 | err = tpm_get_capability(dev, TPM_CAP_HANDLE, type, buf, |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 628 | sizeof(buf)); |
| 629 | if (err) { |
| 630 | printf("tpm_get_capability returned error %d.\n", err); |
| 631 | return -1; |
| 632 | } |
| 633 | res_count = get_unaligned_be16(buf); |
| 634 | ptr = buf + 2; |
| 635 | |
| 636 | printf("Resources of type %s (%02x):\n", argv[1], type); |
| 637 | if (!res_count) { |
| 638 | puts("None\n"); |
| 639 | } else { |
| 640 | for (i = 0; i < res_count; ++i, ptr += 4) |
| 641 | printf("Index %d: %08x\n", i, get_unaligned_be32(ptr)); |
| 642 | } |
| 643 | |
| 644 | return 0; |
| 645 | } |
| 646 | #endif /* CONFIG_TPM_LIST_RESOURCES */ |
| 647 | |
Miquel Raynal | d677bfe | 2018-05-15 11:57:06 +0200 | [diff] [blame] | 648 | TPM_COMMAND_NO_ARG(tpm_self_test_full) |
| 649 | TPM_COMMAND_NO_ARG(tpm_continue_self_test) |
| 650 | TPM_COMMAND_NO_ARG(tpm_force_clear) |
| 651 | TPM_COMMAND_NO_ARG(tpm_physical_enable) |
| 652 | TPM_COMMAND_NO_ARG(tpm_physical_disable) |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 653 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 654 | static struct cmd_tbl tpm1_commands[] = { |
Philippe Reynes | 3780e2d | 2020-01-09 18:45:46 +0100 | [diff] [blame] | 655 | U_BOOT_CMD_MKENT(device, 0, 1, do_tpm_device, "", ""), |
Simon Glass | ad77694 | 2015-08-22 18:31:40 -0600 | [diff] [blame] | 656 | U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""), |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 657 | U_BOOT_CMD_MKENT(init, 0, 1, do_tpm_init, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 658 | U_BOOT_CMD_MKENT(startup, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 659 | do_tpm_startup, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 660 | U_BOOT_CMD_MKENT(self_test_full, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 661 | do_tpm_self_test_full, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 662 | U_BOOT_CMD_MKENT(continue_self_test, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 663 | do_tpm_continue_self_test, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 664 | U_BOOT_CMD_MKENT(force_clear, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 665 | do_tpm_force_clear, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 666 | U_BOOT_CMD_MKENT(physical_enable, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 667 | do_tpm_physical_enable, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 668 | U_BOOT_CMD_MKENT(physical_disable, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 669 | do_tpm_physical_disable, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 670 | U_BOOT_CMD_MKENT(nv_define_space, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 671 | do_tpm_nv_define_space, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 672 | U_BOOT_CMD_MKENT(nv_read_value, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 673 | do_tpm_nv_read_value, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 674 | U_BOOT_CMD_MKENT(nv_write_value, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 675 | do_tpm_nv_write_value, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 676 | U_BOOT_CMD_MKENT(extend, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 677 | do_tpm_extend, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 678 | U_BOOT_CMD_MKENT(pcr_read, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 679 | do_tpm_pcr_read, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 680 | U_BOOT_CMD_MKENT(tsc_physical_presence, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 681 | do_tpm_tsc_physical_presence, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 682 | U_BOOT_CMD_MKENT(read_pubek, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 683 | do_tpm_read_pubek, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 684 | U_BOOT_CMD_MKENT(physical_set_deactivated, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 685 | do_tpm_physical_set_deactivated, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 686 | U_BOOT_CMD_MKENT(get_capability, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 687 | do_tpm_get_capability, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 688 | U_BOOT_CMD_MKENT(raw_transfer, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 689 | do_tpm_raw_transfer, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 690 | U_BOOT_CMD_MKENT(nv_define, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 691 | do_tpm_nv_define, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 692 | U_BOOT_CMD_MKENT(nv_read, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 693 | do_tpm_nv_read, "", ""), |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 694 | U_BOOT_CMD_MKENT(nv_write, 0, 1, |
Miquel Raynal | c617918 | 2018-05-15 11:57:00 +0200 | [diff] [blame] | 695 | do_tpm_nv_write, "", ""), |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 696 | #ifdef CONFIG_TPM_AUTH_SESSIONS |
| 697 | U_BOOT_CMD_MKENT(oiap, 0, 1, |
| 698 | do_tpm_oiap, "", ""), |
| 699 | U_BOOT_CMD_MKENT(end_oiap, 0, 1, |
Simon Glass | d6a885f | 2021-02-06 14:23:36 -0700 | [diff] [blame] | 700 | do_tpm1_end_oiap, "", ""), |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 701 | U_BOOT_CMD_MKENT(load_key2_oiap, 0, 1, |
| 702 | do_tpm_load_key2_oiap, "", ""), |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 703 | #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1 |
| 704 | U_BOOT_CMD_MKENT(load_key_by_sha1, 0, 1, |
| 705 | do_tpm_load_key_by_sha1, "", ""), |
| 706 | #endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */ |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 707 | U_BOOT_CMD_MKENT(get_pub_key_oiap, 0, 1, |
| 708 | do_tpm_get_pub_key_oiap, "", ""), |
| 709 | #endif /* CONFIG_TPM_AUTH_SESSIONS */ |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 710 | #ifdef CONFIG_TPM_FLUSH_RESOURCES |
| 711 | U_BOOT_CMD_MKENT(flush, 0, 1, |
| 712 | do_tpm_flush, "", ""), |
| 713 | #endif /* CONFIG_TPM_FLUSH_RESOURCES */ |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 714 | #ifdef CONFIG_TPM_LIST_RESOURCES |
| 715 | U_BOOT_CMD_MKENT(list, 0, 1, |
| 716 | do_tpm_list, "", ""), |
| 717 | #endif /* CONFIG_TPM_LIST_RESOURCES */ |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 718 | }; |
Luigi Semenzato | eea3f4d | 2012-12-05 14:46:44 +0000 | [diff] [blame] | 719 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 720 | struct cmd_tbl *get_tpm1_commands(unsigned int *size) |
Luigi Semenzato | eea3f4d | 2012-12-05 14:46:44 +0000 | [diff] [blame] | 721 | { |
Miquel Raynal | d677bfe | 2018-05-15 11:57:06 +0200 | [diff] [blame] | 722 | *size = ARRAY_SIZE(tpm1_commands); |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 723 | |
Miquel Raynal | d677bfe | 2018-05-15 11:57:06 +0200 | [diff] [blame] | 724 | return tpm1_commands; |
Luigi Semenzato | eea3f4d | 2012-12-05 14:46:44 +0000 | [diff] [blame] | 725 | } |
| 726 | |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 727 | U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm, |
Miquel Raynal | d677bfe | 2018-05-15 11:57:06 +0200 | [diff] [blame] | 728 | "Issue a TPMv1.x command", |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 729 | "cmd args...\n" |
| 730 | " - Issue TPM command <cmd> with arguments <args...>.\n" |
| 731 | "Admin Startup and State Commands:\n" |
Philippe Reynes | 3780e2d | 2020-01-09 18:45:46 +0100 | [diff] [blame] | 732 | " device [num device]\n" |
| 733 | " - Show all devices or set the specified device\n" |
Simon Glass | ad77694 | 2015-08-22 18:31:40 -0600 | [diff] [blame] | 734 | " info - Show information about the TPM\n" |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 735 | " init\n" |
| 736 | " - Put TPM into a state where it waits for 'startup' command.\n" |
| 737 | " startup mode\n" |
| 738 | " - Issue TPM_Starup command. <mode> is one of TPM_ST_CLEAR,\n" |
| 739 | " TPM_ST_STATE, and TPM_ST_DEACTIVATED.\n" |
| 740 | "Admin Testing Commands:\n" |
| 741 | " self_test_full\n" |
| 742 | " - Test all of the TPM capabilities.\n" |
| 743 | " continue_self_test\n" |
| 744 | " - Inform TPM that it should complete the self-test.\n" |
| 745 | "Admin Opt-in Commands:\n" |
| 746 | " physical_enable\n" |
| 747 | " - Set the PERMANENT disable flag to FALSE using physical presence as\n" |
| 748 | " authorization.\n" |
| 749 | " physical_disable\n" |
| 750 | " - Set the PERMANENT disable flag to TRUE using physical presence as\n" |
| 751 | " authorization.\n" |
| 752 | " physical_set_deactivated 0|1\n" |
| 753 | " - Set deactivated flag.\n" |
| 754 | "Admin Ownership Commands:\n" |
| 755 | " force_clear\n" |
| 756 | " - Issue TPM_ForceClear command.\n" |
| 757 | " tsc_physical_presence flags\n" |
| 758 | " - Set TPM device's Physical Presence flags to <flags>.\n" |
| 759 | "The Capability Commands:\n" |
| 760 | " get_capability cap_area sub_cap addr count\n" |
| 761 | " - Read <count> bytes of TPM capability indexed by <cap_area> and\n" |
| 762 | " <sub_cap> to memory address <addr>.\n" |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 763 | #if defined(CONFIG_TPM_FLUSH_RESOURCES) || defined(CONFIG_TPM_LIST_RESOURCES) |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 764 | "Resource management functions\n" |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 765 | #endif |
| 766 | #ifdef CONFIG_TPM_FLUSH_RESOURCES |
Mario Six | 7690be3 | 2017-01-11 16:00:50 +0100 | [diff] [blame] | 767 | " flush resource_type id\n" |
| 768 | " - flushes a resource of type <resource_type> (may be one of key, auth,\n" |
| 769 | " hash, trans, context, counter, delegate, daa_tpm, daa_v0, daa_v1),\n" |
| 770 | " and id <id> from the TPM. Use an <id> of \"all\" to flush all\n" |
| 771 | " resources of that type.\n" |
| 772 | #endif /* CONFIG_TPM_FLUSH_RESOURCES */ |
mario.six@gdsys.cc | 3d1df0e | 2017-03-20 10:28:30 +0100 | [diff] [blame] | 773 | #ifdef CONFIG_TPM_LIST_RESOURCES |
| 774 | " list resource_type\n" |
| 775 | " - lists resources of type <resource_type> (may be one of key, auth,\n" |
| 776 | " hash, trans, context, counter, delegate, daa_tpm, daa_v0, daa_v1),\n" |
| 777 | " contained in the TPM.\n" |
| 778 | #endif /* CONFIG_TPM_LIST_RESOURCES */ |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 779 | #ifdef CONFIG_TPM_AUTH_SESSIONS |
| 780 | "Storage functions\n" |
| 781 | " loadkey2_oiap parent_handle key_addr key_len usage_auth\n" |
| 782 | " - loads a key data from memory address <key_addr>, <key_len> bytes\n" |
| 783 | " into TPM using the parent key <parent_handle> with authorization\n" |
| 784 | " <usage_auth> (20 bytes hex string).\n" |
mario.six@gdsys.cc | 0f4b2ba | 2017-03-20 10:28:28 +0100 | [diff] [blame] | 785 | #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1 |
| 786 | " load_key_by_sha1 parent_hash key_addr key_len usage_auth\n" |
| 787 | " - loads a key data from memory address <key_addr>, <key_len> bytes\n" |
| 788 | " into TPM using the parent hash <parent_hash> (20 bytes hex string)\n" |
| 789 | " with authorization <usage_auth> (20 bytes hex string).\n" |
| 790 | #endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */ |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 791 | " get_pub_key_oiap key_handle usage_auth\n" |
| 792 | " - get the public key portion of a loaded key <key_handle> using\n" |
| 793 | " authorization <usage auth> (20 bytes hex string)\n" |
| 794 | #endif /* CONFIG_TPM_AUTH_SESSIONS */ |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 795 | "Endorsement Key Handling Commands:\n" |
| 796 | " read_pubek addr count\n" |
| 797 | " - Read <count> bytes of the public endorsement key to memory\n" |
| 798 | " address <addr>\n" |
| 799 | "Integrity Collection and Reporting Commands:\n" |
| 800 | " extend index digest_hex_string\n" |
| 801 | " - Add a new measurement to a PCR. Update PCR <index> with the 20-bytes\n" |
| 802 | " <digest_hex_string>\n" |
| 803 | " pcr_read index addr count\n" |
| 804 | " - Read <count> bytes from PCR <index> to memory address <addr>.\n" |
Reinhard Pfau | be6c152 | 2013-06-26 15:55:13 +0200 | [diff] [blame] | 805 | #ifdef CONFIG_TPM_AUTH_SESSIONS |
| 806 | "Authorization Sessions\n" |
| 807 | " oiap\n" |
| 808 | " - setup an OIAP session\n" |
| 809 | " end_oiap\n" |
| 810 | " - terminates an active OIAP session\n" |
| 811 | #endif /* CONFIG_TPM_AUTH_SESSIONS */ |
Che-liang Chiou | 8732b07 | 2013-02-28 09:34:57 +0000 | [diff] [blame] | 812 | "Non-volatile Storage Commands:\n" |
| 813 | " nv_define_space index permission size\n" |
| 814 | " - Establish a space at index <index> with <permission> of <size> bytes.\n" |
| 815 | " nv_read_value index addr count\n" |
| 816 | " - Read <count> bytes from space <index> to memory address <addr>.\n" |
| 817 | " nv_write_value index addr count\n" |
| 818 | " - Write <count> bytes from memory address <addr> to space <index>.\n" |
| 819 | "Miscellaneous helper functions:\n" |
| 820 | " raw_transfer byte_string\n" |
| 821 | " - Send a byte string <byte_string> to TPM and print the response.\n" |
| 822 | " Non-volatile storage helper functions:\n" |
| 823 | " These helper functions treat a non-volatile space as a non-padded\n" |
| 824 | " sequence of integer values. These integer values are defined by a type\n" |
| 825 | " string, which is a text string of 'bwd' characters: 'b' means a 8-bit\n" |
| 826 | " value, 'w' 16-bit value, 'd' 32-bit value. All helper functions take\n" |
| 827 | " a type string as their first argument.\n" |
| 828 | " nv_define type_string index perm\n" |
| 829 | " - Define a space <index> with permission <perm>.\n" |
| 830 | " nv_read types_string index vars...\n" |
| 831 | " - Read from space <index> to environment variables <vars...>.\n" |
| 832 | " nv_write types_string index values...\n" |
| 833 | " - Write to space <index> from values <values...>.\n" |
Luigi Semenzato | eea3f4d | 2012-12-05 14:46:44 +0000 | [diff] [blame] | 834 | ); |