1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
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 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
69 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
70 /* resulting in version 6.1 */
71 /* */
72 /**************************************************************************/
_ux_host_stack_rh_device_extraction(UX_HCD * hcd,UINT port_index)73 UINT _ux_host_stack_rh_device_extraction(UX_HCD *hcd, UINT port_index)
74 {
75
76 /* If trace is enabled, insert this event into the trace buffer. */
77 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_RH_DEVICE_EXTRACTION, hcd, port_index, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
78
79 /* Ask the stack to remove the device, pass the value 0 as the parent root hub. */
80 _ux_host_stack_device_remove(hcd, 0, port_index);
81
82 /* The device has been removed, so the port is free again. */
83 hcd -> ux_hcd_rh_device_connection &= (ULONG)~(1 << port_index);
84
85 /* That command should never fail! */
86 return(UX_SUCCESS);
87 }
88
89