53 Qtd->Signature = EHC_QTD_SIG;
60 QtdHw->NextQtd = QTD_LINK (
NULL,
TRUE);
61 QtdHw->AltNext = QTD_LINK (
NULL,
TRUE);
62 QtdHw->Status = QTD_STAT_ACTIVE;
64 QtdHw->ErrCnt = QTD_MAX_ERR;
66 QtdHw->TotalBytes = 0;
67 QtdHw->DataToggle = Toggle;
75 for (Index = 0; Index <= QTD_MAX_BUFFER; Index++) {
81 QtdHw->Page[Index] = EHC_LOW_32BIT (DataPhy);
82 QtdHw->PageHigh[Index] = EHC_HIGH_32BIT (DataPhy);
84 ThisBufLen = QTD_BUF_LEN - (EHC_LOW_32BIT (DataPhy) & QTD_BUF_MASK);
86 if (Len + ThisBufLen >= DataLen) {
93 DataPhy += ThisBufLen;
103 Len = Len - Len % MaxPacket;
106 QtdHw->TotalBytes = (UINT32)Len;
137 if (Ep->DevSpeed == EFI_USB_SPEED_HIGH) {
138 QhHw->SMask = QH_MICROFRAME_0;
153 QhHw->SMask = QH_MICROFRAME_1;
154 QhHw->CMask = QH_MICROFRAME_3 | QH_MICROFRAME_4 | QH_MICROFRAME_5;
181 Qh->Signature = EHC_QH_SIG;
183 Qh->Interval = Ep->PollRate;
188 QhHw->HorizonLink = QH_LINK (
NULL, 0,
TRUE);
189 QhHw->DeviceAddr = Ep->DevAddr;
191 QhHw->EpNum = Ep->EpAddr;
192 QhHw->EpSpeed = Ep->DevSpeed;
194 QhHw->ReclaimHead = 0;
195 QhHw->MaxPacketLen = (UINT32)Ep->MaxPacket;
197 QhHw->NakReload = QH_NAK_RELOAD;
198 QhHw->HubAddr = Ep->HubAddr;
199 QhHw->PortNum = Ep->HubPort;
200 QhHw->Multiplier = 1;
201 QhHw->DataToggle = Ep->Toggle;
203 if (Ep->DevSpeed != EFI_USB_SPEED_HIGH) {
204 QhHw->Status |= QTD_STAT_DO_SS;
208 case EHC_CTRL_TRANSFER:
216 if (Ep->DevSpeed != EFI_USB_SPEED_HIGH) {
222 case EHC_INT_TRANSFER_ASYNC:
223 case EHC_INT_TRANSFER_SYNC:
232 case EHC_BULK_TRANSFER:
233 if ((Ep->DevSpeed == EFI_USB_SPEED_HIGH) && (Ep->Direction == EfiUsbDataOut)) {
234 QhHw->Status |= QTD_STAT_DO_PING;
272 while (Interval != 0) {
277 return (
UINTN)1 << (BitCount - 1);
298 Qtd = EFI_LIST_CONTAINER (Entry,
EHC_QTD, QtdList);
322 if (Urb->RequestPhy !=
NULL) {
323 PciIo->Unmap (PciIo, Urb->RequestMap);
326 if (Urb->DataMap !=
NULL) {
327 PciIo->Unmap (PciIo, Urb->DataMap);
330 if (Urb->Qh !=
NULL) {
370 ASSERT ((Urb !=
NULL) && (Urb->Qh !=
NULL));
385 if (Ep->Direction == EfiUsbDataIn) {
386 AlterNext = QTD_LINK (PhyAddr,
FALSE);
392 if (Urb->Ep.Type == EHC_CTRL_TRANSFER) {
394 Qtd =
EhcCreateQtd (Ehc, (UINT8 *)Urb->Request, (UINT8 *)Urb->RequestPhy, Len, QTD_PID_SETUP, 0, Ep->MaxPacket);
397 return EFI_OUT_OF_RESOURCES;
408 if (Ep->Direction == EfiUsbDataIn) {
409 Pid = QTD_PID_OUTPUT;
416 if (StatusQtd ==
NULL) {
420 if (Ep->Direction == EfiUsbDataIn) {
422 AlterNext = QTD_LINK (PhyAddr,
FALSE);
431 if (Ep->Direction == EfiUsbDataIn) {
434 Pid = QTD_PID_OUTPUT;
440 while (Len < Urb->DataLen) {
443 (UINT8 *)Urb->Data + Len,
444 (UINT8 *)Urb->DataPhy + Len,
455 Qtd->QtdHw.AltNext = AlterNext;
461 if (((Qtd->DataLen + Ep->MaxPacket - 1) / Ep->MaxPacket) % 2) {
462 Toggle = (UINT8)(1 - Toggle);
471 if (Ep->Type == EHC_CTRL_TRANSFER) {
479 Qtd = EFI_LIST_CONTAINER (Entry,
EHC_QTD, QtdList);
484 if (Entry->ForwardLink == &Qh->Qtds) {
488 NextQtd = EFI_LIST_CONTAINER (Entry->ForwardLink,
EHC_QTD, QtdList);
490 Qtd->QtdHw.NextQtd = QTD_LINK (PhyAddr,
FALSE);
496 NextQtd = EFI_LIST_CONTAINER (Qh->Qtds.ForwardLink,
EHC_QTD, QtdList);
498 Qh->QhHw.NextQtd = QTD_LINK (PhyAddr,
FALSE);
503 return EFI_OUT_OF_RESOURCES;
560 Urb->Signature = EHC_URB_SIG;
564 Ep->DevAddr = DevAddr;
565 Ep->EpAddr = (UINT8)(EpAddr & 0x0F);
566 Ep->Direction = (((EpAddr & 0x80) != 0) ? EfiUsbDataIn : EfiUsbDataOut);
567 Ep->DevSpeed = DevSpeed;
568 Ep->MaxPacket = MaxPacket;
573 if (DevSpeed != EFI_USB_SPEED_HIGH) {
574 ASSERT (Hub !=
NULL);
576 Ep->HubAddr = Hub->TranslatorHubAddress;
577 Ep->HubPort = Hub->TranslatorPortNumber;
584 Urb->Request = Request;
586 Urb->DataLen = DataLen;
587 Urb->Callback = Callback;
588 Urb->Context = Context;
593 if (Urb->Qh ==
NULL) {
600 if (Request !=
NULL) {
603 Status = PciIo->Map (PciIo, MapOp, Request, &Len, &PhyAddr, &Map);
609 Urb->RequestPhy = (VOID *)((
UINTN)PhyAddr);
610 Urb->RequestMap = Map;
616 if (Ep->Direction == EfiUsbDataIn) {
622 Status = PciIo->Map (PciIo, MapOp, Data, &Len, &PhyAddr, &Map);
624 if (EFI_ERROR (Status) || (Len != DataLen)) {
628 Urb->DataPhy = (VOID *)((
UINTN)PhyAddr);
634 if (EFI_ERROR (Status)) {
#define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)
#define BASE_LIST_FOR_EACH(Entry, ListHead)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID EhcFreeQtds(IN USB2_HC_DEV *Ehc, IN LIST_ENTRY *Qtds)
VOID EhcInitIntQh(IN USB_ENDPOINT *Ep, IN QH_HW *QhHw)
EFI_STATUS EhcCreateQtds(IN USB2_HC_DEV *Ehc, IN URB *Urb)
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)
UINTN EhcConvertPollRate(IN UINTN Interval)
URB * EhcCreateUrb(IN USB2_HC_DEV *Ehc, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINT8 Toggle, IN UINTN MaxPacket, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub, IN UINTN Type, IN EFI_USB_DEVICE_REQUEST *Request, IN VOID *Data, IN UINTN DataLen, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, IN VOID *Context, IN UINTN Interval)
VOID EhcFreeUrb(IN USB2_HC_DEV *Ehc, IN URB *Urb)
EFI_PHYSICAL_ADDRESS UsbHcGetPciAddressForHostMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
VOID UsbHcFreeMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
VOID * UsbHcAllocateMem(IN USBHC_MEM_POOL *Pool, IN UINTN Size)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
EFI_PCI_IO_PROTOCOL_OPERATION
@ EfiPciIoOperationBusMasterWrite
@ EfiPciIoOperationBusMasterRead
EFI_STATUS(EFIAPI * EFI_ASYNC_USB_TRANSFER_CALLBACK)(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
UINT64 EFI_PHYSICAL_ADDRESS