/src/hbfa-fl/HBFA/UefiHostTestPkg/Library/BaseLibHost/SwapBytes32.c
Line | Count | Source |
1 | | /** @file |
2 | | Math worker functions. |
3 | | |
4 | | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> |
5 | | SPDX-License-Identifier: BSD-2-Clause-Patent |
6 | | |
7 | | **/ |
8 | | |
9 | | #include <Base.h> |
10 | | #include <Library/BaseLib.h> |
11 | | |
12 | | /** |
13 | | Switches the endianess of a 32-bit integer. |
14 | | |
15 | | This function swaps the bytes in a 32-bit unsigned value to switch the value |
16 | | from little endian to big endian or vice versa. The byte swapped value is |
17 | | returned. |
18 | | |
19 | | @param Value A 32-bit unsigned value. |
20 | | |
21 | | @return The byte swapped Value. |
22 | | |
23 | | **/ |
24 | | UINT32 |
25 | | EFIAPI |
26 | | SwapBytes32 ( |
27 | | IN UINT32 Value |
28 | | ) |
29 | 1.43k | { |
30 | 1.43k | UINT32 LowerBytes; |
31 | 1.43k | UINT32 HigherBytes; |
32 | | |
33 | 1.43k | LowerBytes = (UINT32) SwapBytes16 ((UINT16) Value); |
34 | 1.43k | HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Value >> 16)); |
35 | | |
36 | 1.43k | return (LowerBytes << 16 | HigherBytes); |
37 | 1.43k | } |