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_asynch_schedule PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function schedules new transfers from the control/bulk lists. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* hcd_sim_host Pointer to host controller */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* None */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* _ux_hcd_sim_host_transaction_schedule Schedule simulator transaction*/ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* Host Simulator Controller Driver */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 67 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _ux_hcd_sim_host_asynch_schedule(UX_HCD_SIM_HOST * hcd_sim_host)71VOID _ux_hcd_sim_host_asynch_schedule(UX_HCD_SIM_HOST *hcd_sim_host) 72 { 73 74 UX_HCD_SIM_HOST_ED *ed; 75 UX_HCD_SIM_HOST_ED *first_ed; 76 UINT status; 77 78 79 /* Get the pointer to the current ED in the asynchronous list. */ 80 ed = hcd_sim_host -> ux_hcd_sim_host_asynch_current_ed; 81 82 /* Check if there is any ED candidate in the asynch list. */ 83 if (ed == UX_NULL) 84 { 85 86 /* Check if there is any ED in the asynch list. If none, nothing to do. */ 87 if (hcd_sim_host -> ux_hcd_sim_host_asynch_head_ed == UX_NULL) 88 return; 89 else 90 ed = hcd_sim_host -> ux_hcd_sim_host_asynch_head_ed; 91 } 92 93 /* Remember this ED. */ 94 first_ed = ed; 95 96 /* In simulation, we are not tied to bandwidth limitation. */ 97 do 98 { 99 100 /* Check if this ED has a tail and head TD different. */ 101 if (ed -> ux_sim_host_ed_tail_td != ed -> ux_sim_host_ed_head_td) 102 { 103 104 /* Schedule this transaction with the device simulator. */ 105 status = _ux_hcd_sim_host_transaction_schedule(hcd_sim_host, ed); 106 107 /* If the TD has been added to the list, we can memorize this ED has 108 being served and make the next ED as the one to be first scanned 109 at the next SOF. */ 110 if (status == UX_SUCCESS) 111 { 112 113 if (ed -> ux_sim_host_ed_next_ed == UX_NULL) 114 hcd_sim_host -> ux_hcd_sim_host_asynch_current_ed = hcd_sim_host -> ux_hcd_sim_host_asynch_head_ed; 115 else 116 hcd_sim_host -> ux_hcd_sim_host_asynch_current_ed = ed -> ux_sim_host_ed_next_ed; 117 } 118 } 119 120 /* Point to the next ED in the list. Check if at end of list. */ 121 if (ed -> ux_sim_host_ed_next_ed == UX_NULL) 122 ed = hcd_sim_host -> ux_hcd_sim_host_asynch_head_ed; 123 else 124 ed = ed -> ux_sim_host_ed_next_ed; 125 126 } while ((ed) && (ed != first_ed)); 127 } 128 129