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_ed_clean PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Chaoqiong Xiao, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function cleans the tds attached to a ED in case a transfer */ 46 /* has to be aborted. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* ed Pointer to ED */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* Completion Status */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _ux_utility_virtual_address Get virtual address */ 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 /* resulting in version 6.1 */ 71 /* */ 72 /**************************************************************************/ _ux_hcd_ehci_ed_clean(UX_EHCI_ED * ed)73UINT _ux_hcd_ehci_ed_clean(UX_EHCI_ED *ed) 74 { 75 76 UX_EHCI_TD *td; 77 UX_EHCI_TD *next_td; 78 79 80 /* Get the first pointer to the TD. */ 81 td = ed -> ux_ehci_ed_queue_element; 82 td = (UX_EHCI_TD *) ((ULONG) td & ~UX_EHCI_QH_T); 83 td = _ux_utility_virtual_address(td); 84 85 /* Mark the TD link of the endpoint as terminated. */ 86 ed -> ux_ehci_ed_queue_element = (UX_EHCI_TD *) UX_EHCI_TD_T; 87 88 /* Free all tds attached to the ED. */ 89 while (td != UX_NULL) 90 { 91 92 /* Get the next TD pointed by the current TD. */ 93 next_td = td -> ux_ehci_td_link_pointer; 94 next_td = (UX_EHCI_TD *) ((ULONG) next_td & ~UX_EHCI_TD_T); 95 next_td = _ux_utility_virtual_address(next_td); 96 97 /* Mark the current TD as free. */ 98 td -> ux_ehci_td_status = UX_UNUSED; 99 100 td = next_td; 101 } 102 103 /* Reset the first TD. */ 104 ed -> ux_ehci_ed_first_td = UX_NULL; 105 106 /* Reset the last TD. */ 107 ed -> ux_ehci_ed_last_td = UX_NULL; 108 109 /* Return successful completion. */ 110 return(UX_SUCCESS); 111 } 112 113