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