39 return EFI_OUT_OF_RESOURCES;
42 Qtd->QtdHw.Status = QTD_STAT_HALTED;
43 Ehc->ShortReadStop = Qtd;
51 Ep.Direction = EfiUsbDataIn;
52 Ep.DevSpeed = EFI_USB_SPEED_HIGH;
57 Ep.Type = EHC_BULK_TRANSFER;
63 return EFI_OUT_OF_RESOURCES;
67 QhHw->HorizonLink = QH_LINK (QhHw, EHC_TYPE_QH,
FALSE);
68 QhHw->Status = QTD_STAT_HALTED;
69 QhHw->ReclaimHead = 1;
70 Ehc->ReclaimHead = Qh;
76 Ep.Type = EHC_INT_TRANSFER_SYNC;
81 return EFI_OUT_OF_RESOURCES;
84 Qh->QhHw.Status = QTD_STAT_HALTED;
131 if (EFI_ERROR (Status) || (Buf ==
NULL)) {
132 return EFI_OUT_OF_RESOURCES;
135 Ehc->PeriodFrame = Buf;
136 Ehc->PeriodFrameMap = Map;
137 Ehc->High32bitAddr = EHC_HIGH_32BIT (PhyAddr);
146 EHC_BIT_IS_SET (Ehc->HcCapParams, HCCP_64BIT),
150 if (Ehc->MemPool ==
NULL) {
151 return EFI_OUT_OF_RESOURCES;
156 if (EFI_ERROR (Status)) {
163 Desc = (UINT32 *)Ehc->PeriodFrame;
165 for (Index = 0; Index < EHC_FRAME_LEN; Index++) {
166 Desc[Index] = QH_LINK (PciAddr, EHC_TYPE_QH,
FALSE);
169 EhcWriteOpReg (Ehc, EHC_FRAME_BASE_OFFSET, EHC_LOW_32BIT (PhyAddr));
177 EhcWriteOpReg (Ehc, EHC_ASYNC_HEAD_OFFSET, EHC_LOW_32BIT (PciAddr));
195 if (Ehc->PeriodOne !=
NULL) {
197 Ehc->PeriodOne =
NULL;
200 if (Ehc->ReclaimHead !=
NULL) {
202 Ehc->ReclaimHead =
NULL;
205 if (Ehc->ShortReadStop !=
NULL) {
207 Ehc->ShortReadStop =
NULL;
210 if (Ehc->MemPool !=
NULL) {
215 if (Ehc->PeriodFrame !=
NULL) {
216 IoMmuFreeBuffer (Ehc->IoMmu, 1, Ehc->PeriodFrame, Ehc->PeriodFrameMap);
217 Ehc->PeriodFrame =
NULL;
245 Head = Ehc->ReclaimHead;
247 Qh->NextQh = Head->NextQh;
250 Qh->QhHw.HorizonLink = QH_LINK (Head, EHC_TYPE_QH,
FALSE);
251 Head->QhHw.HorizonLink = QH_LINK (Qh, EHC_TYPE_QH,
FALSE);
270 ASSERT (Ehc->ReclaimHead->NextQh == Qh);
277 Head = Ehc->ReclaimHead;
279 Head->NextQh = Qh->NextQh;
282 Head->QhHw.HorizonLink = QH_LINK (Head, EHC_TYPE_QH,
FALSE);
315 ASSERT ((Ehc !=
NULL) && (Urb !=
NULL) && (Urb->Qh !=
NULL));
320 Urb->Result = EFI_USB_NOERROR;
323 Urb->Result |= EFI_USB_ERR_SYSTEM;
328 Qtd = EFI_LIST_CONTAINER (Entry,
PEI_EHC_QTD, QtdList);
330 State = (UINT8)QtdHw->Status;
332 if (EHC_BIT_IS_SET (State, QTD_STAT_HALTED)) {
337 if ((State & QTD_STAT_ERR_MASK) == 0) {
338 Urb->Result |= EFI_USB_ERR_STALL;
341 if (EHC_BIT_IS_SET (State, QTD_STAT_BABBLE_ERR)) {
342 Urb->Result |= EFI_USB_ERR_BABBLE;
345 if (EHC_BIT_IS_SET (State, QTD_STAT_BUFF_ERR)) {
346 Urb->Result |= EFI_USB_ERR_BUFFER;
349 if (EHC_BIT_IS_SET (State, QTD_STAT_TRANS_ERR) && (QtdHw->ErrCnt == 0)) {
350 Urb->Result |= EFI_USB_ERR_TIMEOUT;
355 }
else if (EHC_BIT_IS_SET (State, QTD_STAT_ACTIVE)) {
359 Urb->Result |= EFI_USB_ERR_NOTEXECUTE;
368 if (QtdHw->Pid != QTD_PID_SETUP) {
369 Urb->Completed += Qtd->DataLen - QtdHw->TotalBytes;
372 if ((QtdHw->TotalBytes != 0) && (QtdHw->Pid == QTD_PID_INPUT)) {
381 if (QtdHw->AltNext == QTD_LINK (Ehc->ShortReadStop,
FALSE)) {
399 Urb->DataToggle = (UINT8)Urb->Qh->QhHw.DataToggle;
427 BOOLEAN InfiniteLoop;
430 Loop = TimeOut * EHC_1_MILLISECOND;
432 InfiniteLoop =
FALSE;
442 for (Index = 0; InfiniteLoop || (Index < Loop); Index++) {
453 Status = EFI_TIMEOUT;
454 }
else if (Urb->Result != EFI_USB_NOERROR) {
455 Status = EFI_DEVICE_ERROR;
EFI_STATUS IoMmuAllocateBuffer(IN UINTN Pages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
EFI_STATUS IoMmuFreeBuffer(IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping)
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
#define BASE_LIST_FOR_EACH(Entry, ListHead)
BOOLEAN EhcCheckUrbResult(IN USB2_HC_DEV *Ehc, IN URB *Urb)
EFI_STATUS EhcInitSched(IN USB2_HC_DEV *Ehc)
VOID EhcLinkQhToAsync(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
VOID EhcFreeSched(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcCreateHelpQ(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcExecTransfer(IN USB2_HC_DEV *Ehc, IN URB *Urb, IN UINTN TimeOut)
VOID EhcUnlinkQhFromAsync(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
EHC_QTD * EhcCreateQtd(IN USB2_HC_DEV *Ehc, IN UINT8 *Data, IN UINT8 *DataPhy, IN UINTN DataLen, IN UINT8 PktId, IN UINT8 Toggle, IN UINTN MaxPacket)
EHC_QH * EhcCreateQh(IN USB2_HC_DEV *Ehci, IN USB_ENDPOINT *Ep)
EFI_PHYSICAL_ADDRESS UsbHcGetPciAddressForHostMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
EFI_STATUS UsbHcFreeMemPool(IN USBHC_MEM_POOL *Pool)
VOID UsbHcFreeMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
USBHC_MEM_POOL * UsbHcInitMemPool(IN EFI_PCI_IO_PROTOCOL *PciIo, IN BOOLEAN Check4G, IN UINT32 Which4G)
VOID EhcWriteOpReg(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Data)
EFI_STATUS EhcSetAndWaitDoorBell(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
BOOLEAN EhcIsHalt(IN USB2_HC_DEV *Ehc)
BOOLEAN EhcIsSysError(IN USB2_HC_DEV *Ehc)
UINT64 EFI_PHYSICAL_ADDRESS