blob: d0dc1cd0b188d0db97f0db8245a05b41627e6ef5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** HUB Class */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_stack.h"
#include "ux_host_class_hub.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hub_transfer_request_completed PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function is called by the completion thread when a transfer */
/* request has been completed either because the transfer is */
/* successful or there was an error. */
/* */
/* Because the HUB influences the topology of the USB, the insertion */
/* or extraction of devices cannot be done during the transfer request */
/* thread. We post a signal to the topology thread to wake up and */
/* treat these changes on the HUB status. */
/* */
/* In RTOS mode, the interrupt pipe is not reactivated here. We will */
/* do this when the topology thread has investigated the reason of the */
/* transfer completion. */
/* */
/* In standalone mode, the interrupt pipe is reactivated here. The */
/* bitmap in buffer is examined in hub tasks function. */
/* */
/* INPUT */
/* */
/* transfer_request Pointer to transfer request */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_host_semaphore_put Put the signaling semaphore */
/* */
/* CALLED BY */
/* */
/* HUB Class */
/* */
/**************************************************************************/
VOID _ux_host_class_hub_transfer_request_completed(UX_TRANSFER *transfer_request)
{
UX_HOST_CLASS_HUB *hub;
/* Get the class instance for this transfer request. */
hub = (UX_HOST_CLASS_HUB *) transfer_request -> ux_transfer_request_class_instance;
/* Check the state of the transfer. If there is an error, we do not proceed with this report. */
if (transfer_request -> ux_transfer_request_completion_code != UX_SUCCESS)
{
/* We have an error. We do not rehook another transfer if the device instance is shutting down or
if the transfer was aborted by the class. */
if ((hub -> ux_host_class_hub_state == UX_HOST_CLASS_INSTANCE_SHUTDOWN) ||
(transfer_request -> ux_transfer_request_completion_code == UX_TRANSFER_STATUS_ABORT) ||
(transfer_request -> ux_transfer_request_completion_code == UX_TRANSFER_NO_ANSWER))
/* We do not proceed. */
return;
else
{
/* Reactivate the HUB interrupt pipe. */
_ux_host_stack_transfer_request(transfer_request);
/* We do not proceed. */
return;
}
}
#if defined(UX_HOST_STANDALONE)
/* Reactivate the HUB interrupt pipe. */
_ux_host_stack_transfer_request(transfer_request);
#else
/* We need to memorize which HUB instance has received a change signal. */
hub -> ux_host_class_hub_change_semaphore++;
/* Now we can set the semaphore, the enum thread will wake up and will
call the HUB instance which has a status change. */
_ux_host_semaphore_put(&_ux_system_host -> ux_system_host_enum_semaphore);
#endif
/* Return to caller. */
return;
}
|