1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** USBX Component */
16 /** */
17 /** EHCI Controller Driver */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22
23 /* Include necessary system files. */
24
25 #define UX_SOURCE_CODE
26
27 #include "ux_api.h"
28 #include "ux_hcd_ehci.h"
29 #include "ux_host_stack.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_hcd_ehci_hsisochronous_td_obtain PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function obtains a free TD from the high speed isochronous */
45 /* TD list. */
46 /* */
47 /* INPUT */
48 /* */
49 /* hcd_ehci Pointer to EHCI controller */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* UX_EHCI_HSISO_TD * Pointer to EHCI HSISO TD */
54 /* */
55 /* CALLS */
56 /* */
57 /* None */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* EHCI 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 /* verified memset and memcpy */
70 /* cases, */
71 /* resulting in version 6.1 */
72 /* */
73 /**************************************************************************/
_ux_hcd_ehci_hsisochronous_td_obtain(UX_HCD_EHCI * hcd_ehci)74 UX_EHCI_HSISO_TD *_ux_hcd_ehci_hsisochronous_td_obtain(UX_HCD_EHCI *hcd_ehci)
75 {
76 #if UX_MAX_ISO_TD == 0
77
78 /* This function is not yet supported, return NULL. */
79 UX_PARAMETER_NOT_USED(hcd_ehci);
80 return(UX_NULL);
81 #else
82
83 UX_EHCI_HSISO_TD *td;
84 ULONG td_index;
85
86
87 /* Start the search from the beginning of the list. */
88 td = hcd_ehci -> ux_hcd_ehci_hsiso_td_list;
89 for (td_index = 0; td_index < _ux_system_host -> ux_system_host_max_iso_td; td_index++)
90 {
91
92 /* Check the TD status, a free TD is marked with the USED flag. */
93 if (td -> ux_ehci_hsiso_td_status == UX_UNUSED)
94 {
95
96 /* The TD may have been used, so we reset all fields. */
97 _ux_utility_memory_set(td, 0, sizeof(UX_EHCI_HSISO_TD)); /* Use case of memset is verified. */
98
99 /* This TD is now marked as USED. */
100 td -> ux_ehci_hsiso_td_status = UX_USED;
101
102 /* Initialize the link pointer TD fields. */
103 td -> ux_ehci_hsiso_td_next_lp.value = UX_EHCI_HSISO_T;
104
105 /* Success, return TD pointer. */
106 return(td);
107 }
108
109 /* Look at next TD. */
110 td++;
111 }
112
113 /* There is no available TD in the TD list. */
114
115 /* Error, return a null. */
116 return(UX_NULL);
117 #endif
118 }
119
120