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 |
|
|
/** 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 |
|
|
/**************************************************************************/ |
67 |
|
1059 |
VOID _ux_host_stack_new_configuration_create(UX_DEVICE *device, UX_CONFIGURATION *configuration) |
68 |
|
|
{ |
69 |
|
|
|
70 |
|
|
UX_CONFIGURATION *list_configuration; |
71 |
|
|
|
72 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
73 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_NEW_CONFIGURATION_CREATE, device, configuration, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) |
74 |
|
|
|
75 |
|
|
/* The device that owns this configuration is memorized in the |
76 |
|
|
configuration container itself, easier for back chaining. */ |
77 |
|
1059 |
configuration -> ux_configuration_device = device; |
78 |
|
|
|
79 |
|
|
/* Save the configuration handle in the container, this is for ensuring the |
80 |
|
|
configuration container is not corrupted. */ |
81 |
|
1059 |
configuration -> ux_configuration_handle = (ULONG) (ALIGN_TYPE) configuration; |
82 |
|
|
|
83 |
|
|
/* There is 2 cases for the creation of the configuration descriptor |
84 |
|
|
if this is the first one, the configuration descriptor is hooked |
85 |
|
|
to the device. If it is not the first one, the configuration is |
86 |
|
|
hooked to the end of the chain of configurations. */ |
87 |
✓✓ |
1059 |
if (device -> ux_device_first_configuration == UX_NULL) |
88 |
|
|
{ |
89 |
|
1052 |
device -> ux_device_first_configuration = configuration; |
90 |
|
|
} |
91 |
|
|
else |
92 |
|
|
{ |
93 |
|
|
|
94 |
|
|
/* Get the pointer to the first configuration. */ |
95 |
|
7 |
list_configuration = device -> ux_device_first_configuration; |
96 |
|
|
|
97 |
|
|
/* And traverse until we have reached the end of the configuration list. */ |
98 |
✓✓ |
9 |
while (list_configuration -> ux_configuration_next_configuration != UX_NULL) |
99 |
|
|
{ |
100 |
|
2 |
list_configuration = list_configuration -> ux_configuration_next_configuration; |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
/* Hook the new configuration. */ |
104 |
|
7 |
list_configuration -> ux_configuration_next_configuration = configuration; |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
/* Return to caller. */ |
108 |
|
1059 |
return; |
109 |
|
|
} |
110 |
|
|
|