GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_host_stack_configuration_instance_create.c Lines: 9 9 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
/**   Host Stack                                                          */
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_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_host_stack_configuration_instance_create        PORTABLE C      */
37
/*                                                           6.2.0        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function will create a configuration instance. It scan all the */
45
/*    interfaces hooked to the configuration and enable each interface    */
46
/*    with the alternate setting 0.                                       */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    configuration                         Pointer to configuration      */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    Completion Status                                                   */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _ux_host_stack_interface_instance_create  Create interface instance */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    USBX Components                                                     */
63
/*                                                                        */
64
/**************************************************************************/
65
909
UINT  _ux_host_stack_configuration_instance_create(UX_CONFIGURATION *configuration)
66
{
67
68
UX_INTERFACE    *interface_ptr;
69
UINT            status;
70
71
    /* If trace is enabled, insert this event into the trace buffer.  */
72
    UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_CONFIGURATION_INSTANCE_CREATE, configuration, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
73
74
    /* Obtain the first interface for this configuration.  */
75
909
    interface_ptr =  configuration -> ux_configuration_first_interface;
76
77
    /* Each selected alternate setting 0 for each interface must be created.  */
78
2706
    while (interface_ptr != UX_NULL)
79
    {
80
81
        /* Check if we are dealing with the first alternate setting.  */
82
1807
        if (interface_ptr -> ux_interface_descriptor.bAlternateSetting == 0)
83
        {
84
85
#if UX_HOST_STACK_CONFIGURATION_INSTANCE_CREATE_CONTROL == UX_HOST_STACK_CONFIGURATION_INSTANCE_CREATE_OWNED
86
87
            /* Create the interface, if it's usable. */
88
            if (interface_ptr -> ux_interface_class || configuration -> ux_configuration_device -> ux_device_class)
89
#endif
90
            {
91
1532
                status = _ux_host_stack_interface_instance_create(interface_ptr);
92
93
                /* Check status, the controller may have refused the endpoint creation.  */
94
1532
                if (status != UX_SUCCESS)
95
96
                    /* An error occurred.  The interface cannot be mounted.  */
97
10
                    return(status);
98
            }
99
        }
100
101
        /* Next interface.  */
102
1797
        interface_ptr =  interface_ptr -> ux_interface_next_interface;
103
    }
104
105
    /* Return successful completion.  */
106
899
    return(UX_SUCCESS);
107
}
108