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