summaryrefslogtreecommitdiff
path: root/common/usbx_host_controllers/src/ux_hcd_ehci_poll_rate_entry_get.c
blob: 0397293595f71ff65b50e9b187c82febf4255502 (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
/***************************************************************************
 * 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                                                        */
/**                                                                       */
/**   EHCI Controller Driver                                              */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/* Include necessary system files.  */

#define UX_SOURCE_CODE

#include "ux_api.h"
#include "ux_hcd_ehci.h"
#include "ux_host_stack.h"


/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _ux_hcd_ehci_poll_rate_entry_get                    PORTABLE C      */
/*                                                           6.1.2        */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This function return a pointer to the first ED in the periodic tree */
/*    that start specific poll rate.                                      */
/*    Note that when poll rate is longer, poll depth is smaller and       */
/*    endpoint period interval is larger.                                 */
/*      PollInterval   Depth                                              */
/*         1             M                                                */
/*         2            M-1                                               */
/*         4            M-2                                               */
/*         8            M-3                                               */
/*        ...           ...                                               */
/*         N             0                                                */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    hcd_ehci                              Pointer to EHCI controller    */
/*    ed_list                               Pointer to ED list to scan    */
/*    poll_depth                            Poll depth expected           */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    UX_EHCI_ED *                          Pointer to ED                 */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    EHCI Controller Driver                                              */
/*                                                                        */
/**************************************************************************/
UX_EHCI_ED *_ux_hcd_ehci_poll_rate_entry_get(UX_HCD_EHCI *hcd_ehci,
    UX_EHCI_ED *ed_list, ULONG poll_depth)
{


    UX_PARAMETER_NOT_USED(hcd_ehci);

    /* Scan the list of ED/iTD/siTDs from the poll rate lowest/interval longest
       entry until appropriate poll rate node.
       The depth index is the poll rate EHCI value and the first entry (anchor)
       is pointed.  */

    /* Obtain next link pointer including Typ and T.  */
    while(poll_depth --)
    {
        if (ed_list -> REF_AS.ANCHOR.ux_ehci_ed_next_anchor == UX_NULL)
            break;
        ed_list = ed_list -> REF_AS.ANCHOR.ux_ehci_ed_next_anchor;
    }

    /* Return the list entry.  */
    return(ed_list);
}