blob: 7c74c2c59733088cc864c43b2588aacd4fbf0e28 (
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
104
105
106
107
108
109
110
111
112
|
/***************************************************************************
* 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 */
/** */
/** OHCI Controller Driver */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_hcd_ohci.h"
#include "ux_host_stack.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_ohci_next_td_clean PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function cleans all the tds attached to a ED. The end of the */
/* TD chain is pointed by the tail TD. */
/* */
/* INPUT */
/* */
/* td Pointer to OHCI TD */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_utility_physical_address Get physical address */
/* _ux_utility_virtual_address Get virtual address */
/* */
/* CALLED BY */
/* */
/* OHCI Controller Driver */
/* */
/**************************************************************************/
VOID _ux_hcd_ohci_next_td_clean(UX_OHCI_TD *td)
{
UX_OHCI_ED *ed;
UX_OHCI_TD *head_td;
UX_OHCI_TD *tail_td;
ULONG value_td;
ULONG value_carry;
/* Obtain the pointer to the ED from the TD. */
ed = td -> ux_ohci_td_ed;
/* Ensure that the potential Carry bit is maintained in the head ED. */
value_carry = (ULONG)(ed -> ux_ohci_ed_head_td) & UX_OHCI_ED_TOGGLE_CARRY;
/* Ensure that the potential Halt bit is removed in the head ED. */
value_td = (ULONG) _ux_utility_virtual_address(ed -> ux_ohci_ed_head_td) & UX_OHCI_ED_MASK_TD;
head_td = (UX_OHCI_TD *)value_td;
/* Remove all the tds from this ED and leave the head and tail pointing
to the dummy TD. */
tail_td = _ux_utility_virtual_address(ed -> ux_ohci_ed_tail_td);
/* Free all tds attached to the ED. */
while (head_td != tail_td)
{
/* Mark the current head_td as free. */
head_td -> ux_ohci_td_status = UX_UNUSED;
/* Update the head TD with the next TD. */
ed -> ux_ohci_ed_head_td = head_td -> ux_ohci_td_next_td;
/* Now the new head_td is the next TD in the chain. */
head_td = _ux_utility_virtual_address(ed -> ux_ohci_ed_head_td);
}
/* Restore the value carry for next transfers. */
value_td = (ULONG) ed -> ux_ohci_ed_head_td;
value_td |= value_carry;
ed -> ux_ohci_ed_head_td = (UX_OHCI_TD *) value_td;
/* Return to caller. */
return;
}
|