GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_device_stack_interface_start.c Lines: 22 22 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
/**   Device Stack                                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
#define UX_SOURCE_CODE
24
25
26
/* Include necessary system files.  */
27
28
#include "ux_api.h"
29
#include "ux_device_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_device_stack_interface_start                    PORTABLE C      */
37
/*                                                           6.1.12       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function starts an interface associated with the enabled       */
45
/*    configuration.                                                      */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    interface                             Pointer to interface          */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    Completion Status                                                   */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    (ux_slave_class_entry_function)       Device class entry function   */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    Application                                                         */
62
/*    Device Stack                                                        */
63
/*                                                                        */
64
/**************************************************************************/
65
1541
UINT  _ux_device_stack_interface_start(UX_SLAVE_INTERFACE *interface_ptr)
66
{
67
68
UX_SLAVE_DEVICE             *device;
69
UX_SLAVE_CLASS              *class_ptr;
70
UINT                        status;
71
UX_SLAVE_CLASS_COMMAND      class_command;
72
73
74
    /* Get the class for the interface.  */
75
1541
    class_ptr =  _ux_system_slave -> ux_system_slave_interface_class_array[interface_ptr -> ux_slave_interface_descriptor.bInterfaceNumber];
76
77
    /* Check if class driver is available. */
78
1541
    if (class_ptr == UX_NULL)
79
80
        /* There is no class driver supported. */
81
66
        return (UX_NO_CLASS_MATCH);
82
83
    /* Get the pointer to the device.  */
84
1475
    device =  &_ux_system_slave -> ux_system_slave_device;
85
86
    /* Build all the fields of the Class Command.  */
87
1475
    class_command.ux_slave_class_command_request   =    UX_SLAVE_CLASS_COMMAND_QUERY;
88
1475
    class_command.ux_slave_class_command_interface =   (VOID *)interface_ptr;
89
1475
    class_command.ux_slave_class_command_class     =   interface_ptr -> ux_slave_interface_descriptor.bInterfaceClass;
90
1475
    class_command.ux_slave_class_command_subclass  =   interface_ptr -> ux_slave_interface_descriptor.bInterfaceSubClass;
91
1475
    class_command.ux_slave_class_command_protocol  =   interface_ptr -> ux_slave_interface_descriptor.bInterfaceProtocol;
92
1475
    class_command.ux_slave_class_command_vid       =   device -> ux_slave_device_descriptor.idVendor;
93
1475
    class_command.ux_slave_class_command_pid       =   device -> ux_slave_device_descriptor.idProduct;
94
95
    /* We can now memorize the interface pointer associated with this class.  */
96
1475
    class_ptr -> ux_slave_class_interface = interface_ptr;
97
98
    /* We have found a potential candidate. Call this registered class entry function.  */
99
1475
    status = class_ptr -> ux_slave_class_entry_function(&class_command);
100
101
    /* The status tells us if the registered class wants to own this class.  */
102
1475
    if (status == UX_SUCCESS)
103
    {
104
105
        /* Store the class container. */
106
1379
        class_command.ux_slave_class_command_class_ptr =  class_ptr;
107
108
        /* Store the command.  */
109
1379
        class_command.ux_slave_class_command_request =  UX_SLAVE_CLASS_COMMAND_ACTIVATE;
110
111
        /* Activate the class.  */
112
1379
        status = class_ptr -> ux_slave_class_entry_function(&class_command);
113
114
        /* If the class was successfully activated, set the class for the interface.  */
115
1379
        if(status == UX_SUCCESS)
116
1349
            interface_ptr -> ux_slave_interface_class =  class_ptr;
117
118
1379
        return(status);
119
    }
120
121
    /* There is no driver who want to own this class!  */
122
96
    return(UX_NO_CLASS_MATCH);
123
}
124