Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 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 "ReadClock_fp.h" |
| 9 | |
Vadim Bendebury | c3730f6 | 2019-01-15 11:59:05 -0800 | [diff] [blame] | 10 | #if IS_CC_ENABLED(ReadClock) |
Vadim Bendebury | 56abbbf | 2018-08-28 15:34:31 -0700 | [diff] [blame] | 11 | static UINT16 ReadClock_Out_Marshal(ReadClock_Out* source, |
| 12 | TPMI_ST_COMMAND_TAG tag, |
| 13 | BYTE** buffer, |
| 14 | INT32* size) { |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 15 | UINT16 total_size = 0; |
| 16 | UINT32 parameter_size = 0; |
| 17 | BYTE* parameter_size_location; |
| 18 | INT32 parameter_size_size = sizeof(UINT32); |
| 19 | UINT32 num_response_handles = 0; |
| 20 | // Add parameter_size=0 to indicate size of the parameter area. Will be |
| 21 | // replaced later by computed parameter_size. |
| 22 | if (tag == TPM_ST_SESSIONS) { |
| 23 | parameter_size_location = *buffer; |
| 24 | // Don't add to total_size, but increment *buffer and decrement *size. |
| 25 | UINT32_Marshal(¶meter_size, buffer, size); |
| 26 | } |
| 27 | // Marshal response parameters. |
| 28 | total_size += TPMS_TIME_INFO_Marshal(&source->currentTime, buffer, size); |
| 29 | // Compute actual parameter_size. Don't add result to total_size. |
| 30 | if (tag == TPM_ST_SESSIONS) { |
| 31 | parameter_size = total_size - num_response_handles * sizeof(TPM_HANDLE); |
| 32 | UINT32_Marshal(¶meter_size, ¶meter_size_location, |
| 33 | ¶meter_size_size); |
| 34 | } |
| 35 | return total_size; |
| 36 | } |
Vadim Bendebury | 56abbbf | 2018-08-28 15:34:31 -0700 | [diff] [blame] | 37 | #endif |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 38 | |
| 39 | TPM_RC Exec_ReadClock(TPMI_ST_COMMAND_TAG tag, |
| 40 | BYTE** request_parameter_buffer, |
| 41 | INT32* request_parameter_buffer_size, |
| 42 | TPM_HANDLE request_handles[], |
| 43 | UINT32* response_handle_buffer_size, |
| 44 | UINT32* response_parameter_buffer_size) { |
| 45 | TPM_RC result = TPM_RC_SUCCESS; |
| 46 | ReadClock_Out out; |
Vadim Bendebury | c3730f6 | 2019-01-15 11:59:05 -0800 | [diff] [blame] | 47 | #if IS_CC_ENABLED(ReadClock) |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 48 | BYTE* response_buffer; |
| 49 | INT32 response_buffer_size; |
| 50 | UINT16 bytes_marshalled; |
| 51 | UINT16 num_response_handles = 0; |
| 52 | #endif |
| 53 | *response_handle_buffer_size = 0; |
| 54 | *response_parameter_buffer_size = 0; |
| 55 | // Execute command. |
| 56 | result = TPM2_ReadClock(&out); |
| 57 | if (result != TPM_RC_SUCCESS) { |
| 58 | return result; |
| 59 | } |
| 60 | // Marshal output structure containing response handles and parameters to |
| 61 | // response buffer. |
Vadim Bendebury | c3730f6 | 2019-01-15 11:59:05 -0800 | [diff] [blame] | 62 | #if IS_CC_ENABLED(ReadClock) |
Jocelyn Bohr | a4ed3aa | 2015-07-30 10:44:16 -0700 | [diff] [blame] | 63 | response_buffer = MemoryGetResponseBuffer(TPM_CC_ReadClock) + 10; |
| 64 | response_buffer_size = MAX_RESPONSE_SIZE - 10; |
| 65 | bytes_marshalled = |
| 66 | ReadClock_Out_Marshal(&out, tag, &response_buffer, &response_buffer_size); |
| 67 | *response_handle_buffer_size = num_response_handles * sizeof(TPM_HANDLE); |
| 68 | *response_parameter_buffer_size = |
| 69 | bytes_marshalled - *response_handle_buffer_size; |
| 70 | return TPM_RC_SUCCESS; |
| 71 | #endif |
| 72 | return TPM_RC_COMMAND_CODE; |
| 73 | } |