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 "Startup_fp.h"
9
Startup_In_Unmarshal(Startup_In * target,TPM_HANDLE request_handles[],BYTE ** buffer,INT32 * size)10 TPM_RC Startup_In_Unmarshal(Startup_In* target,
11 TPM_HANDLE request_handles[],
12 BYTE** buffer,
13 INT32* size) {
14 TPM_RC result = TPM_RC_SUCCESS;
15 // Unmarshal request parameters.
16 result = TPM_SU_Unmarshal(&target->startupType, buffer, size);
17 if (result != TPM_RC_SUCCESS) {
18 return result;
19 }
20 if ((result == TPM_RC_SUCCESS) && *size) {
21 result = TPM_RC_SIZE;
22 }
23 return result;
24 }
25
Exec_Startup(TPMI_ST_COMMAND_TAG tag,BYTE ** request_parameter_buffer,INT32 * request_parameter_buffer_size,TPM_HANDLE request_handles[],UINT32 * response_handle_buffer_size,UINT32 * response_parameter_buffer_size)26 TPM_RC Exec_Startup(TPMI_ST_COMMAND_TAG tag,
27 BYTE** request_parameter_buffer,
28 INT32* request_parameter_buffer_size,
29 TPM_HANDLE request_handles[],
30 UINT32* response_handle_buffer_size,
31 UINT32* response_parameter_buffer_size) {
32 TPM_RC result = TPM_RC_SUCCESS;
33 Startup_In in;
34 #ifdef TPM_CC_Startup
35 BYTE* response_buffer;
36 INT32 response_buffer_size;
37 #endif
38 *response_handle_buffer_size = 0;
39 *response_parameter_buffer_size = 0;
40 // Unmarshal request parameters to input structure.
41 result = Startup_In_Unmarshal(&in, request_handles, request_parameter_buffer,
42 request_parameter_buffer_size);
43 if (result != TPM_RC_SUCCESS) {
44 return result;
45 }
46 // Execute command.
47 result = TPM2_Startup(&in);
48 if (result != TPM_RC_SUCCESS) {
49 return result;
50 }
51 #ifdef TPM_CC_Startup
52 response_buffer = MemoryGetResponseBuffer(TPM_CC_Startup) + 10;
53 response_buffer_size = MAX_RESPONSE_SIZE - 10;
54 // Add parameter_size field, always equal to 0 here.
55 if (tag == TPM_ST_SESSIONS) {
56 UINT32_Marshal(response_parameter_buffer_size, &response_buffer,
57 &response_buffer_size);
58 }
59 return TPM_RC_SUCCESS;
60 #endif
61 return TPM_RC_COMMAND_CODE;
62 }
63