GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_host_stack_class_call.c Lines: 10 10 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_class_call                           PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Chaoqiong Xiao, Microsoft Corporation                               */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function will call all the registered classes to the USBX      */
44
/*    stack. Each class will have the possibility to own the device or    */
45
/*    one of the interfaces of a device.                                  */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    class_command                         Class command structure       */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    Number of owners                                                    */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    (ux_host_class_entry_function)        Class entry function          */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    USBX Components                                                     */
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
/*                                            optimized based on compile  */
70
/*                                            definitions,                */
71
/*                                            resulting in version 6.1    */
72
/*                                                                        */
73
/**************************************************************************/
74
3313
UX_HOST_CLASS  *_ux_host_stack_class_call(UX_HOST_CLASS_COMMAND *class_command)
75
{
76
77
3313
UINT            status = UX_NO_CLASS_MATCH;
78
UX_HOST_CLASS   *class_inst;
79
#if UX_MAX_CLASS_DRIVER > 1
80
ULONG           class_index;
81
#endif
82
83
    /* Start from the 1st registered classes with USBX.  */
84
3313
    class_inst =  _ux_system_host -> ux_system_host_class_array;
85
86
    /* Parse all the class drivers.  */
87
#if UX_MAX_CLASS_DRIVER > 1
88
17830
    for (class_index = 0; class_index < _ux_system_host -> ux_system_host_max_class; class_index++)
89
    {
90
#endif
91
92
        /* Check if this class driver is used.  */
93
16019
        if (class_inst -> ux_host_class_status == UX_USED)
94
        {
95
96
            /* We have found a potential candidate. Call this registered class entry function.  */
97
3434
            status = class_inst -> ux_host_class_entry_function(class_command);
98
99
            /* The status tells us if the registered class wants to own this class.  */
100
3434
            if (status == UX_SUCCESS)
101
            {
102
103
                /* Yes, return this class pointer.  */
104
1502
                return(class_inst);
105
            }
106
        }
107
#if UX_MAX_CLASS_DRIVER > 1
108
        /* Move to the next registered class. */
109
14517
        class_inst ++;
110
    }
111
#endif
112
113
    /* There is no driver who want to own this class!  */
114
1811
    return(UX_NULL);
115
}