52 Qtd->Signature = EHC_QTD_SIG;
59 QtdHw->NextQtd = QTD_LINK (
NULL,
TRUE);
60 QtdHw->AltNext = QTD_LINK (
NULL,
TRUE);
61 QtdHw->Status = QTD_STAT_ACTIVE;
63 QtdHw->ErrCnt = QTD_MAX_ERR;
65 QtdHw->TotalBytes = 0;
66 QtdHw->DataToggle = Toggle;
74 for (Index = 0; Index <= QTD_MAX_BUFFER; Index++) {
80 QtdHw->Page[Index] = EHC_LOW_32BIT (Data);
81 QtdHw->PageHigh[Index] = EHC_HIGH_32BIT (Data);
83 ThisBufLen = QTD_BUF_LEN - (EHC_LOW_32BIT (Data) & QTD_BUF_MASK);
85 if (Len + ThisBufLen >= DataLen) {
101 Len = Len - Len % MaxPacket;
104 QtdHw->TotalBytes = (UINT32)Len;
135 if (Ep->DevSpeed == EFI_USB_SPEED_HIGH) {
136 QhHw->SMask = QH_MICROFRAME_0;
151 QhHw->SMask = QH_MICROFRAME_1;
152 QhHw->CMask = QH_MICROFRAME_3 | QH_MICROFRAME_4 | QH_MICROFRAME_5;
179 Qh->Signature = EHC_QH_SIG;
181 Qh->Interval = Ep->PollRate;
186 QhHw->HorizonLink = QH_LINK (
NULL, 0,
TRUE);
187 QhHw->DeviceAddr = Ep->DevAddr;
189 QhHw->EpNum = Ep->EpAddr;
190 QhHw->EpSpeed = Ep->DevSpeed;
192 QhHw->ReclaimHead = 0;
193 QhHw->MaxPacketLen = (UINT32)Ep->MaxPacket;
195 QhHw->NakReload = QH_NAK_RELOAD;
196 QhHw->HubAddr = Ep->HubAddr;
197 QhHw->PortNum = Ep->HubPort;
198 QhHw->Multiplier = 1;
199 QhHw->DataToggle = Ep->Toggle;
201 if (Ep->DevSpeed != EFI_USB_SPEED_HIGH) {
202 QhHw->Status |= QTD_STAT_DO_SS;
206 case EHC_CTRL_TRANSFER:
214 if (Ep->DevSpeed != EFI_USB_SPEED_HIGH) {
220 case EHC_INT_TRANSFER_ASYNC:
221 case EHC_INT_TRANSFER_SYNC:
230 case EHC_BULK_TRANSFER:
231 if ((Ep->DevSpeed == EFI_USB_SPEED_HIGH) && (Ep->Direction == EfiUsbDataOut)) {
232 QhHw->Status |= QTD_STAT_DO_PING;
270 while (Interval != 0) {
275 return (
UINTN)1 << (BitCount - 1);
296 Qtd = EFI_LIST_CONTAINER (Entry,
PEI_EHC_QTD, QtdList);
316 if (Urb->RequestPhy !=
NULL) {
320 if (Urb->DataMap !=
NULL) {
324 if (Urb->Qh !=
NULL) {
361 ASSERT ((Urb !=
NULL) && (Urb->Qh !=
NULL));
375 if (Ep->Direction == EfiUsbDataIn) {
376 AlterNext = QTD_LINK (Ehc->ShortReadStop,
FALSE);
382 if (Urb->Ep.Type == EHC_CTRL_TRANSFER) {
384 Qtd =
EhcCreateQtd (Ehc, Urb->RequestPhy, Len, QTD_PID_SETUP, 0, Ep->MaxPacket);
387 return EFI_OUT_OF_RESOURCES;
398 if (Ep->Direction == EfiUsbDataIn) {
399 Pid = QTD_PID_OUTPUT;
406 if (StatusQtd ==
NULL) {
410 if (Ep->Direction == EfiUsbDataIn) {
411 AlterNext = QTD_LINK (StatusQtd,
FALSE);
420 if (Ep->Direction == EfiUsbDataIn) {
423 Pid = QTD_PID_OUTPUT;
429 while (Len < Urb->DataLen) {
432 (UINT8 *)Urb->DataPhy + Len,
443 Qtd->QtdHw.AltNext = AlterNext;
449 if (((Qtd->DataLen + Ep->MaxPacket - 1) / Ep->MaxPacket) % 2) {
450 Toggle = (UINT8)(1 - Toggle);
459 if (Ep->Type == EHC_CTRL_TRANSFER) {
467 Qtd = EFI_LIST_CONTAINER (Entry,
PEI_EHC_QTD, QtdList);
472 if (Entry->ForwardLink == &Qh->Qtds) {
476 NextQtd = EFI_LIST_CONTAINER (Entry->ForwardLink,
PEI_EHC_QTD, QtdList);
477 Qtd->QtdHw.NextQtd = QTD_LINK (NextQtd,
FALSE);
483 NextQtd = EFI_LIST_CONTAINER (Qh->Qtds.ForwardLink,
PEI_EHC_QTD, QtdList);
484 Qh->QhHw.NextQtd = QTD_LINK (NextQtd,
FALSE);
489 return EFI_OUT_OF_RESOURCES;
542 Urb->Signature = EHC_URB_SIG;
546 Ep->DevAddr = DevAddr;
547 Ep->EpAddr = (UINT8)(EpAddr & 0x0F);
548 Ep->Direction = (((EpAddr & 0x80) != 0) ? EfiUsbDataIn : EfiUsbDataOut);
549 Ep->DevSpeed = DevSpeed;
550 Ep->MaxPacket = MaxPacket;
555 if (DevSpeed != EFI_USB_SPEED_HIGH) {
556 ASSERT (Hub !=
NULL);
558 Ep->HubAddr = Hub->TranslatorHubAddress;
559 Ep->HubPort = Hub->TranslatorPortNumber;
566 Urb->Request = Request;
568 Urb->DataLen = DataLen;
569 Urb->Callback = Callback;
570 Urb->Context = Context;
573 if (Urb->Qh ==
NULL) {
577 Urb->RequestPhy =
NULL;
578 Urb->RequestMap =
NULL;
585 if (Request !=
NULL) {
588 Status =
IoMmuMap (Ehc->IoMmu, MapOp, Request, &Len, &PhyAddr, &Map);
594 Urb->RequestPhy = (VOID *)((
UINTN)PhyAddr);
595 Urb->RequestMap = Map;
601 if (Ep->Direction == EfiUsbDataIn) {
607 Status =
IoMmuMap (Ehc->IoMmu, MapOp, Data, &Len, &PhyAddr, &Map);
609 if (EFI_ERROR (Status) || (Len != DataLen)) {
613 Urb->DataPhy = (VOID *)((
UINTN)PhyAddr);
619 if (EFI_ERROR (Status)) {
EFI_STATUS IoMmuUnmap(IN VOID *Mapping)
EFI_STATUS IoMmuMap(IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
#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)
VOID UsbHcFreeMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
VOID * UsbHcAllocateMem(IN USBHC_MEM_POOL *Pool, IN UINTN Size)
EFI_STATUS(EFIAPI * EFI_ASYNC_USB_TRANSFER_CALLBACK)(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
@ EdkiiIoMmuOperationBusMasterWrite
@ EdkiiIoMmuOperationBusMasterRead
UINT64 EFI_PHYSICAL_ADDRESS