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 |
|
|
/** HUB Class */ |
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 |
|
|
#include "ux_host_class_hub.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _ux_host_class_hub_transfer_request_completed PORTABLE C */ |
38 |
|
|
/* 6.1.12 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function is called by the completion thread when a transfer */ |
46 |
|
|
/* request has been completed either because the transfer is */ |
47 |
|
|
/* successful or there was an error. */ |
48 |
|
|
/* */ |
49 |
|
|
/* Because the HUB influences the topology of the USB, the insertion */ |
50 |
|
|
/* or extraction of devices cannot be done during the transfer request */ |
51 |
|
|
/* thread. We post a signal to the topology thread to wake up and */ |
52 |
|
|
/* treat these changes on the HUB status. */ |
53 |
|
|
/* */ |
54 |
|
|
/* In RTOS mode, the interrupt pipe is not reactivated here. We will */ |
55 |
|
|
/* do this when the topology thread has investigated the reason of the */ |
56 |
|
|
/* transfer completion. */ |
57 |
|
|
/* */ |
58 |
|
|
/* In standalone mode, the interrupt pipe is reactivated here. The */ |
59 |
|
|
/* bitmap in buffer is examined in hub tasks function. */ |
60 |
|
|
/* */ |
61 |
|
|
/* INPUT */ |
62 |
|
|
/* */ |
63 |
|
|
/* transfer_request Pointer to transfer request */ |
64 |
|
|
/* */ |
65 |
|
|
/* OUTPUT */ |
66 |
|
|
/* */ |
67 |
|
|
/* None */ |
68 |
|
|
/* */ |
69 |
|
|
/* CALLS */ |
70 |
|
|
/* */ |
71 |
|
|
/* _ux_host_semaphore_put Put the signaling semaphore */ |
72 |
|
|
/* */ |
73 |
|
|
/* CALLED BY */ |
74 |
|
|
/* */ |
75 |
|
|
/* HUB Class */ |
76 |
|
|
/* */ |
77 |
|
|
/**************************************************************************/ |
78 |
|
67 |
VOID _ux_host_class_hub_transfer_request_completed(UX_TRANSFER *transfer_request) |
79 |
|
|
{ |
80 |
|
|
|
81 |
|
|
UX_HOST_CLASS_HUB *hub; |
82 |
|
|
|
83 |
|
|
|
84 |
|
|
/* Get the class instance for this transfer request. */ |
85 |
|
67 |
hub = (UX_HOST_CLASS_HUB *) transfer_request -> ux_transfer_request_class_instance; |
86 |
|
|
|
87 |
|
|
|
88 |
|
|
/* Check the state of the transfer. If there is an error, we do not proceed with this report. */ |
89 |
✓✓ |
67 |
if (transfer_request -> ux_transfer_request_completion_code != UX_SUCCESS) |
90 |
|
|
{ |
91 |
|
|
|
92 |
|
|
/* We have an error. We do not rehook another transfer if the device instance is shutting down or |
93 |
|
|
if the transfer was aborted by the class. */ |
94 |
✓✓ |
40 |
if ((hub -> ux_host_class_hub_state == UX_HOST_CLASS_INSTANCE_SHUTDOWN) || |
95 |
✓✓ |
3 |
(transfer_request -> ux_transfer_request_completion_code == UX_TRANSFER_STATUS_ABORT) || |
96 |
✓✓ |
2 |
(transfer_request -> ux_transfer_request_completion_code == UX_TRANSFER_NO_ANSWER)) |
97 |
|
|
|
98 |
|
|
/* We do not proceed. */ |
99 |
|
39 |
return; |
100 |
|
|
else |
101 |
|
|
|
102 |
|
|
{ |
103 |
|
|
|
104 |
|
|
/* Reactivate the HUB interrupt pipe. */ |
105 |
|
1 |
_ux_host_stack_transfer_request(transfer_request); |
106 |
|
|
|
107 |
|
|
/* We do not proceed. */ |
108 |
|
1 |
return; |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
#if defined(UX_HOST_STANDALONE) |
113 |
|
|
|
114 |
|
|
/* Reactivate the HUB interrupt pipe. */ |
115 |
|
|
_ux_host_stack_transfer_request(transfer_request); |
116 |
|
|
#else |
117 |
|
|
|
118 |
|
|
/* We need to memorize which HUB instance has received a change signal. */ |
119 |
|
27 |
hub -> ux_host_class_hub_change_semaphore++; |
120 |
|
|
|
121 |
|
|
/* Now we can set the semaphore, the enum thread will wake up and will |
122 |
|
|
call the HUB instance which has a status change. */ |
123 |
|
27 |
_ux_host_semaphore_put(&_ux_system_host -> ux_system_host_enum_semaphore); |
124 |
|
|
#endif |
125 |
|
|
|
126 |
|
|
/* Return to caller. */ |
127 |
|
27 |
return; |
128 |
|
|
} |