GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_long_put_big_endian.c Lines: 9 9 100.0 %
Date: 2024-12-12 17:16:36 Branches: 0 0 - %

Line Branch Exec Source
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_put_big_endian                     PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Chaoqiong Xiao, Microsoft Corporation                               */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This function writes a 32-bit value in big endian format.           */
43
/*                                                                        */
44
/*  INPUT                                                                 */
45
/*                                                                        */
46
/*    address                               Destination address           */
47
/*    value                                 32-bit value                  */
48
/*                                                                        */
49
/*  OUTPUT                                                                */
50
/*                                                                        */
51
/*    None                                                                */
52
/*                                                                        */
53
/*  CALLS                                                                 */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLED BY                                                             */
58
/*                                                                        */
59
/*    USBX Components                                                     */
60
/*                                                                        */
61
/*  RELEASE HISTORY                                                       */
62
/*                                                                        */
63
/*    DATE              NAME                      DESCRIPTION             */
64
/*                                                                        */
65
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
66
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
67
/*                                            resulting in version 6.1    */
68
/*                                                                        */
69
/**************************************************************************/
70
2379
VOID  _ux_utility_long_put_big_endian(UCHAR * address, ULONG value)
71
{
72
73
ULONG   low_word_value;
74
ULONG   high_word_value;
75
76
    /* First we swap the value words.  */
77
2379
    low_word_value =  value >> 16;
78
2379
    high_word_value =  value << 16;
79
2379
    value =  high_word_value | low_word_value;
80
81
    /* In order to make this function endian agnostic and memory alignment
82
       independent, we write a byte at a time from the address.  */
83
2379
    *address++ =  (UCHAR) ((value >> 8) & 0xff);
84
2379
    *address++ =  (UCHAR) (value & 0xff);
85
2379
    *address++ =  (UCHAR) ((value >> 24 ) & 0xff);
86
2379
    *address   =  (UCHAR) ((value >> 16) & 0xff);
87
88
    /* Return to caller.  */
89
2379
    return;
90
}
91