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 /** Host Simulator Controller Driver */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define UX_SOURCE_CODE 24 25 26 /* Include necessary system files. */ 27 28 #include "ux_api.h" 29 #include "ux_hcd_sim_host.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _ux_hcd_sim_host_isochronous_endpoint_create PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function creates an isochronous endpoint. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* hcd_sim_host Pointer to host controller */ 49 /* endpoint Pointer to endpoint */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* Completion Status */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* _ux_hcd_sim_host_ed_obtain Obtain host ED */ 58 /* _ux_hcd_sim_host_isochronous_td_obtain Obtain host ISO TD */ 59 /* */ 60 /* CALLED BY */ 61 /* */ 62 /* Host Simulator 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_sim_host_isochronous_endpoint_create(UX_HCD_SIM_HOST * hcd_sim_host,UX_ENDPOINT * endpoint)73UINT _ux_hcd_sim_host_isochronous_endpoint_create(UX_HCD_SIM_HOST *hcd_sim_host, UX_ENDPOINT *endpoint) 74 { 75 76 UX_HCD_SIM_HOST_ED *ed; 77 UX_HCD_SIM_HOST_ED *head_ed; 78 UX_HCD_SIM_HOST_ISO_TD *td; 79 80 81 /* Obtain a ED for this new endpoint. This ED will live as long as the endpoint is 82 active and will be the container for the TDs. */ 83 ed = _ux_hcd_sim_host_ed_obtain(hcd_sim_host); 84 if (ed == UX_NULL) 85 return(UX_NO_ED_AVAILABLE); 86 87 /* Obtain a dummy isoch TD for terminating the ED transfer chain. */ 88 td = _ux_hcd_sim_host_isochronous_td_obtain(hcd_sim_host); 89 if (td == UX_NULL) 90 { 91 92 ed -> ux_sim_host_ed_status = UX_UNUSED; 93 return(UX_NO_TD_AVAILABLE); 94 } 95 96 /* Attach the ED to the endpoint container. */ 97 endpoint -> ux_endpoint_ed = (VOID *) ed; 98 99 /* Hook the TD to both the tail and head of the ED. */ 100 ed -> ux_sim_host_ed_tail_td = (UX_HCD_SIM_HOST_TD *) ((void *) td); 101 ed -> ux_sim_host_ed_head_td = (UX_HCD_SIM_HOST_TD *) ((void *) td); 102 103 /* Attach this ED to the ISO list. */ 104 head_ed = hcd_sim_host -> ux_hcd_sim_host_iso_head_ed; 105 ed -> ux_sim_host_ed_next_ed = head_ed; 106 hcd_sim_host -> ux_hcd_sim_host_iso_head_ed = ed; 107 108 /* Build the back chaining pointer. The previous head ED needs to know about the 109 inserted ED. */ 110 if (head_ed != UX_NULL) 111 head_ed -> ux_sim_host_ed_previous_ed = ed; 112 113 /* Return successful completion. */ 114 return(UX_SUCCESS); 115 } 116 117