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_asynchronous_endpoint_destroy PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Chaoqiong Xiao, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function will destroy an asynchronous endpoint. The control */ 46 /* and bulk endpoints fall into this category. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* hcd_ehci Pointer to EHCI controller */ 51 /* endpoint Pointer to endpoint */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* Completion Status */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _ux_hcd_ehci_door_bell_wait Wait for door bell */ 60 /* _ux_utility_physical_address Get physical address */ 61 /* */ 62 /* CALLED BY */ 63 /* */ 64 /* EHCI Controller Driver */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 71 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _ux_hcd_ehci_asynchronous_endpoint_destroy(UX_HCD_EHCI * hcd_ehci,UX_ENDPOINT * endpoint)75UINT _ux_hcd_ehci_asynchronous_endpoint_destroy(UX_HCD_EHCI *hcd_ehci, UX_ENDPOINT *endpoint) 76 { 77 78 UX_EHCI_ED *ed; 79 UX_EHCI_ED *previous_ed; 80 UX_EHCI_ED *next_ed; 81 UX_EHCI_LINK_POINTER queue_head; 82 83 84 /* From the endpoint container fetch the EHCI ED descriptor. */ 85 ed = (UX_EHCI_ED *) endpoint -> ux_endpoint_ed; 86 87 /* Get the previous ED in the list for this ED. */ 88 previous_ed = ed -> ux_ehci_ed_previous_ed; 89 90 /* Get the next ED in the list for this ED. */ 91 next_ed = ed -> ux_ehci_ed_next_ed; 92 93 /* Point the previous ED to the ED after the ED to be removed. */ 94 previous_ed -> ux_ehci_ed_next_ed = next_ed; 95 96 /* Point the next ED previous pointer to the previous ED. */ 97 next_ed -> ux_ehci_ed_previous_ed = previous_ed; 98 99 /* Now remove the physical link. */ 100 queue_head.void_ptr = _ux_utility_physical_address(next_ed); 101 queue_head.value |= UX_EHCI_QH_TYP_QH; 102 previous_ed -> ux_ehci_ed_queue_head = queue_head.ed_ptr; 103 104 /* If this ED was the last ED, we need to update the HCD last ED value. */ 105 if (hcd_ehci -> ux_hcd_ehci_asynch_last_list == ed) 106 hcd_ehci -> ux_hcd_ehci_asynch_last_list = previous_ed; 107 108 /* Arm the doorbell and wait for its completion. */ 109 _ux_hcd_ehci_door_bell_wait(hcd_ehci); 110 111 /* Now we can safely make the ED free. */ 112 ed -> ux_ehci_ed_status = UX_UNUSED; 113 114 /* Return successful completion. */ 115 return(UX_SUCCESS); 116 } 117 118