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