Home | History | Annotate | Download | only in tpm2
      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 "EvictControl_fp.h"
      9 
     10 TPM_RC EvictControl_In_Unmarshal(EvictControl_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->auth = request_handles[0];
     17   target->objectHandle = request_handles[1];
     18   // Unmarshal request parameters.
     19   result =
     20       TPMI_DH_PERSISTENT_Unmarshal(&target->persistentHandle, buffer, size);
     21   if (result != TPM_RC_SUCCESS) {
     22     return result;
     23   }
     24   if ((result == TPM_RC_SUCCESS) && *size) {
     25     result = TPM_RC_SIZE;
     26   }
     27   return result;
     28 }
     29 
     30 TPM_RC Exec_EvictControl(TPMI_ST_COMMAND_TAG tag,
     31                          BYTE** request_parameter_buffer,
     32                          INT32* request_parameter_buffer_size,
     33                          TPM_HANDLE request_handles[],
     34                          UINT32* response_handle_buffer_size,
     35                          UINT32* response_parameter_buffer_size) {
     36   TPM_RC result = TPM_RC_SUCCESS;
     37   EvictControl_In in;
     38 #ifdef TPM_CC_EvictControl
     39   BYTE* response_buffer;
     40   INT32 response_buffer_size;
     41 #endif
     42   *response_handle_buffer_size = 0;
     43   *response_parameter_buffer_size = 0;
     44   // Unmarshal request parameters to input structure.
     45   result =
     46       EvictControl_In_Unmarshal(&in, request_handles, request_parameter_buffer,
     47                                 request_parameter_buffer_size);
     48   if (result != TPM_RC_SUCCESS) {
     49     return result;
     50   }
     51   // Execute command.
     52   result = TPM2_EvictControl(&in);
     53   if (result != TPM_RC_SUCCESS) {
     54     return result;
     55   }
     56 #ifdef TPM_CC_EvictControl
     57   response_buffer = MemoryGetResponseBuffer(TPM_CC_EvictControl) + 10;
     58   response_buffer_size = MAX_RESPONSE_SIZE - 10;
     59   // Add parameter_size field, always equal to 0 here.
     60   if (tag == TPM_ST_SESSIONS) {
     61     UINT32_Marshal(response_parameter_buffer_size, &response_buffer,
     62                    &response_buffer_size);
     63   }
     64   return TPM_RC_SUCCESS;
     65 #endif
     66   return TPM_RC_COMMAND_CODE;
     67 }
     68