2 OHCI transfer scheduling routines.
4 Copyright (c) 2013-2015 Intel Corporation.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 Convert Error code from OHCI format to EFI format
23 @Param ErrorCode ErrorCode in OHCI format
25 @retval ErrorCode in EFI format
33 UINT32 TransferResult
;
37 TransferResult
= EFI_USB_NOERROR
;
40 case TD_TOBE_PROCESSED
:
41 case TD_TOBE_PROCESSED_2
:
42 TransferResult
= EFI_USB_ERR_NOTEXECUTE
;
46 TransferResult
= EFI_USB_ERR_STALL
;
49 case TD_BUFFER_OVERRUN
:
50 case TD_BUFFER_UNDERRUN
:
51 TransferResult
= EFI_USB_ERR_BUFFER
;
55 TransferResult
= EFI_USB_ERR_CRC
;
59 TransferResult
= EFI_USB_ERR_TIMEOUT
;
62 case TD_BITSTUFFING_ERROR
:
63 TransferResult
= EFI_USB_ERR_BITSTUFF
;
67 TransferResult
= EFI_USB_ERR_SYSTEM
;
70 return TransferResult
;
78 @Param Ohc UHC private data
79 @Param Td TD_DESCRIPTOR
80 @Param Result Result to return
83 @retval FLASE means Error or Short packet
88 IN USB_OHCI_HC_DEV
*Ohc
,
93 UINT32 TdCompletionCode
;
95 *Result
= EFI_USB_NOERROR
;
98 TdCompletionCode
= Td
->Word0
.ConditionCode
;
100 *Result
|= ConvertErrorCode(TdCompletionCode
);
102 // if any error encountered, stop processing the left TDs.
108 Td
= Td
->NextTDPointer
;
117 Check the task status on an ED
119 @Param Ed Pointer to the ED task that TD hooked on
120 @Param HeadTd TD header for current transaction
122 @retval Task Status Code
128 IN ED_DESCRIPTOR
*Ed
,
129 IN TD_DESCRIPTOR
*HeadTd
132 while(HeadTd
!= NULL
) {
133 if (HeadTd
->Word0
.ConditionCode
!= 0) {
134 return HeadTd
->Word0
.ConditionCode
;
136 HeadTd
= HeadTd
->NextTDPointer
;
139 if (OhciGetEDField (Ed
, ED_TDHEAD_PTR
) != OhciGetEDField (Ed
, ED_TDTAIL_PTR
)) {
140 return TD_TOBE_PROCESSED
;
148 Check the task status
150 @Param Ohc UHC private data
151 @Param ListType Pipe type
152 @Param Ed Pointer to the ED task hooked on
153 @Param HeadTd Head of TD corresponding to the task
154 @Param ErrorCode return the ErrorCode
156 @retval EFI_SUCCESS Task done
157 @retval EFI_NOT_READY Task on processing
158 @retval EFI_DEVICE_ERROR Some error occured
163 IN USB_OHCI_HC_DEV
*Ohc
,
164 IN DESCRIPTOR_LIST_TYPE ListType
,
165 IN ED_DESCRIPTOR
*Ed
,
166 IN TD_DESCRIPTOR
*HeadTd
,
167 OUT UINT32
*ErrorCode
170 *ErrorCode
= TD_TOBE_PROCESSED
;
174 if (OhciGetHcCommandStatus (Ohc
, CONTROL_LIST_FILLED
) != 0) {
175 return EFI_NOT_READY
;
180 if (OhciGetHcCommandStatus (Ohc
, BULK_LIST_FILLED
) != 0) {
181 return EFI_NOT_READY
;
189 *ErrorCode
= CheckEDStatus (Ed
, HeadTd
);
192 if (*ErrorCode
== TD_NO_ERROR
) {
194 } else if (*ErrorCode
== TD_TOBE_PROCESSED
) {
195 return EFI_NOT_READY
;
197 return EFI_DEVICE_ERROR
;
204 Convert TD condition code to Efi Status
206 @Param ConditionCode Condition code to convert
208 @retval EFI_SUCCESS No error occured
209 @retval EFI_NOT_READY TD still on processing
210 @retval EFI_DEVICE_ERROR Error occured in processing TD
215 OhciTDConditionCodeToStatus (
216 IN UINT32 ConditionCode
219 if (ConditionCode
== TD_NO_ERROR
) {
223 if (ConditionCode
== TD_TOBE_PROCESSED
) {
224 return EFI_NOT_READY
;
227 return EFI_DEVICE_ERROR
;