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 Simulator Controller Driver                                    */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define UX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "ux_api.h"
29 #include "ux_hcd_sim_host.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _ux_hcd_sim_host_ed_td_clean                        PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Chaoqiong Xiao, Microsoft Corporation                               */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function process cleans the ED of all TDs except the last      */
45 /*    dummy TD.                                                           */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    ed                                    Pointer to ED                 */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    None                                                                */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    Host Simulator Controller Driver                                    */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
68 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_ux_hcd_sim_host_ed_td_clean(UX_HCD_SIM_HOST_ED * ed)72 VOID  _ux_hcd_sim_host_ed_td_clean(UX_HCD_SIM_HOST_ED *ed)
73 {
74 
75 UX_HCD_SIM_HOST_TD      *head_td;
76 UX_HCD_SIM_HOST_TD      *tail_td;
77 
78 
79     /* Remove all the tds from this ED and leave the head and tail pointing
80        to the dummy TD.  */
81     head_td =  ed -> ux_sim_host_ed_head_td;
82     tail_td =  ed -> ux_sim_host_ed_tail_td;
83 
84     /* Free all tds attached to the ED.  */
85     while (head_td != tail_td)
86     {
87 
88         /* Mark the current head TD as free.  */
89         head_td -> ux_sim_host_td_status =  UX_UNUSED;
90 
91         /* Update the head TD with the next TD.  */
92         ed -> ux_sim_host_ed_head_td =  head_td -> ux_sim_host_td_next_td;
93 
94         /* Now the new head_td is the next TD in the chain.  */
95         head_td =  ed -> ux_sim_host_ed_head_td;
96     }
97 }
98 
99