Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/tlcl/generator.c

Issue 2854029: Add PhysicalDisable command. (Closed) Base URL: ssh://git@chromiumos-git/tpm_lite.git
Patch Set: . Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/tlcl/structures.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* This program generates partially filled TPM datagrams and other compile-time 6 /* This program generates partially filled TPM datagrams and other compile-time
7 * constants (e.g. structure sizes and offsets). Compile this file---and ONLY 7 * constants (e.g. structure sizes and offsets). Compile this file---and ONLY
8 * this file---with -fpack-struct. We take advantage of the fact that the 8 * this file---with -fpack-struct. We take advantage of the fact that the
9 * (packed) TPM structures layout (mostly) match the TPM request and response 9 * (packed) TPM structures layout (mostly) match the TPM request and response
10 * datagram layout. When they don't completely match, some fixing is necessary 10 * datagram layout. When they don't completely match, some fixing is necessary
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int size = kTpmRequestHeaderLength; 211 int size = kTpmRequestHeaderLength;
212 Command* cmd = newCommand(TPM_ORD_ContinueSelfTest, size); 212 Command* cmd = newCommand(TPM_ORD_ContinueSelfTest, size);
213 cmd->name = "tpm_continueselftest_cmd"; 213 cmd->name = "tpm_continueselftest_cmd";
214 return cmd; 214 return cmd;
215 } 215 }
216 216
217 Command* BuildReadPubekCommand(void) { 217 Command* BuildReadPubekCommand(void) {
218 int size = kTpmRequestHeaderLength + sizeof(TPM_NONCE); 218 int size = kTpmRequestHeaderLength + sizeof(TPM_NONCE);
219 Command* cmd = newCommand(TPM_ORD_ReadPubek, size); 219 Command* cmd = newCommand(TPM_ORD_ReadPubek, size);
220 cmd->name = "tpm_readpubek_cmd"; 220 cmd->name = "tpm_readpubek_cmd";
221 return cmd; 221 return cmd;
222 } 222 }
223 223
224 Command* BuildForceClearCommand(void) { 224 Command* BuildForceClearCommand(void) {
225 int size = kTpmRequestHeaderLength; 225 int size = kTpmRequestHeaderLength;
226 Command* cmd = newCommand(TPM_ORD_ForceClear, size); 226 Command* cmd = newCommand(TPM_ORD_ForceClear, size);
227 cmd->name = "tpm_forceclear_cmd"; 227 cmd->name = "tpm_forceclear_cmd";
228 return cmd; 228 return cmd;
229 } 229 }
230 230
231 Command* BuildPhysicalEnableCommand(void) { 231 Command* BuildPhysicalEnableCommand(void) {
232 int size = kTpmRequestHeaderLength; 232 int size = kTpmRequestHeaderLength;
233 Command* cmd = newCommand(TPM_ORD_PhysicalEnable, size); 233 Command* cmd = newCommand(TPM_ORD_PhysicalEnable, size);
234 cmd->name = "tpm_physicalenable_cmd"; 234 cmd->name = "tpm_physicalenable_cmd";
235 return cmd; 235 return cmd;
236 }
237
238 Command* BuildPhysicalDisableCommand(void) {
239 int size = kTpmRequestHeaderLength;
240 Command* cmd = newCommand(TPM_ORD_PhysicalDisable, size);
241 cmd->name = "tpm_physicaldisable_cmd";
242 return cmd;
236 } 243 }
237 244
238 Command* BuildPhysicalSetDeactivatedCommand(void) { 245 Command* BuildPhysicalSetDeactivatedCommand(void) {
239 int size = kTpmRequestHeaderLength + sizeof(uint8_t); 246 int size = kTpmRequestHeaderLength + sizeof(uint8_t);
240 Command* cmd = newCommand(TPM_ORD_PhysicalSetDeactivated, size); 247 Command* cmd = newCommand(TPM_ORD_PhysicalSetDeactivated, size);
241 cmd->name = "tpm_physicalsetdeactivated_cmd"; 248 cmd->name = "tpm_physicalsetdeactivated_cmd";
242 AddVisibleField(cmd, "deactivated", kTpmRequestHeaderLength); 249 AddVisibleField(cmd, "deactivated", kTpmRequestHeaderLength);
243 return cmd; 250 return cmd;
244 } 251 }
245 252
246 Command* BuildExtendCommand(void) { 253 Command* BuildExtendCommand(void) {
247 int size = kTpmRequestHeaderLength + sizeof(uint32_t) + kPcrDigestLength; 254 int size = kTpmRequestHeaderLength + sizeof(uint32_t) + kPcrDigestLength;
248 Command* cmd = newCommand(TPM_ORD_Extend, size); 255 Command* cmd = newCommand(TPM_ORD_Extend, size);
249 cmd->name = "tpm_extend_cmd"; 256 cmd->name = "tpm_extend_cmd";
250 AddVisibleField(cmd, "pcrNum", kTpmRequestHeaderLength); 257 AddVisibleField(cmd, "pcrNum", kTpmRequestHeaderLength);
251 AddVisibleField(cmd, "inDigest", kTpmRequestHeaderLength + sizeof(uint32_t)); 258 AddVisibleField(cmd, "inDigest", kTpmRequestHeaderLength + sizeof(uint32_t));
252 return cmd; 259 return cmd;
253 } 260 }
254 261
255 Command* BuildGetFlagsCommand(void) { 262 Command* BuildGetFlagsCommand(void) {
256 int size = (kTpmRequestHeaderLength + 263 int size = (kTpmRequestHeaderLength +
257 sizeof(TPM_CAPABILITY_AREA) + /* capArea */ 264 sizeof(TPM_CAPABILITY_AREA) + /* capArea */
258 sizeof(uint32_t) + /* subCapSize */ 265 sizeof(uint32_t) + /* subCapSize */
259 sizeof(uint32_t)); /* subCap */ 266 sizeof(uint32_t)); /* subCap */
260 267
261 Command* cmd = newCommand(TPM_ORD_GetCapability, size); 268 Command* cmd = newCommand(TPM_ORD_GetCapability, size);
262 cmd->name = "tpm_getflags_cmd"; 269 cmd->name = "tpm_getflags_cmd";
263 AddInitializedField(cmd, kTpmRequestHeaderLength, 270 AddInitializedField(cmd, kTpmRequestHeaderLength,
264 sizeof(TPM_CAPABILITY_AREA), TPM_CAP_FLAG); 271 sizeof(TPM_CAPABILITY_AREA), TPM_CAP_FLAG);
265 AddInitializedField(cmd, kTpmRequestHeaderLength + 272 AddInitializedField(cmd, kTpmRequestHeaderLength +
266 sizeof(TPM_CAPABILITY_AREA), 273 sizeof(TPM_CAPABILITY_AREA),
267 sizeof(uint32_t), sizeof(uint32_t)); 274 sizeof(uint32_t), sizeof(uint32_t));
268 AddInitializedField(cmd, kTpmRequestHeaderLength + 275 AddInitializedField(cmd, kTpmRequestHeaderLength +
269 sizeof(TPM_CAPABILITY_AREA) + sizeof(uint32_t), 276 sizeof(TPM_CAPABILITY_AREA) + sizeof(uint32_t),
270 sizeof(uint32_t), TPM_CAP_FLAG_PERMANENT); 277 sizeof(uint32_t), TPM_CAP_FLAG_PERMANENT);
271 return cmd; 278 return cmd;
272 } 279 }
273 280
274 Command* BuildGetPermissionsCommand(void) { 281 Command* BuildGetPermissionsCommand(void) {
275 int size = (kTpmRequestHeaderLength + 282 int size = (kTpmRequestHeaderLength +
276 sizeof(TPM_CAPABILITY_AREA) + /* capArea */ 283 sizeof(TPM_CAPABILITY_AREA) + /* capArea */
277 sizeof(uint32_t) + /* subCapSize */ 284 sizeof(uint32_t) + /* subCapSize */
278 sizeof(uint32_t)); /* subCap */ 285 sizeof(uint32_t)); /* subCap */
279 286
280 Command* cmd = newCommand(TPM_ORD_GetCapability, size); 287 Command* cmd = newCommand(TPM_ORD_GetCapability, size);
281 cmd->name = "tpm_getpermissions_cmd"; 288 cmd->name = "tpm_getpermissions_cmd";
282 AddInitializedField(cmd, kTpmRequestHeaderLength, 289 AddInitializedField(cmd, kTpmRequestHeaderLength,
283 sizeof(TPM_CAPABILITY_AREA), TPM_CAP_NV_INDEX); 290 sizeof(TPM_CAPABILITY_AREA), TPM_CAP_NV_INDEX);
284 AddInitializedField(cmd, kTpmRequestHeaderLength + 291 AddInitializedField(cmd, kTpmRequestHeaderLength +
285 sizeof(TPM_CAPABILITY_AREA), 292 sizeof(TPM_CAPABILITY_AREA),
286 sizeof(uint32_t), sizeof(uint32_t)); 293 sizeof(uint32_t), sizeof(uint32_t));
287 AddVisibleField(cmd, "index", kTpmRequestHeaderLength + 294 AddVisibleField(cmd, "index", kTpmRequestHeaderLength +
288 sizeof(TPM_CAPABILITY_AREA) + sizeof(uint32_t)); 295 sizeof(TPM_CAPABILITY_AREA) + sizeof(uint32_t));
289 return cmd; 296 return cmd;
290 } 297 }
291 298
292 /* Output the fields of a structure. 299 /* Output the fields of a structure.
293 */ 300 */
294 void OutputFields(Field* fld) { 301 void OutputFields(Field* fld) {
295 /* 302 /*
296 * Field order is reversed. 303 * Field order is reversed.
297 */ 304 */
298 if (fld != NULL) { 305 if (fld != NULL) {
299 OutputFields(fld->next); 306 OutputFields(fld->next);
(...skipping 29 matching lines...) Expand all
329 case 1: 336 case 1:
330 printf("0x%x, ", fld->value); 337 printf("0x%x, ", fld->value);
331 cursor += 1; 338 cursor += 1;
332 break; 339 break;
333 case 2: 340 case 2:
334 printf("0x%x, 0x%x, ", fld->value >> 8, fld->value & 0xff); 341 printf("0x%x, 0x%x, ", fld->value >> 8, fld->value & 0xff);
335 cursor += 2; 342 cursor += 2;
336 break; 343 break;
337 case 4: 344 case 4:
338 printf("0x%x, 0x%x, 0x%x, 0x%x, ", fld->value >> 24, 345 printf("0x%x, 0x%x, 0x%x, 0x%x, ", fld->value >> 24,
339 (fld->value >> 16) & 0xff, 346 (fld->value >> 16) & 0xff,
340 (fld->value >> 8) & 0xff, 347 (fld->value >> 8) & 0xff,
341 fld->value & 0xff); 348 fld->value & 0xff);
342 cursor += 4; 349 cursor += 4;
343 break; 350 break;
344 default: 351 default:
345 error("invalid field size %d\n", fld->size); 352 error("invalid field size %d\n", fld->size);
346 break; 353 break;
347 } 354 }
348 } 355 }
349 return cursor; 356 return cursor;
350 } 357 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 BuildDefineSpaceCommand, 395 BuildDefineSpaceCommand,
389 BuildWriteCommand, 396 BuildWriteCommand,
390 BuildReadCommand, 397 BuildReadCommand,
391 BuildPPAssertCommand, 398 BuildPPAssertCommand,
392 BuildPPLockCommand, 399 BuildPPLockCommand,
393 BuildStartupCommand, 400 BuildStartupCommand,
394 BuildSelftestfullCommand, 401 BuildSelftestfullCommand,
395 BuildContinueSelfTestCommand, 402 BuildContinueSelfTestCommand,
396 BuildReadPubekCommand, 403 BuildReadPubekCommand,
397 BuildForceClearCommand, 404 BuildForceClearCommand,
405 BuildPhysicalDisableCommand,
398 BuildPhysicalEnableCommand, 406 BuildPhysicalEnableCommand,
399 BuildPhysicalSetDeactivatedCommand, 407 BuildPhysicalSetDeactivatedCommand,
400 BuildGetFlagsCommand, 408 BuildGetFlagsCommand,
401 BuildGetPermissionsCommand, 409 BuildGetPermissionsCommand,
402 BuildExtendCommand, 410 BuildExtendCommand,
403 }; 411 };
404 412
405 static void FreeFields(Field* fld) { 413 static void FreeFields(Field* fld) {
406 if (fld != NULL) { 414 if (fld != NULL) {
407 Field* next_field = fld->next; 415 Field* next_field = fld->next;
(...skipping 24 matching lines...) Expand all
432 OutputCommands(commands); 440 OutputCommands(commands);
433 printf("const int kWriteInfoLength = %d;\n", (int) sizeof(TPM_WRITE_INFO)); 441 printf("const int kWriteInfoLength = %d;\n", (int) sizeof(TPM_WRITE_INFO));
434 printf("const int kNvDataPublicPermissionsOffset = %d;\n", 442 printf("const int kNvDataPublicPermissionsOffset = %d;\n",
435 (int) (offsetof(TPM_NV_DATA_PUBLIC, permission) + 443 (int) (offsetof(TPM_NV_DATA_PUBLIC, permission) +
436 2 * PCR_SELECTION_FIX + 444 2 * PCR_SELECTION_FIX +
437 offsetof(TPM_NV_ATTRIBUTES, attributes))); 445 offsetof(TPM_NV_ATTRIBUTES, attributes)));
438 446
439 FreeCommands(commands); 447 FreeCommands(commands);
440 return 0; 448 return 0;
441 } 449 }
OLDNEW
« no previous file with comments | « no previous file | src/tlcl/structures.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698