1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
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_new_configuration_create PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function creates a new configuration for the current device */
45 /* a device can have multiple configurations. */
46 /* */
47 /* INPUT */
48 /* */
49 /* device Pointer to the descriptor */
50 /* for the device */
51 /* configuration_descriptor Configuration descriptor */
52 /* previously parsed */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* None */
57 /* */
58 /* CALLS */
59 /* */
60 /* None */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* USBX Components */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
71 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
72 /* resulting in version 6.1 */
73 /* */
74 /**************************************************************************/
_ux_host_stack_new_configuration_create(UX_DEVICE * device,UX_CONFIGURATION * configuration)75 VOID _ux_host_stack_new_configuration_create(UX_DEVICE *device, UX_CONFIGURATION *configuration)
76 {
77
78 UX_CONFIGURATION *list_configuration;
79
80 /* If trace is enabled, insert this event into the trace buffer. */
81 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_NEW_CONFIGURATION_CREATE, device, configuration, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
82
83 /* The device that owns this configuration is memorized in the
84 configuration container itself, easier for back chaining. */
85 configuration -> ux_configuration_device = device;
86
87 /* Save the configuration handle in the container, this is for ensuring the
88 configuration container is not corrupted. */
89 configuration -> ux_configuration_handle = (ULONG) (ALIGN_TYPE) configuration;
90
91 /* There is 2 cases for the creation of the configuration descriptor
92 if this is the first one, the configuration descriptor is hooked
93 to the device. If it is not the first one, the configuration is
94 hooked to the end of the chain of configurations. */
95 if (device -> ux_device_first_configuration == UX_NULL)
96 {
97 device -> ux_device_first_configuration = configuration;
98 }
99 else
100 {
101
102 /* Get the pointer to the first configuration. */
103 list_configuration = device -> ux_device_first_configuration;
104
105 /* And traverse until we have reached the end of the configuration list. */
106 while (list_configuration -> ux_configuration_next_configuration != UX_NULL)
107 {
108 list_configuration = list_configuration -> ux_configuration_next_configuration;
109 }
110
111 /* Hook the new configuration. */
112 list_configuration -> ux_configuration_next_configuration = configuration;
113 }
114
115 /* Return to caller. */
116 return;
117 }
118
119