1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** USBX Component */
16 /** */
17 /** Utility */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22
23 /* Include necessary system files. */
24
25 #define UX_SOURCE_CODE
26
27 #include "ux_api.h"
28
29
30 /**************************************************************************/
31 /* */
32 /* FUNCTION RELEASE */
33 /* */
34 /* _ux_utility_long_get PORTABLE C */
35 /* 6.1 */
36 /* AUTHOR */
37 /* */
38 /* Chaoqiong Xiao, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function reads a 32-bit value. */
43 /* */
44 /* INPUT */
45 /* */
46 /* address Source address */
47 /* */
48 /* OUTPUT */
49 /* */
50 /* 32-bit value */
51 /* */
52 /* CALLS */
53 /* */
54 /* None */
55 /* */
56 /* CALLED BY */
57 /* */
58 /* USBX Components */
59 /* */
60 /* RELEASE HISTORY */
61 /* */
62 /* DATE NAME DESCRIPTION */
63 /* */
64 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
65 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
66 /* resulting in version 6.1 */
67 /* */
68 /**************************************************************************/
_ux_utility_long_get(UCHAR * address)69 ULONG _ux_utility_long_get(UCHAR * address)
70 {
71
72 ULONG value;
73
74
75 /* In order to make this function endian agnostic and memory alignment
76 independent, we read a byte at a time from the address. */
77 value = (ULONG) *address++;
78 value |= (ULONG)*address++ << 8;
79 value |= (ULONG)*address++ << 16;
80 value |= (ULONG)*address << 24;
81
82 /* Return 32-bit value. */
83 return(value);
84 }
85
86