GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_host_classes/src/ux_host_class_hub_change_detect.c Lines: 10 10 100.0 %
Date: 2026-03-06 18:57:10 Branches: 6 6 100.0 %

Line Branch Exec Source
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
/**   HUB Class                                                           */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
#include "ux_host_class_hub.h"
30
#include "ux_host_stack.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _ux_host_class_hub_change_detect                    PORTABLE C      */
38
/*                                                           6.1.12       */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function is called by the enumeration thread when there has    */
46
/*    been activity on the HUB.                                           */
47
/*                                                                        */
48
/*    In standalone mode there is nothing to do here, activities are      */
49
/*    processed in hub tasks function.                                    */
50
/*                                                                        */
51
/*  INPUT                                                                 */
52
/*                                                                        */
53
/*    None                                                                */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _ux_host_class_hub_change_process     Process HUB change            */
62
/*    _ux_host_stack_class_get              Get class                     */
63
/*    _ux_host_stack_class_instance_get     Get class instance            */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    HUB Class                                                           */
68
/*                                                                        */
69
/**************************************************************************/
70
122
VOID  _ux_host_class_hub_change_detect(VOID)
71
{
72
#if defined(UX_HOST_STANDALONE)
73
74
    /* Things are done in hub task nothing to do here.  */
75
#else
76
77
UX_HOST_CLASS           *class;
78
UX_HOST_CLASS_HUB       *hub;
79
UINT                    status;
80
UINT                    class_index;
81
82
    /* Get the class container first.  */
83
122
    _ux_host_stack_class_get(_ux_system_host_class_hub_name, &class);
84
85
    /* We start with the first index of the class instance.  */
86
122
    class_index =  0;
87
88
    /* We have found the class, now parse the instances.  */
89
    do
90
    {
91
92
        /* Get class instance.  */
93
185
        status =  _ux_host_stack_class_instance_get(class, class_index++, (VOID **) &hub);
94
95
        /* Check completion status.  */
96
185
        if (status == UX_SUCCESS)
97
        {
98
99
            /* We have found an instance of a HUB, check if it is live and if the HUB has
100
               detected a change before we proceed.  */
101
63
            if (hub -> ux_host_class_hub_change_semaphore != 0)
102
            {
103
104
                /* If trace is enabled, insert this event into the trace buffer.  */
105
                UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_HUB_CHANGE_DETECT, hub, 0, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
106
107
                /* Call the HUB function that will diagnose the origin of the change.  */
108
27
                _ux_host_class_hub_change_process(hub);
109
110
                /* Decrement the HUB instance semaphore change so we don't get awaken again.  */
111
27
                hub -> ux_host_class_hub_change_semaphore--;
112
            }
113
        }
114
185
    } while (status == UX_SUCCESS);
115
116
    /* We have parsed all the HUB instances.  */
117
122
    return;
118
#endif
119
}