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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/***************************************************************************
* 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_transfer_abort PORTABLE C */
/* 6.1.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function will abort transactions attached to a transfer */
/* request. */
/* */
/* INPUT */
/* */
/* hcd_ohci Pointer to OHCI controller */
/* transfer_request Pointer to transfer request */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_utility_delay_ms Delay */
/* _ux_utility_physical_address Get physical address */
/* _ux_utility_virtual_address Get virtual address */
/* */
/* CALLED BY */
/* */
/* OHCI Controller Driver */
/* */
/**************************************************************************/
UINT _ux_hcd_ohci_transfer_abort(UX_HCD_OHCI *hcd_ohci, UX_TRANSFER *transfer_request)
{
UX_ENDPOINT *endpoint;
UX_OHCI_ED *ed;
UX_OHCI_TD *head_td;
UX_OHCI_TD *tail_td;
ULONG value_td;
ULONG value_carry;
UX_PARAMETER_NOT_USED(hcd_ohci);
/* Get the pointer to the endpoint associated with the transfer request. */
endpoint = (UX_ENDPOINT *) transfer_request -> ux_transfer_request_endpoint;
/* From the endpoint container, get the address of the physical endpoint. */
ed = (UX_OHCI_ED *) endpoint -> ux_endpoint_ed;
/* Check if this physical endpoint has been initialized properly! */
if (ed == UX_NULL)
{
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_HCD, UX_ENDPOINT_HANDLE_UNKNOWN);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_ENDPOINT_HANDLE_UNKNOWN, endpoint, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_ENDPOINT_HANDLE_UNKNOWN);
}
/* The endpoint may be active. If so, set the skip bit. */
ed -> ux_ohci_ed_dw0 |= UX_OHCI_ED_SKIP;
/* Wait for the controller to finish the current frame processing. */
_ux_utility_delay_ms(1);
/* 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)
{
/* Update the head TD with the next TD. */
ed -> ux_ohci_ed_head_td = head_td -> ux_ohci_td_next_td;
/* Mark the current head TD as free. */
head_td -> ux_ohci_td_status = UX_UNUSED;
/* 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;
/* Remove the reset bit in the ED. */
ed -> ux_ohci_ed_dw0 &= ~UX_OHCI_ED_SKIP;
/* Return successful completion. */
return(UX_SUCCESS);
}
|