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_rh_device_extraction PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function handles a device extraction on a downstream port */ |
45 |
|
|
/* of the root hub pointed by HCD. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* HCD Pointer to HCD structure */ |
50 |
|
|
/* port_index Port index of insertion */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* Completion Status */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* _ux_host_stack_device_remove Remove device */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLED BY */ |
61 |
|
|
/* */ |
62 |
|
|
/* USBX Components */ |
63 |
|
|
/* */ |
64 |
|
|
/**************************************************************************/ |
65 |
|
587 |
UINT _ux_host_stack_rh_device_extraction(UX_HCD *hcd, UINT port_index) |
66 |
|
|
{ |
67 |
|
|
|
68 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
69 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_RH_DEVICE_EXTRACTION, hcd, port_index, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) |
70 |
|
|
|
71 |
|
|
/* Ask the stack to remove the device, pass the value 0 as the parent root hub. */ |
72 |
|
587 |
_ux_host_stack_device_remove(hcd, 0, port_index); |
73 |
|
|
|
74 |
|
|
/* The device has been removed, so the port is free again. */ |
75 |
|
579 |
hcd -> ux_hcd_rh_device_connection &= (ULONG)~(1 << port_index); |
76 |
|
|
|
77 |
|
|
/* That command should never fail! */ |
78 |
|
579 |
return(UX_SUCCESS); |
79 |
|
|
} |
80 |
|
|
|