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 "PolicyCounterTimer_fp.h"
9 
PolicyCounterTimer_In_Unmarshal(PolicyCounterTimer_In * target,TPM_HANDLE request_handles[],BYTE ** buffer,INT32 * size)10 TPM_RC PolicyCounterTimer_In_Unmarshal(PolicyCounterTimer_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->policySession = request_handles[0];
17   // Unmarshal request parameters.
18   result = TPM2B_OPERAND_Unmarshal(&target->operandB, buffer, size);
19   if (result != TPM_RC_SUCCESS) {
20     return result;
21   }
22   result = UINT16_Unmarshal(&target->offset, buffer, size);
23   if (result != TPM_RC_SUCCESS) {
24     return result;
25   }
26   result = TPM_EO_Unmarshal(&target->operation, buffer, size);
27   if (result != TPM_RC_SUCCESS) {
28     return result;
29   }
30   if ((result == TPM_RC_SUCCESS) && *size) {
31     result = TPM_RC_SIZE;
32   }
33   return result;
34 }
35 
Exec_PolicyCounterTimer(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)36 TPM_RC Exec_PolicyCounterTimer(TPMI_ST_COMMAND_TAG tag,
37                                BYTE** request_parameter_buffer,
38                                INT32* request_parameter_buffer_size,
39                                TPM_HANDLE request_handles[],
40                                UINT32* response_handle_buffer_size,
41                                UINT32* response_parameter_buffer_size) {
42   TPM_RC result = TPM_RC_SUCCESS;
43   PolicyCounterTimer_In in;
44 #ifdef TPM_CC_PolicyCounterTimer
45   BYTE* response_buffer;
46   INT32 response_buffer_size;
47 #endif
48   *response_handle_buffer_size = 0;
49   *response_parameter_buffer_size = 0;
50   // Unmarshal request parameters to input structure.
51   result = PolicyCounterTimer_In_Unmarshal(&in, request_handles,
52                                            request_parameter_buffer,
53                                            request_parameter_buffer_size);
54   if (result != TPM_RC_SUCCESS) {
55     return result;
56   }
57   // Execute command.
58   result = TPM2_PolicyCounterTimer(&in);
59   if (result != TPM_RC_SUCCESS) {
60     return result;
61   }
62 #ifdef TPM_CC_PolicyCounterTimer
63   response_buffer = MemoryGetResponseBuffer(TPM_CC_PolicyCounterTimer) + 10;
64   response_buffer_size = MAX_RESPONSE_SIZE - 10;
65   // Add parameter_size field, always equal to 0 here.
66   if (tag == TPM_ST_SESSIONS) {
67     UINT32_Marshal(response_parameter_buffer_size, &response_buffer,
68                    &response_buffer_size);
69   }
70   return TPM_RC_SUCCESS;
71 #endif
72   return TPM_RC_COMMAND_CODE;
73 }
74