GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_host_stack_hcd_thread_entry.c Lines: 9 9 100.0 %
Date: 2024-12-12 17:16:36 Branches: 6 6 100.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
/**   Host Stack                                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
23
/* Include necessary system files.  */
24
25
#define UX_SOURCE_CODE
26
27
#include "ux_api.h"
28
#include "ux_host_stack.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _ux_host_stack_hcd_thread_entry                     PORTABLE C      */
36
/*                                                           6.1.10       */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function is the entry point of the host controller thread.     */
44
/*    The HCD thread is initialized at the system level and the thread    */
45
/*    entry routine is invoked right away. This thread suspends until     */
46
/*    one of the HCD resumes it due to HCD activities.                    */
47
/*                                                                        */
48
/*    It's for RTOS mode.                                                 */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    input                                 Not used input                */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _ux_utility_semaphore_get             Get signal semaphore          */
61
/*    (ux_hcd_entry_function)               HCD's entry function          */
62
/*                                                                        */
63
/*  CALLED BY                                                             */
64
/*                                                                        */
65
/*    ThreadX                                                             */
66
/*                                                                        */
67
/*  RELEASE HISTORY                                                       */
68
/*                                                                        */
69
/*    DATE              NAME                      DESCRIPTION             */
70
/*                                                                        */
71
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
72
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
73
/*                                            optimized based on compile  */
74
/*                                            definitions,                */
75
/*                                            resulting in version 6.1    */
76
/*  11-09-2020     Chaoqiong Xiao           Modified comment(s),          */
77
/*                                            fixed registered HCD scan,  */
78
/*                                            resulting in version 6.1.2  */
79
/*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
80
/*                                            refined macros names,       */
81
/*                                            resulting in version 6.1.10 */
82
/*                                                                        */
83
/**************************************************************************/
84
362
VOID  _ux_host_stack_hcd_thread_entry(ULONG input)
85
{
86
87
UINT        hcd_index;
88
UX_HCD      *hcd;
89
UX_INTERRUPT_SAVE_AREA
90
91
    UX_PARAMETER_NOT_USED(input);
92
93
    /* Loop forever on the semaphore. The semaphore is used to signal that
94
       there is work for one or more HCDs.  */
95
    while (1)
96
    {
97
98
        /* Get the semaphore that signals something is available for this
99
           thread to process.  */
100
165961
        _ux_host_semaphore_get_norc(&_ux_system_host -> ux_system_host_hcd_semaphore, UX_WAIT_FOREVER);
101
102
#if UX_MAX_HCD > 1
103
        /* This thread was awaken by one or more HCD controllers. Check each of the HCDs
104
           to see who posted work to do. */
105
496797
        for(hcd_index = 0; hcd_index < _ux_system_host -> ux_system_host_max_hcd; hcd_index++)
106
        {
107
#else
108
            hcd_index = 0;
109
#endif
110
111
            /* Pickup HCD pointer.  */
112
331198
            hcd =  &_ux_system_host -> ux_system_host_hcd_array[hcd_index];
113
114
            /* Is there work to do for this HCD?  */
115

331198
            if((hcd -> ux_hcd_status == UX_HCD_STATUS_OPERATIONAL) && (hcd -> ux_hcd_thread_signal !=0))
116
            {
117
118
                /* Yes, call the HCD function to process the work.  */
119
165599
                hcd -> ux_hcd_entry_function(hcd, UX_HCD_PROCESS_DONE_QUEUE, UX_NULL);
120
165599
                UX_DISABLE
121
165599
                hcd -> ux_hcd_thread_signal--;
122
165599
                UX_RESTORE
123
            }
124
125
#if UX_MAX_HCD > 1
126
        }
127
#endif
128
    }
129
}
130