OLD | NEW |
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } | 424 } |
425 } | 425 } |
426 } | 426 } |
427 | 427 |
428 /* Outputs the structure initializers for all commands. | 428 /* Outputs the structure initializers for all commands. |
429 */ | 429 */ |
430 void OutputCommands(Command* cmd) { | 430 void OutputCommands(Command* cmd) { |
431 if (cmd == NULL) { | 431 if (cmd == NULL) { |
432 return; | 432 return; |
433 } else { | 433 } else { |
434 printf("struct s_%s{\n uint8_t buffer[%d];\n", | 434 printf("const struct s_%s{\n uint8_t buffer[%d];\n", |
435 cmd->name, cmd->size == 0 ? cmd->max_size : cmd->size); | 435 cmd->name, cmd->size == 0 ? cmd->max_size : cmd->size); |
436 OutputFields(cmd->fields); | 436 OutputFields(cmd->fields); |
437 printf("} %s = {{", cmd->name); | 437 printf("} %s = {{", cmd->name); |
438 OutputBytes(cmd); | 438 OutputBytes(cmd); |
439 printf("},\n"); | 439 printf("},\n"); |
440 OutputFieldPointers(cmd, cmd->fields); | 440 OutputFieldPointers(cmd, cmd->fields); |
441 printf("};\n\n"); | 441 printf("};\n\n"); |
442 } | 442 } |
443 OutputCommands(cmd->next); | 443 OutputCommands(cmd->next); |
444 } | 444 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 OutputCommands(commands); | 496 OutputCommands(commands); |
497 printf("const int kWriteInfoLength = %d;\n", (int) sizeof(TPM_WRITE_INFO)); | 497 printf("const int kWriteInfoLength = %d;\n", (int) sizeof(TPM_WRITE_INFO)); |
498 printf("const int kNvDataPublicPermissionsOffset = %d;\n", | 498 printf("const int kNvDataPublicPermissionsOffset = %d;\n", |
499 (int) (offsetof(TPM_NV_DATA_PUBLIC, permission) + | 499 (int) (offsetof(TPM_NV_DATA_PUBLIC, permission) + |
500 2 * PCR_SELECTION_FIX + | 500 2 * PCR_SELECTION_FIX + |
501 offsetof(TPM_NV_ATTRIBUTES, attributes))); | 501 offsetof(TPM_NV_ATTRIBUTES, attributes))); |
502 | 502 |
503 FreeCommands(commands); | 503 FreeCommands(commands); |
504 return 0; | 504 return 0; |
505 } | 505 } |
OLD | NEW |