blob: a1a0ce39d6d71324c440359e77a56ceedb3b5ebb (
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
|
/***************************************************************************
* 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 */
/** */
/** Host Stack */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_stack.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_enum_thread_entry PORTABLE C */
/* 6.1.10 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file contains the enum thread for USBX. It is in charge of */
/* the topology changes either from device insertion\extraction on */
/* the root hub or on a regular hub. */
/* */
/* This thread ensures we never have more that 2 instances trying to */
/* perform a change to the topology (mostly enumeration) for fear that */
/* more than one device could answer to address 0. */
/* */
/* This function is the entry point of the topology thread. It waits */
/* until one of the HCDs or a hub sets the semaphore to indicate */
/* there has been a change in the USB topology which could be either */
/* a insertion or extraction or eventually a hub downstream port */
/* signal. */
/* */
/* This is for RTOS mode. */
/* */
/* INPUT */
/* */
/* input Not used input */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_host_stack_rh_change_process Root hub processing */
/* _ux_utility_semaphore_get Get signal semaphore */
/* (ux_system_host_enum_hub_function) HUB enum processing function */
/* */
/* CALLED BY */
/* */
/* ThreadX */
/* */
/**************************************************************************/
VOID _ux_host_stack_enum_thread_entry(ULONG input)
{
UX_PARAMETER_NOT_USED(input);
/* Loop forever waiting for changes signaled through the semaphore. */
while (1)
{
/* Wait for the semaphore to be put by the root hub or a regular hub. */
_ux_host_semaphore_get_norc(&_ux_system_host -> ux_system_host_enum_semaphore, UX_WAIT_FOREVER);
#if UX_MAX_DEVICES > 1
/* We try the hub first. For this we look into the USBX project
structure to see if there is at least one hub. */
if (_ux_system_host -> ux_system_host_enum_hub_function != UX_NULL)
{
/* Yes, there is a HUB function, call it! */
_ux_system_host -> ux_system_host_enum_hub_function();
}
#endif
/* The signal may be also coming from the root hub, call the root hub handler. */
_ux_host_stack_rh_change_process();
}
}
|