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