drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / src / security / tpm / tss / tcg-1.2 / tss_internal.h
blobc5a5aaa187dc611b819d080ef24fd827942ba791
1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #ifndef TCG_TSS_INTERNAL_H_
4 #define TCG_TSS_INTERNAL_H_
6 #include <stdint.h>
8 /*
9 * These numbers derive from adding the sizes of command fields as shown in the
10 * TPM commands manual.
12 #define kTpmRequestHeaderLength 10
13 #define kTpmResponseHeaderLength 10
14 #define kTpmReadInfoLength 12
15 #define kEncAuthLength 20
16 #define kPcrDigestLength 20
19 * Conversion functions. to_tpm_TYPE puts a value of type TYPE into a TPM
20 * command buffer. from_tpm_TYPE gets a value of type TYPE from a TPM command
21 * buffer into a variable.
23 __attribute__((unused))
24 static inline void to_tpm_uint32(uint8_t *buffer, uint32_t x)
26 buffer[0] = (uint8_t)(x >> 24);
27 buffer[1] = (uint8_t)((x >> 16) & 0xff);
28 buffer[2] = (uint8_t)((x >> 8) & 0xff);
29 buffer[3] = (uint8_t)(x & 0xff);
33 * See comment for above function.
35 __attribute__((unused))
36 static inline void from_tpm_uint32(const uint8_t *buffer, uint32_t *x)
38 *x = ((buffer[0] << 24) |
39 (buffer[1] << 16) |
40 (buffer[2] << 8) |
41 buffer[3]);
45 * See comment for above function.
47 __attribute__((unused))
48 static inline void to_tpm_uint16(uint8_t *buffer, uint16_t x)
50 buffer[0] = (uint8_t)(x >> 8);
51 buffer[1] = (uint8_t)(x & 0xff);
55 * See comment for above function.
57 __attribute__((unused))
58 static inline void from_tpm_uint16(const uint8_t *buffer, uint16_t *x)
60 *x = (buffer[0] << 8) | buffer[1];
63 #endif /* TCG_TSS_INTERNAL_H_ */