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_hcd_thread_entry PORTABLE C */ |
37 |
|
|
/* 6.1.10 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function is the entry point of the host controller thread. */ |
45 |
|
|
/* The HCD thread is initialized at the system level and the thread */ |
46 |
|
|
/* entry routine is invoked right away. This thread suspends until */ |
47 |
|
|
/* one of the HCD resumes it due to HCD activities. */ |
48 |
|
|
/* */ |
49 |
|
|
/* It's for RTOS mode. */ |
50 |
|
|
/* */ |
51 |
|
|
/* INPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* input Not used input */ |
54 |
|
|
/* */ |
55 |
|
|
/* OUTPUT */ |
56 |
|
|
/* */ |
57 |
|
|
/* None */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLS */ |
60 |
|
|
/* */ |
61 |
|
|
/* _ux_utility_semaphore_get Get signal semaphore */ |
62 |
|
|
/* (ux_hcd_entry_function) HCD's entry function */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLED BY */ |
65 |
|
|
/* */ |
66 |
|
|
/* ThreadX */ |
67 |
|
|
/* */ |
68 |
|
|
/**************************************************************************/ |
69 |
|
363 |
VOID _ux_host_stack_hcd_thread_entry(ULONG input) |
70 |
|
|
{ |
71 |
|
|
|
72 |
|
|
UINT hcd_index; |
73 |
|
|
UX_HCD *hcd; |
74 |
|
|
UX_INTERRUPT_SAVE_AREA |
75 |
|
|
|
76 |
|
|
UX_PARAMETER_NOT_USED(input); |
77 |
|
|
|
78 |
|
|
/* Loop forever on the semaphore. The semaphore is used to signal that |
79 |
|
|
there is work for one or more HCDs. */ |
80 |
|
|
while (1) |
81 |
|
|
{ |
82 |
|
|
|
83 |
|
|
/* Get the semaphore that signals something is available for this |
84 |
|
|
thread to process. */ |
85 |
|
166091 |
_ux_host_semaphore_get_norc(&_ux_system_host -> ux_system_host_hcd_semaphore, UX_WAIT_FOREVER); |
86 |
|
|
|
87 |
|
|
#if UX_MAX_HCD > 1 |
88 |
|
|
/* This thread was awaken by one or more HCD controllers. Check each of the HCDs |
89 |
|
|
to see who posted work to do. */ |
90 |
✓✓ |
497184 |
for(hcd_index = 0; hcd_index < _ux_system_host -> ux_system_host_max_hcd; hcd_index++) |
91 |
|
|
{ |
92 |
|
|
#else |
93 |
|
|
hcd_index = 0; |
94 |
|
|
#endif |
95 |
|
|
|
96 |
|
|
/* Pickup HCD pointer. */ |
97 |
|
331456 |
hcd = &_ux_system_host -> ux_system_host_hcd_array[hcd_index]; |
98 |
|
|
|
99 |
|
|
/* Is there work to do for this HCD? */ |
100 |
✓✓✓✓
|
331456 |
if((hcd -> ux_hcd_status == UX_HCD_STATUS_OPERATIONAL) && (hcd -> ux_hcd_thread_signal !=0)) |
101 |
|
|
{ |
102 |
|
|
|
103 |
|
|
/* Yes, call the HCD function to process the work. */ |
104 |
|
165728 |
hcd -> ux_hcd_entry_function(hcd, UX_HCD_PROCESS_DONE_QUEUE, UX_NULL); |
105 |
|
165728 |
UX_DISABLE |
106 |
|
165728 |
hcd -> ux_hcd_thread_signal--; |
107 |
|
165728 |
UX_RESTORE |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
#if UX_MAX_HCD > 1 |
111 |
|
|
} |
112 |
|
|
#endif |
113 |
|
|
} |
114 |
|
|
} |
115 |
|
|
|