| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return cmd; | 200 return cmd; |
| 201 } | 201 } |
| 202 | 202 |
| 203 Command* BuildSelftestfullCommand(void) { | 203 Command* BuildSelftestfullCommand(void) { |
| 204 int size = kTpmRequestHeaderLength; | 204 int size = kTpmRequestHeaderLength; |
| 205 Command* cmd = newCommand(TPM_ORD_SelfTestFull, size); | 205 Command* cmd = newCommand(TPM_ORD_SelfTestFull, size); |
| 206 cmd->name = "tpm_selftestfull_cmd"; | 206 cmd->name = "tpm_selftestfull_cmd"; |
| 207 return cmd; | 207 return cmd; |
| 208 } | 208 } |
| 209 | 209 |
| 210 Command* BuildContinueSelfTestCommand(void) { |
| 211 int size = kTpmRequestHeaderLength; |
| 212 Command* cmd = newCommand(TPM_ORD_ContinueSelfTest, size); |
| 213 cmd->name = "tpm_continueselftest_cmd"; |
| 214 return cmd; |
| 215 } |
| 216 |
| 210 Command* BuildReadPubekCommand(void) { | 217 Command* BuildReadPubekCommand(void) { |
| 211 int size = kTpmRequestHeaderLength + sizeof(TPM_NONCE); | 218 int size = kTpmRequestHeaderLength + sizeof(TPM_NONCE); |
| 212 Command* cmd = newCommand(TPM_ORD_ReadPubek, size); | 219 Command* cmd = newCommand(TPM_ORD_ReadPubek, size); |
| 213 cmd->name = "tpm_readpubek_cmd"; | 220 cmd->name = "tpm_readpubek_cmd"; |
| 214 return cmd; | 221 return cmd; |
| 215 } | 222 } |
| 216 | 223 |
| 217 Command* BuildForceClearCommand(void) { | 224 Command* BuildForceClearCommand(void) { |
| 218 int size = kTpmRequestHeaderLength; | 225 int size = kTpmRequestHeaderLength; |
| 219 Command* cmd = newCommand(TPM_ORD_ForceClear, size); | 226 Command* cmd = newCommand(TPM_ORD_ForceClear, size); |
| 220 cmd->name = "tpm_forceclear_cmd"; | 227 cmd->name = "tpm_forceclear_cmd"; |
| 221 return cmd; | 228 return cmd; |
| 222 } | 229 } |
| 223 | 230 |
| 224 Command* BuildPhysicalEnableCommand(void) { | 231 Command* BuildPhysicalEnableCommand(void) { |
| 225 int size = kTpmRequestHeaderLength; | 232 int size = kTpmRequestHeaderLength; |
| 226 Command* cmd = newCommand(TPM_ORD_PhysicalEnable, size); | 233 Command* cmd = newCommand(TPM_ORD_PhysicalEnable, size); |
| 227 cmd->name = "tpm_physicalenable_cmd"; | 234 cmd->name = "tpm_physicalenable_cmd"; |
| 228 return cmd; | 235 return cmd; |
| 229 } | 236 } |
| 230 | 237 |
| 231 Command* BuildPhysicalSetDeactivatedCommand(void) { | 238 Command* BuildPhysicalSetDeactivatedCommand(void) { |
| 232 int size = kTpmRequestHeaderLength + sizeof(uint8_t); | 239 int size = kTpmRequestHeaderLength + sizeof(uint8_t); |
| 233 Command* cmd = newCommand(TPM_ORD_PhysicalSetDeactivated, size); | 240 Command* cmd = newCommand(TPM_ORD_PhysicalSetDeactivated, size); |
| 234 cmd->name = "tpm_physicalsetdeactivated_cmd"; | 241 cmd->name = "tpm_physicalsetdeactivated_cmd"; |
| 235 AddVisibleField(cmd, "deactivated", kTpmRequestHeaderLength); | 242 AddVisibleField(cmd, "deactivated", kTpmRequestHeaderLength); |
| 236 return cmd; | 243 return cmd; |
| 237 } | 244 } |
| 238 | 245 |
| 246 Command* BuildExtendCommand(void) { |
| 247 int size = kTpmRequestHeaderLength + sizeof(uint32_t) + kPcrDigestLength; |
| 248 Command* cmd = newCommand(TPM_ORD_Extend, size); |
| 249 cmd->name = "tpm_extend_cmd"; |
| 250 AddVisibleField(cmd, "pcrNum", kTpmRequestHeaderLength); |
| 251 AddVisibleField(cmd, "inDigest", kTpmRequestHeaderLength + sizeof(uint32_t)); |
| 252 return cmd; |
| 253 } |
| 254 |
| 239 Command* BuildGetCapabilityCommand(void) { | 255 Command* BuildGetCapabilityCommand(void) { |
| 240 int size = (kTpmRequestHeaderLength + | 256 int size = (kTpmRequestHeaderLength + |
| 241 sizeof(TPM_CAPABILITY_AREA) + /* capArea */ | 257 sizeof(TPM_CAPABILITY_AREA) + /* capArea */ |
| 242 sizeof(uint32_t) + /* subCapSize */ | 258 sizeof(uint32_t) + /* subCapSize */ |
| 243 sizeof(uint32_t)); /* subCap */ | 259 sizeof(uint32_t)); /* subCap */ |
| 244 | 260 |
| 245 Command* cmd = newCommand(TPM_ORD_GetCapability, size); | 261 Command* cmd = newCommand(TPM_ORD_GetCapability, size); |
| 246 cmd->name = "tpm_getcapability_cmd"; | 262 cmd->name = "tpm_getcapability_cmd"; |
| 247 AddInitializedField(cmd, kTpmRequestHeaderLength, | 263 AddInitializedField(cmd, kTpmRequestHeaderLength, |
| 248 sizeof(TPM_CAPABILITY_AREA), TPM_CAP_FLAG); | 264 sizeof(TPM_CAPABILITY_AREA), TPM_CAP_FLAG); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 367 } |
| 352 | 368 |
| 353 Command* (*builders[])(void) = { | 369 Command* (*builders[])(void) = { |
| 354 BuildDefineSpaceCommand, | 370 BuildDefineSpaceCommand, |
| 355 BuildWriteCommand, | 371 BuildWriteCommand, |
| 356 BuildReadCommand, | 372 BuildReadCommand, |
| 357 BuildPPAssertCommand, | 373 BuildPPAssertCommand, |
| 358 BuildPPLockCommand, | 374 BuildPPLockCommand, |
| 359 BuildStartupCommand, | 375 BuildStartupCommand, |
| 360 BuildSelftestfullCommand, | 376 BuildSelftestfullCommand, |
| 377 BuildContinueSelfTestCommand, |
| 361 BuildReadPubekCommand, | 378 BuildReadPubekCommand, |
| 362 BuildForceClearCommand, | 379 BuildForceClearCommand, |
| 363 BuildPhysicalEnableCommand, | 380 BuildPhysicalEnableCommand, |
| 364 BuildPhysicalSetDeactivatedCommand, | 381 BuildPhysicalSetDeactivatedCommand, |
| 365 BuildGetCapabilityCommand, | 382 BuildGetCapabilityCommand, |
| 383 BuildExtendCommand, |
| 366 }; | 384 }; |
| 367 | 385 |
| 368 static void FreeFields(Field* fld) { | 386 static void FreeFields(Field* fld) { |
| 369 if (fld != NULL) { | 387 if (fld != NULL) { |
| 370 Field* next_field = fld->next; | 388 Field* next_field = fld->next; |
| 371 free(fld); | 389 free(fld); |
| 372 FreeFields(next_field); | 390 FreeFields(next_field); |
| 373 } | 391 } |
| 374 } | 392 } |
| 375 | 393 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 391 commands = cmd; | 409 commands = cmd; |
| 392 } | 410 } |
| 393 | 411 |
| 394 printf("/* This file is automatically generated */\n\n"); | 412 printf("/* This file is automatically generated */\n\n"); |
| 395 OutputCommands(commands); | 413 OutputCommands(commands); |
| 396 printf("const int kWriteInfoLength = %d;\n", (int) sizeof(TPM_WRITE_INFO)); | 414 printf("const int kWriteInfoLength = %d;\n", (int) sizeof(TPM_WRITE_INFO)); |
| 397 | 415 |
| 398 FreeCommands(commands); | 416 FreeCommands(commands); |
| 399 return 0; | 417 return 0; |
| 400 } | 418 } |
| OLD | NEW |