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_ed_obtain PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function obtains a free ED from the ED list. */
46 /* */
47 /* INPUT */
48 /* */
49 /* hcd_ohci Pointer to OHCI HCD */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* UX_OHCI_ED * Pointer to ED */
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_ed_obtain(UX_HCD_OHCI * hcd_ohci)74 UX_OHCI_ED *_ux_hcd_ohci_ed_obtain(UX_HCD_OHCI *hcd_ohci)
75 {
76
77 UX_OHCI_ED *ed;
78 ULONG ed_index;
79
80
81 /* Start the search from the beginning of the list. */
82 ed = hcd_ohci -> ux_hcd_ohci_ed_list;
83 for (ed_index = 0; ed_index < _ux_system_host -> ux_system_host_max_ed; ed_index++)
84 {
85
86 /* Check the ED status, a free ED is marked with the UNUSED flag. */
87 if (ed -> ux_ohci_ed_status == UX_UNUSED)
88 {
89
90 /* The ED may have been used, so we reset all fields. */
91 _ux_utility_memory_set(ed, 0, sizeof(UX_OHCI_ED)); /* Use case of memset is verified. */
92
93 /* This ED is now marked as USED. */
94 ed -> ux_ohci_ed_status = UX_USED;
95
96 /* Success, return the ED pointer. */
97 return(ed);
98 }
99
100 /* Point to the next ED. */
101 ed++;
102 }
103
104 /* There is no available ED in the ED list, return a NULL. */
105 return(UX_NULL);
106 }
107
108