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