1 // Copyright 2015 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // THIS CODE IS GENERATED - DO NOT MODIFY! 6 7 #include "MemoryLib_fp.h" 8 #include "FieldUpgradeStart_fp.h" 9 10 TPM_RC FieldUpgradeStart_In_Unmarshal(FieldUpgradeStart_In* target, 11 TPM_HANDLE request_handles[], 12 BYTE** buffer, 13 INT32* size) { 14 TPM_RC result = TPM_RC_SUCCESS; 15 // Get request handles from request_handles array. 16 target->authorization = request_handles[0]; 17 target->keyHandle = request_handles[1]; 18 // Unmarshal request parameters. 19 result = TPM2B_DIGEST_Unmarshal(&target->fuDigest, buffer, size); 20 if (result != TPM_RC_SUCCESS) { 21 return result; 22 } 23 result = TPMT_SIGNATURE_Unmarshal(&target->manifestSignature, buffer, size); 24 if (result != TPM_RC_SUCCESS) { 25 return result; 26 } 27 if ((result == TPM_RC_SUCCESS) && *size) { 28 result = TPM_RC_SIZE; 29 } 30 return result; 31 } 32 33 TPM_RC Exec_FieldUpgradeStart(TPMI_ST_COMMAND_TAG tag, 34 BYTE** request_parameter_buffer, 35 INT32* request_parameter_buffer_size, 36 TPM_HANDLE request_handles[], 37 UINT32* response_handle_buffer_size, 38 UINT32* response_parameter_buffer_size) { 39 TPM_RC result = TPM_RC_SUCCESS; 40 FieldUpgradeStart_In in; 41 #ifdef TPM_CC_FieldUpgradeStart 42 BYTE* response_buffer; 43 INT32 response_buffer_size; 44 #endif 45 *response_handle_buffer_size = 0; 46 *response_parameter_buffer_size = 0; 47 // Unmarshal request parameters to input structure. 48 result = FieldUpgradeStart_In_Unmarshal(&in, request_handles, 49 request_parameter_buffer, 50 request_parameter_buffer_size); 51 if (result != TPM_RC_SUCCESS) { 52 return result; 53 } 54 // Execute command. 55 result = TPM2_FieldUpgradeStart(&in); 56 if (result != TPM_RC_SUCCESS) { 57 return result; 58 } 59 #ifdef TPM_CC_FieldUpgradeStart 60 response_buffer = MemoryGetResponseBuffer(TPM_CC_FieldUpgradeStart) + 10; 61 response_buffer_size = MAX_RESPONSE_SIZE - 10; 62 // Add parameter_size field, always equal to 0 here. 63 if (tag == TPM_ST_SESSIONS) { 64 UINT32_Marshal(response_parameter_buffer_size, &response_buffer, 65 &response_buffer_size); 66 } 67 return TPM_RC_SUCCESS; 68 #endif 69 return TPM_RC_COMMAND_CODE; 70 } 71