1 /* 2 * Copyright (c) 2015 Google, Inc 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #ifndef __tpm_internal_h 8 #define __tpm_internal_h 9 10 enum { 11 TPM_MAX_ORDINAL = 243, 12 TPM_MAX_PROTECTED_ORDINAL = 12, 13 TPM_PROTECTED_ORDINAL_MASK = 0xff, 14 TPM_CMD_COUNT_BYTE = 2, 15 TPM_CMD_ORDINAL_BYTE = 6, 16 }; 17 18 /* 19 * Array with one entry per ordinal defining the maximum amount 20 * of time the chip could take to return the result. The ordinal 21 * designation of short, medium or long is defined in a table in 22 * TCG Specification TPM Main Part 2 TPM Structures Section 17. The 23 * values of the SHORT, MEDIUM, and LONG durations are retrieved 24 * from the chip during initialization with a call to tpm_get_timeouts. 25 */ 26 static const u8 tpm_protected_ordinal_duration[TPM_MAX_PROTECTED_ORDINAL] = { 27 TPM_UNDEFINED, /* 0 */ 28 TPM_UNDEFINED, 29 TPM_UNDEFINED, 30 TPM_UNDEFINED, 31 TPM_UNDEFINED, 32 TPM_UNDEFINED, /* 5 */ 33 TPM_UNDEFINED, 34 TPM_UNDEFINED, 35 TPM_UNDEFINED, 36 TPM_UNDEFINED, 37 TPM_SHORT, /* 10 */ 38 TPM_SHORT, 39 }; 40 41 static const u8 tpm_ordinal_duration[TPM_MAX_ORDINAL] = { 42 TPM_UNDEFINED, /* 0 */ 43 TPM_UNDEFINED, 44 TPM_UNDEFINED, 45 TPM_UNDEFINED, 46 TPM_UNDEFINED, 47 TPM_UNDEFINED, /* 5 */ 48 TPM_UNDEFINED, 49 TPM_UNDEFINED, 50 TPM_UNDEFINED, 51 TPM_UNDEFINED, 52 TPM_SHORT, /* 10 */ 53 TPM_SHORT, 54 TPM_MEDIUM, 55 TPM_LONG, 56 TPM_LONG, 57 TPM_MEDIUM, /* 15 */ 58 TPM_SHORT, 59 TPM_SHORT, 60 TPM_MEDIUM, 61 TPM_LONG, 62 TPM_SHORT, /* 20 */ 63 TPM_SHORT, 64 TPM_MEDIUM, 65 TPM_MEDIUM, 66 TPM_MEDIUM, 67 TPM_SHORT, /* 25 */ 68 TPM_SHORT, 69 TPM_MEDIUM, 70 TPM_SHORT, 71 TPM_SHORT, 72 TPM_MEDIUM, /* 30 */ 73 TPM_LONG, 74 TPM_MEDIUM, 75 TPM_SHORT, 76 TPM_SHORT, 77 TPM_SHORT, /* 35 */ 78 TPM_MEDIUM, 79 TPM_MEDIUM, 80 TPM_UNDEFINED, 81 TPM_UNDEFINED, 82 TPM_MEDIUM, /* 40 */ 83 TPM_LONG, 84 TPM_MEDIUM, 85 TPM_SHORT, 86 TPM_SHORT, 87 TPM_SHORT, /* 45 */ 88 TPM_SHORT, 89 TPM_SHORT, 90 TPM_SHORT, 91 TPM_LONG, 92 TPM_MEDIUM, /* 50 */ 93 TPM_MEDIUM, 94 TPM_UNDEFINED, 95 TPM_UNDEFINED, 96 TPM_UNDEFINED, 97 TPM_UNDEFINED, /* 55 */ 98 TPM_UNDEFINED, 99 TPM_UNDEFINED, 100 TPM_UNDEFINED, 101 TPM_UNDEFINED, 102 TPM_MEDIUM, /* 60 */ 103 TPM_MEDIUM, 104 TPM_MEDIUM, 105 TPM_SHORT, 106 TPM_SHORT, 107 TPM_MEDIUM, /* 65 */ 108 TPM_UNDEFINED, 109 TPM_UNDEFINED, 110 TPM_UNDEFINED, 111 TPM_UNDEFINED, 112 TPM_SHORT, /* 70 */ 113 TPM_SHORT, 114 TPM_UNDEFINED, 115 TPM_UNDEFINED, 116 TPM_UNDEFINED, 117 TPM_UNDEFINED, /* 75 */ 118 TPM_UNDEFINED, 119 TPM_UNDEFINED, 120 TPM_UNDEFINED, 121 TPM_UNDEFINED, 122 TPM_LONG, /* 80 */ 123 TPM_UNDEFINED, 124 TPM_MEDIUM, 125 TPM_LONG, 126 TPM_SHORT, 127 TPM_UNDEFINED, /* 85 */ 128 TPM_UNDEFINED, 129 TPM_UNDEFINED, 130 TPM_UNDEFINED, 131 TPM_UNDEFINED, 132 TPM_SHORT, /* 90 */ 133 TPM_SHORT, 134 TPM_SHORT, 135 TPM_SHORT, 136 TPM_SHORT, 137 TPM_UNDEFINED, /* 95 */ 138 TPM_UNDEFINED, 139 TPM_UNDEFINED, 140 TPM_UNDEFINED, 141 TPM_UNDEFINED, 142 TPM_MEDIUM, /* 100 */ 143 TPM_SHORT, 144 TPM_SHORT, 145 TPM_UNDEFINED, 146 TPM_UNDEFINED, 147 TPM_UNDEFINED, /* 105 */ 148 TPM_UNDEFINED, 149 TPM_UNDEFINED, 150 TPM_UNDEFINED, 151 TPM_UNDEFINED, 152 TPM_SHORT, /* 110 */ 153 TPM_SHORT, 154 TPM_SHORT, 155 TPM_SHORT, 156 TPM_SHORT, 157 TPM_SHORT, /* 115 */ 158 TPM_SHORT, 159 TPM_SHORT, 160 TPM_UNDEFINED, 161 TPM_UNDEFINED, 162 TPM_LONG, /* 120 */ 163 TPM_LONG, 164 TPM_MEDIUM, 165 TPM_UNDEFINED, 166 TPM_SHORT, 167 TPM_SHORT, /* 125 */ 168 TPM_SHORT, 169 TPM_LONG, 170 TPM_SHORT, 171 TPM_SHORT, 172 TPM_SHORT, /* 130 */ 173 TPM_MEDIUM, 174 TPM_UNDEFINED, 175 TPM_SHORT, 176 TPM_MEDIUM, 177 TPM_UNDEFINED, /* 135 */ 178 TPM_UNDEFINED, 179 TPM_UNDEFINED, 180 TPM_UNDEFINED, 181 TPM_UNDEFINED, 182 TPM_SHORT, /* 140 */ 183 TPM_SHORT, 184 TPM_UNDEFINED, 185 TPM_UNDEFINED, 186 TPM_UNDEFINED, 187 TPM_UNDEFINED, /* 145 */ 188 TPM_UNDEFINED, 189 TPM_UNDEFINED, 190 TPM_UNDEFINED, 191 TPM_UNDEFINED, 192 TPM_SHORT, /* 150 */ 193 TPM_MEDIUM, 194 TPM_MEDIUM, 195 TPM_SHORT, 196 TPM_SHORT, 197 TPM_UNDEFINED, /* 155 */ 198 TPM_UNDEFINED, 199 TPM_UNDEFINED, 200 TPM_UNDEFINED, 201 TPM_UNDEFINED, 202 TPM_SHORT, /* 160 */ 203 TPM_SHORT, 204 TPM_SHORT, 205 TPM_SHORT, 206 TPM_UNDEFINED, 207 TPM_UNDEFINED, /* 165 */ 208 TPM_UNDEFINED, 209 TPM_UNDEFINED, 210 TPM_UNDEFINED, 211 TPM_UNDEFINED, 212 TPM_LONG, /* 170 */ 213 TPM_UNDEFINED, 214 TPM_UNDEFINED, 215 TPM_UNDEFINED, 216 TPM_UNDEFINED, 217 TPM_UNDEFINED, /* 175 */ 218 TPM_UNDEFINED, 219 TPM_UNDEFINED, 220 TPM_UNDEFINED, 221 TPM_UNDEFINED, 222 TPM_MEDIUM, /* 180 */ 223 TPM_SHORT, 224 TPM_MEDIUM, 225 TPM_MEDIUM, 226 TPM_MEDIUM, 227 TPM_MEDIUM, /* 185 */ 228 TPM_SHORT, 229 TPM_UNDEFINED, 230 TPM_UNDEFINED, 231 TPM_UNDEFINED, 232 TPM_UNDEFINED, /* 190 */ 233 TPM_UNDEFINED, 234 TPM_UNDEFINED, 235 TPM_UNDEFINED, 236 TPM_UNDEFINED, 237 TPM_UNDEFINED, /* 195 */ 238 TPM_UNDEFINED, 239 TPM_UNDEFINED, 240 TPM_UNDEFINED, 241 TPM_UNDEFINED, 242 TPM_SHORT, /* 200 */ 243 TPM_UNDEFINED, 244 TPM_UNDEFINED, 245 TPM_UNDEFINED, 246 TPM_SHORT, 247 TPM_SHORT, /* 205 */ 248 TPM_SHORT, 249 TPM_SHORT, 250 TPM_SHORT, 251 TPM_SHORT, 252 TPM_MEDIUM, /* 210 */ 253 TPM_UNDEFINED, 254 TPM_MEDIUM, 255 TPM_MEDIUM, 256 TPM_MEDIUM, 257 TPM_UNDEFINED, /* 215 */ 258 TPM_MEDIUM, 259 TPM_UNDEFINED, 260 TPM_UNDEFINED, 261 TPM_SHORT, 262 TPM_SHORT, /* 220 */ 263 TPM_SHORT, 264 TPM_SHORT, 265 TPM_SHORT, 266 TPM_SHORT, 267 TPM_UNDEFINED, /* 225 */ 268 TPM_UNDEFINED, 269 TPM_UNDEFINED, 270 TPM_UNDEFINED, 271 TPM_UNDEFINED, 272 TPM_SHORT, /* 230 */ 273 TPM_LONG, 274 TPM_MEDIUM, 275 TPM_UNDEFINED, 276 TPM_UNDEFINED, 277 TPM_UNDEFINED, /* 235 */ 278 TPM_UNDEFINED, 279 TPM_UNDEFINED, 280 TPM_UNDEFINED, 281 TPM_UNDEFINED, 282 TPM_SHORT, /* 240 */ 283 TPM_UNDEFINED, 284 TPM_MEDIUM, 285 }; 286 287 #endif 288