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 /** EHCI Controller Driver */
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_hcd_ehci.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_hcd_ehci_fsisochronous_td_obtain PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function obtains a free TD from the full speed isochronous */
46 /* TD list. */
47 /* */
48 /* INPUT */
49 /* */
50 /* hcd_ehci Pointer to EHCI controller */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* UX_EHCI_FSISO_TD * Pointer to EHCI FSISO TD */
55 /* */
56 /* CALLS */
57 /* */
58 /* None */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* EHCI Controller Driver */
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 /* verified memset and memcpy */
71 /* cases, */
72 /* resulting in version 6.1 */
73 /* */
74 /**************************************************************************/
_ux_hcd_ehci_fsisochronous_td_obtain(UX_HCD_EHCI * hcd_ehci)75 UX_EHCI_FSISO_TD *_ux_hcd_ehci_fsisochronous_td_obtain(UX_HCD_EHCI *hcd_ehci)
76 {
77 #if UX_MAX_ISO_TD == 0 || !defined(UX_HCD_EHCI_SPLIT_TRANSFER_ENABLE)
78
79 /* This function is not yet supported, return NULL. */
80 UX_PARAMETER_NOT_USED(hcd_ehci);
81 return(UX_NULL);
82 #else
83
84 UX_EHCI_FSISO_TD *td;
85 ULONG td_index;
86
87
88 /* Start the search from the beginning of the list. */
89 td = hcd_ehci -> ux_hcd_ehci_fsiso_td_list;
90 for (td_index = 0; td_index < _ux_system_host -> ux_system_host_max_iso_td; td_index++)
91 {
92
93 /* Check the TD status, a free TD is marked with the USED flag. */
94 if (td -> ux_ehci_fsiso_td_status == UX_UNUSED)
95 {
96
97 /* The TD may have been used, so we reset all fields. */
98 _ux_utility_memory_set(td, 0, sizeof(UX_EHCI_FSISO_TD)); /* Use case of memset is verified. */
99
100 /* This TD is now marked as USED. */
101 td -> ux_ehci_fsiso_td_status = UX_USED;
102
103 /* Initialize the link pointer TD fields. */
104 td -> ux_ehci_fsiso_td_next_lp.value = UX_EHCI_FSISO_T;
105
106 /* Success, return TD pointer. */
107 return(td);
108 }
109
110 /* Look at next TD. */
111 td++;
112 }
113
114 /* There is no available TD in the TD list. */
115
116 /* Error, return a null. */
117 return(UX_NULL);
118 #endif
119 }
120
121