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 /** OHCI 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_ohci.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_hcd_ohci_isochronous_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 isochronous TD list. */
46 /* */
47 /* INPUT */
48 /* */
49 /* hcd_ohci Pointer to OHCI */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* UX_OHCI_ISO_TD * Pointer to OHCI TD */
54 /* */
55 /* CALLS */
56 /* */
57 /* _ux_utility_memory_set Set memory block */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* OHCI 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_ohci_isochronous_td_obtain(UX_HCD_OHCI * hcd_ohci)74 UX_OHCI_ISO_TD *_ux_hcd_ohci_isochronous_td_obtain(UX_HCD_OHCI *hcd_ohci)
75 {
76
77 UX_OHCI_ISO_TD *td;
78 ULONG td_index;
79
80
81 /* Start the search from the beginning of the list. */
82 td = hcd_ohci -> ux_hcd_ohci_iso_td_list;
83 for (td_index = 0; td_index < _ux_system_host -> ux_system_host_max_iso_td; td_index++)
84 {
85
86 /* Check the TD status, a free TD is marked with the UNUSED flag. */
87 if (td -> ux_ohci_iso_td_status == UX_UNUSED)
88 {
89
90 /* The TD may have been used, so we reset all fields. */
91 _ux_utility_memory_set(td, 0, sizeof(UX_OHCI_ISO_TD)); /* Use case of memset is verified. */
92
93 /* This TD is now marked as USED. */
94 td -> ux_ohci_iso_td_status = UX_USED;
95
96 /* Success, return the TD pointer. */
97 return(td);
98 }
99
100 /* Move to next TD. */
101 td++;
102 }
103
104 /* There is no available TD in the TD list. */
105 return(UX_NULL);
106 }
107
108