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 "SelfTest_fp.h"
9
SelfTest_In_Unmarshal(SelfTest_In * target,TPM_HANDLE request_handles[],BYTE ** buffer,INT32 * size)10 TPM_RC SelfTest_In_Unmarshal(SelfTest_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 = TPMI_YES_NO_Unmarshal(&target->fullTest, 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_SelfTest(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_SelfTest(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 SelfTest_In in;
34 #ifdef TPM_CC_SelfTest
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 = SelfTest_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_SelfTest(&in);
48 if (result != TPM_RC_SUCCESS) {
49 return result;
50 }
51 #ifdef TPM_CC_SelfTest
52 response_buffer = MemoryGetResponseBuffer(TPM_CC_SelfTest) + 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