28 OUT UINT8 **MappedAddr,
37 Status = Uhc->PciIo->Map (
46 if (!EFI_ERROR (Status)) {
47 *MappedAddr = (UINT8 *)(
UINTN)PhyAddr;
75 OUT UINT8 **MappedAddr,
89 *PktId = INPUT_PACKET_ID;
90 Status = Uhc->PciIo->Map (
99 if (EFI_ERROR (Status)) {
103 *MappedAddr = (UINT8 *)(
UINTN)PhyAddr;
107 *PktId = OUTPUT_PACKET_ID;
108 Status = Uhc->PciIo->Map (
117 if (EFI_ERROR (Status)) {
121 *MappedAddr = (UINT8 *)(
UINTN)PhyAddr;
125 if ((Len !=
NULL) && (*Len != 0)) {
126 Status = EFI_INVALID_PARAMETER;
130 *PktId = OUTPUT_PACKET_ID;
136 Status = EFI_INVALID_PARAMETER;
162 ASSERT ((Qh !=
NULL) && (Td !=
NULL));
164 Qh->QhHw.VerticalLink = QH_VLINK (PhyAddr,
FALSE);
165 Qh->TDs = (VOID *)Td;
181 ASSERT ((Qh !=
NULL) && (Td !=
NULL));
183 Qh->QhHw.VerticalLink = QH_VLINK (
NULL,
TRUE);
206 ASSERT ((PrevTd !=
NULL) && (ThisTd !=
NULL));
208 PrevTd->TdHw.NextLink = TD_LINK (PhyAddr,
TRUE,
FALSE);
209 PrevTd->NextTd = (VOID *)ThisTd;
232 while (NextTd !=
NULL) {
234 NextTd = ThisTd->NextTd;
262 Qh->QhHw.HorizonLink = QH_HLINK (
NULL,
TRUE);
263 Qh->QhHw.VerticalLink = QH_VLINK (
NULL,
TRUE);
316 IN UINT8 *RequestPhy,
329 Td->TdHw.ShortPacket =
FALSE;
330 Td->TdHw.IsIsoch =
FALSE;
331 Td->TdHw.IntOnCpl =
FALSE;
332 Td->TdHw.ErrorCount = 0x03;
333 Td->TdHw.Status |= USBTD_ACTIVE;
334 Td->TdHw.DataToggle = 0;
335 Td->TdHw.EndPoint = 0;
336 Td->TdHw.LowSpeed = IsLow ? 1 : 0;
337 Td->TdHw.DeviceAddr = DevAddr & 0x7F;
339 Td->TdHw.PidCode = SETUP_PACKET_ID;
340 Td->TdHw.DataBuffer = (UINT32)(
UINTN)RequestPhy;
370 IN UINT8 *DataPhyPtr,
382 ASSERT (Len <= 0x500);
391 Td->TdHw.ShortPacket =
FALSE;
392 Td->TdHw.IsIsoch =
FALSE;
393 Td->TdHw.IntOnCpl =
FALSE;
394 Td->TdHw.ErrorCount = 0x03;
395 Td->TdHw.Status = USBTD_ACTIVE;
396 Td->TdHw.LowSpeed = IsLow ? 1 : 0;
397 Td->TdHw.DataToggle = Toggle & 0x01;
398 Td->TdHw.EndPoint = Endpoint & 0x0F;
399 Td->TdHw.DeviceAddr = DevAddr & 0x7F;
400 Td->TdHw.MaxPacketLen = (UINT32)(Len - 1);
401 Td->TdHw.PidCode = (UINT8)PktId;
402 Td->TdHw.DataBuffer = (UINT32)(
UINTN)DataPhyPtr;
405 Td->DataLen = (UINT16)Len;
438 Td->TdHw.ShortPacket =
FALSE;
439 Td->TdHw.IsIsoch =
FALSE;
440 Td->TdHw.IntOnCpl =
FALSE;
441 Td->TdHw.ErrorCount = 0x03;
442 Td->TdHw.Status |= USBTD_ACTIVE;
443 Td->TdHw.MaxPacketLen = 0x7FF;
444 Td->TdHw.DataToggle = 1;
445 Td->TdHw.EndPoint = 0;
446 Td->TdHw.LowSpeed = IsLow ? 1 : 0;
447 Td->TdHw.DeviceAddr = DevAddr & 0x7F;
448 Td->TdHw.PidCode = (UINT8)PktId;
449 Td->TdHw.DataBuffer = (UINT32)(
UINTN)
NULL;
480 IN UINT8 *RequestPhy,
508 if (SetupTd ==
NULL) {
517 while (DataLen > 0) {
521 ThisTdLen = (DataLen > MaxPacket ? MaxPacket : DataLen);
535 if (DataTd ==
NULL) {
539 if (FirstDataTd ==
NULL) {
540 FirstDataTd = DataTd;
541 FirstDataTd->NextTd =
NULL;
549 DataPhy += ThisTdLen;
550 DataLen -= ThisTdLen;
556 if (OUTPUT_PACKET_ID == DataPktId) {
557 StatusPktId = INPUT_PACKET_ID;
559 StatusPktId = OUTPUT_PACKET_ID;
564 if (StatusTd ==
NULL) {
571 if (FirstDataTd !=
NULL) {
581 if (SetupTd !=
NULL) {
585 if (FirstDataTd !=
NULL) {
618 IN OUT UINT8 *DataToggle,
635 while (DataLen > 0) {
641 if (DataLen > MaxPacket) {
642 ThisTdLen = MaxPacket;
657 if (DataTd ==
NULL) {
661 if (PktId == INPUT_PACKET_ID) {
662 DataTd->TdHw.ShortPacket =
TRUE;
665 if (FirstDataTd ==
NULL) {
666 FirstDataTd = DataTd;
667 FirstDataTd->NextTd =
NULL;
675 DataPhy += ThisTdLen;
676 DataLen -= ThisTdLen;
682 if (FirstDataTd !=
NULL) {
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)
@ EfiPciIoOperationBusMasterWrite
@ EfiPciIoOperationBusMasterRead
UINT64 EFI_PHYSICAL_ADDRESS
VOID UhciDestoryTds(IN USB_HC_DEV *Uhc, IN UHCI_TD_SW *FirstTd)
EFI_STATUS UhciMapUserRequest(IN USB_HC_DEV *Uhc, IN OUT VOID *Request, OUT UINT8 **MappedAddr, OUT VOID **Map)
VOID UhciLinkTdToQh(IN USB_HC_DEV *Uhc, IN UHCI_QH_SW *Qh, IN UHCI_TD_SW *Td)
UHCI_QH_SW * UhciCreateQh(IN USB_HC_DEV *Uhc, IN UINTN Interval)
VOID UhciAppendTd(IN USB_HC_DEV *Uhc, IN UHCI_TD_SW *PrevTd, IN UHCI_TD_SW *ThisTd)
UHCI_TD_SW * UhciCreateDataTd(IN USB_HC_DEV *Uhc, IN UINT8 DevAddr, IN UINT8 Endpoint, IN UINT8 *DataPtr, IN UINT8 *DataPhyPtr, IN UINTN Len, IN UINT8 PktId, IN UINT8 Toggle, IN BOOLEAN IsLow)
UHCI_TD_SW * UhciCreateSetupTd(IN USB_HC_DEV *Uhc, IN UINT8 DevAddr, IN UINT8 *Request, IN UINT8 *RequestPhy, IN BOOLEAN IsLow)
EFI_STATUS UhciMapUserData(IN USB_HC_DEV *Uhc, IN EFI_USB_DATA_DIRECTION Direction, IN VOID *Data, IN OUT UINTN *Len, OUT UINT8 *PktId, OUT UINT8 **MappedAddr, OUT VOID **Map)
UHCI_TD_SW * UhciCreateStatusTd(IN USB_HC_DEV *Uhc, IN UINT8 DevAddr, IN UINT8 PktId, IN BOOLEAN IsLow)
UHCI_TD_SW * UhciCreateBulkOrIntTds(IN USB_HC_DEV *Uhc, IN UINT8 DevAddr, IN UINT8 EndPoint, IN UINT8 PktId, IN UINT8 *Data, IN UINT8 *DataPhy, IN UINTN DataLen, IN OUT UINT8 *DataToggle, IN UINT8 MaxPacket, IN BOOLEAN IsLow)
UHCI_TD_SW * UhciCreateCtrlTds(IN USB_HC_DEV *Uhc, IN UINT8 DeviceAddr, IN UINT8 DataPktId, IN UINT8 *Request, IN UINT8 *RequestPhy, IN UINT8 *Data, IN UINT8 *DataPhy, IN UINTN DataLen, IN UINT8 MaxPacket, IN BOOLEAN IsLow)
UHCI_TD_SW * UhciCreateTd(IN USB_HC_DEV *Uhc)
VOID UhciUnlinkTdFromQh(IN UHCI_QH_SW *Qh, IN UHCI_TD_SW *Td)
UINTN UhciConvertPollRate(IN UINTN Interval)