1 /* 2 * Copyright (c) 2021, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <stdint.h> 8 9 // 10 // Helper functions for byte ordering of TPM commands/responses 11 // SwapBytes16(uint16_t Value)12uint16_t SwapBytes16(uint16_t Value) 13 { 14 return (uint16_t)((Value << 8) | (Value >> 8)); 15 } 16 SwapBytes32(uint32_t Value)17uint32_t SwapBytes32(uint32_t Value) 18 { 19 uint32_t LowerBytes; 20 uint32_t HigherBytes; 21 22 LowerBytes = (uint32_t)SwapBytes16((uint16_t)Value); 23 HigherBytes = (uint32_t)SwapBytes16((uint16_t)(Value >> 16)); 24 25 return (LowerBytes << 16 | HigherBytes); 26 } 27