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_periodic_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 periodic interrupt */ 45 /* list. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* hcd_sim_host Pointer to host controller */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* None */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* _ux_hcd_sim_host_frame_number_get Get frame number */ 58 /* _ux_hcd_sim_host_transaction_schedule Schedule the transaction */ 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_periodic_schedule(UX_HCD_SIM_HOST * hcd_sim_host)73VOID _ux_hcd_sim_host_periodic_schedule(UX_HCD_SIM_HOST *hcd_sim_host) 74 { 75 76 UX_HCD_SIM_HOST_ED *ed; 77 ULONG frame_number; 78 79 /* Get the current frame number. */ 80 _ux_hcd_sim_host_frame_number_get(hcd_sim_host, &frame_number); 81 82 /* Isolate the low bits to match an entry in the upper periodic entry list. */ 83 frame_number &= UX_HCD_SIM_HOST_PERIODIC_ENTRY_MASK; 84 85 /* Get the first ED in the periodic list. */ 86 ed = hcd_sim_host -> ux_hcd_sim_host_interrupt_ed_list[frame_number]; 87 88 /* Search for an entry in the periodic tree. */ 89 while (ed != UX_NULL) 90 { 91 92 /* The ED has to be a real ED (not static) and has to have a different tail and head TD. */ 93 if ((ed -> ux_sim_host_ed_status != UX_HCD_SIM_HOST_ED_STATIC) && (ed -> ux_sim_host_ed_tail_td != ed -> ux_sim_host_ed_head_td)) 94 { 95 96 /* Ensure this ED does not have the SKIP bit set and no TD are in progress. */ 97 if ((ed -> ux_sim_host_ed_head_td -> ux_sim_host_td_status & UX_HCD_SIM_HOST_TD_ACK_PENDING) == 0) 98 99 /* Insert this transfer in the list of scheduled TDs if possible. */ 100 _ux_hcd_sim_host_transaction_schedule(hcd_sim_host, ed); 101 102 } 103 104 /* Point to the next ED in the list. */ 105 ed = ed -> ux_sim_host_ed_next_ed; 106 } 107 108 /* Return to caller. */ 109 return; 110 } 111 112