summaryrefslogtreecommitdiff
path: root/common/core/src/ux_hcd_sim_host_periodic_schedule.c
blob: 6cd4f69d76afdf363bb4715ae156ab2873d655d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/***************************************************************************
 * Copyright (c) 2024 Microsoft Corporation
 * Copyright (c) 2026-present Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * SPDX-License-Identifier: MIT
 **************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */
/** USBX Component                                                        */
/**                                                                       */
/**   Host Simulator Controller Driver                                    */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/

#define UX_SOURCE_CODE


/* Include necessary system files.  */

#include "ux_api.h"
#include "ux_hcd_sim_host.h"


/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _ux_hcd_sim_host_periodic_schedule                  PORTABLE C      */
/*                                                           6.1          */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*     This function schedules new transfers from the periodic interrupt  */
/*     list.                                                              */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    hcd_sim_host                          Pointer to host controller    */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    None                                                                */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    _ux_hcd_sim_host_frame_number_get     Get frame number              */
/*    _ux_hcd_sim_host_transaction_schedule Schedule the transaction      */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    Host Simulator Controller Driver                                    */
/*                                                                        */
/**************************************************************************/
VOID  _ux_hcd_sim_host_periodic_schedule(UX_HCD_SIM_HOST *hcd_sim_host)
{

UX_HCD_SIM_HOST_ED      *ed;
ULONG                   frame_number;

    /* Get the current frame number.  */
    _ux_hcd_sim_host_frame_number_get(hcd_sim_host, &frame_number);

    /* Isolate the low bits to match an entry in the upper periodic entry list.  */
    frame_number &=  UX_HCD_SIM_HOST_PERIODIC_ENTRY_MASK;

    /* Get the first ED in the periodic list.  */
    ed =  hcd_sim_host -> ux_hcd_sim_host_interrupt_ed_list[frame_number];

    /* Search for an entry in the periodic tree.  */
    while (ed != UX_NULL)
    {

        /* The ED has to be a real ED (not static) and has to have a different tail and head TD.  */
        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))
        {

            /* Ensure this ED does not have the SKIP bit set and no TD are in progress. */
            if ((ed -> ux_sim_host_ed_head_td -> ux_sim_host_td_status & UX_HCD_SIM_HOST_TD_ACK_PENDING) == 0)

                /* Insert this transfer in the list of scheduled TDs if possible.  */
                _ux_hcd_sim_host_transaction_schedule(hcd_sim_host, ed);

        }

        /* Point to the next ED in the list.  */
        ed =  ed -> ux_sim_host_ed_next_ed;
    }

    /* Return to caller.  */
    return;
}