@@ -2620,6 +2620,7 @@ EHCI_SubmitIsoTransfer(IN PVOID ehciExtension,
26202620 EhciTransfer -> TransferParameters = TransferParameters ;
26212621 EhciTransfer -> USBDStatus = USBD_STATUS_SUCCESS ;
26222622 EhciTransfer -> EhciEndpoint = EhciEndpoint ;
2623+ InitializeListHead (& EhciTransfer -> ActiveITDs );
26232624
26242625 DeviceSpeed = EhciEndpoint -> EndpointProperties .DeviceSpeed ;
26252626
@@ -2662,6 +2663,7 @@ EHCI_SubmitIsoTransfer(IN PVOID ehciExtension,
26622663 return MP_STATUS_NO_RESOURCES ;
26632664 }
26642665 DPRINT ("OriginalFrame %u New FrameNumber %u\n" , IsoTransfer -> Packets [0 ].FrameNumber , CurrentFrame );
2666+ EHCI_DisablePeriodicList (EhciExtension );
26652667
26662668 /* Allocate and program iTDs, one per frame */
26672669 while (PacketIndex < IsoTransfer -> TotalPackets )
@@ -2681,6 +2683,7 @@ EHCI_SubmitIsoTransfer(IN PVOID ehciExtension,
26812683 /* TODO: free previously allocated iTDs */
26822684 return MP_STATUS_NO_RESOURCES ;
26832685 }
2686+
26842687 DPRINT ("ITD %p CurrentFrame %x\n" , ITD , CurrentFrame );
26852688 EndpointProperties = & EhciEndpoint -> EndpointProperties ;
26862689 DeviceAddress = EndpointProperties -> DeviceAddress ;
@@ -2707,7 +2710,10 @@ EHCI_SubmitIsoTransfer(IN PVOID ehciExtension,
27072710 ITD -> HwTD .Buffer [1 ].Direction = Direction ;
27082711
27092712 /* Setup buffer page 2 with multi (transactions per microframe) */
2710- ITD -> HwTD .Buffer [2 ].Multi = EndpointProperties -> TransactionPerMicroframe ;
2713+ ITD -> HwTD .Buffer [2 ].Multi = IsoTransfer -> Packets [PacketIndex ].PacketLength / EndpointProperties -> MaxPacketSize ;
2714+ ASSERT (IsoTransfer -> Packets [PacketIndex ].PacketLength % EndpointProperties -> MaxPacketSize == 0 );
2715+ ASSERT (ITD -> HwTD .Buffer [2 ].Multi > 0 );
2716+ ASSERT (ITD -> HwTD .Buffer [2 ].Multi <= 3 );
27112717
27122718 /* Program each packet into a transaction slot */
27132719 for (p = 0 ; p < PacketsThisITD ; p ++ )
@@ -2824,9 +2830,9 @@ EHCI_SubmitIsoTransfer(IN PVOID ehciExtension,
28242830 PacketIndex += PacketsThisITD ;
28252831 CurrentFrame ++ ;
28262832 ITDCount ++ ;
2833+ InsertTailList (& EhciTransfer -> ActiveITDs , & ITD -> ActiveITDEntry );
2834+ //DPRINT1("Submitted ITD %p at Frame %u\n", ITD, ITD->ScheduledFrame);
28272835 }
2828- ASSERT (EhciTransfer -> ActiveITD == NULL );
2829- EhciTransfer -> ActiveITD = FirstITD ;
28302836 EhciEndpoint -> FrameCount += ITDCount ;
28312837 EhciTransfer -> PendingTDs += ITDCount ;
28322838 EhciExtension -> PendingTransfers ++ ;
@@ -2866,10 +2872,11 @@ EHCI_AbortIsoTransfer(IN PEHCI_EXTENSION EhciExtension,
28662872 DPRINT ("EHCI_AbortIsoTransfer: Aborting high-speed ISO transfer\n" );
28672873
28682874 /* Find iTDs belonging to this transfer and abort them */
2869- while (EhciTransfer -> ActiveITD )
2875+ while (! IsListEmpty ( & EhciTransfer -> ActiveITDs ) )
28702876 {
28712877 /* grab first */
2872- ITD = EhciTransfer -> ActiveITD ;
2878+ PLIST_ENTRY Entry = RemoveHeadList (& EhciTransfer -> ActiveITDs );
2879+ ITD = CONTAINING_RECORD (Entry , EHCI_HCD_ITD , ActiveITDEntry );
28732880 /* Found an iTD for this transfer */
28742881 DPRINT ("EHCI_AbortIsoTransfer: Aborting iTD %p\n" , ITD );
28752882
@@ -3909,8 +3916,9 @@ EHCI_PollIsoEndpoint(IN PEHCI_EXTENSION EhciExtension,
39093916 if (ITD -> PacketLength [TransIdx ] > 0 )
39103917 {
39113918 HasProgrammedTransactions = TRUE;
3912- if (ITD -> HwTD .Transaction [TransIdx ].Status &
3913- (EHCI_TOKEN_STATUS_ACTIVE >> 4 ))
3919+
3920+ ULONG Status = ITD -> HwTD .Transaction [TransIdx ].Status ;
3921+ if (Status & (1 << 3 ))
39143922 {
39153923 StillActive = TRUE;
39163924 break ;
@@ -3940,6 +3948,7 @@ EHCI_PollEndpoint(IN PVOID ehciExtension,
39403948{
39413949 PEHCI_EXTENSION EhciExtension = ehciExtension ;
39423950 PEHCI_ENDPOINT EhciEndpoint = ehciEndpoint ;
3951+
39433952 ULONG TransferType ;
39443953
39453954 //DPRINT_EHCI("EHCI_PollEndpoint: EhciEndpoint - %p\n", EhciEndpoint);
@@ -4427,6 +4436,10 @@ EHCI_ProcessCompletedITD(IN PEHCI_EXTENSION EhciExtension,
44274436 ITD -> TdFlags &= ~EHCI_HCD_ITD_FLAG_ALLOCATED ;
44284437 ITD -> NextHcdTD = NULL ;
44294438 ITD -> EhciTransfer = NULL ;
4439+ ITD -> EhciEndpoint = NULL ;
4440+ for (ULONG Index = 0 ; Index < EHCI_MAX_ITD_TRANSACTIONS ; Index ++ )
4441+ ITD -> PacketLength [Index ] = 0 ;
4442+
44304443 EhciEndpoint -> RemainITDs ++ ;
44314444
44324445 /* Update per-iTD count */
@@ -4436,10 +4449,10 @@ EHCI_ProcessCompletedITD(IN PEHCI_EXTENSION EhciExtension,
44364449 ITD , TotalBytesTransferred , EhciTransfer -> PendingTDs );
44374450
44384451 /* Complete the transfer only when ALL iTDs are done */
4439- if (EhciTransfer -> ActiveITD == NULL )
4452+ if (IsListEmpty ( & EhciTransfer -> ActiveITDs ) )
44404453 {
4454+ ASSERT (EhciTransfer -> PendingTDs == 0 );
44414455 EhciExtension -> PendingTransfers -- ;
4442- ASSERT (EhciTransfer -> ActiveITD == NULL );
44434456 DPRINT ("EHCI_ProcessCompletedITD: Transfer fully completed, %d total bytes\n" ,
44444457 EhciTransfer -> TransferLen );
44454458
@@ -4462,7 +4475,7 @@ EHCI_UnlinkITDFromFrameList(IN PEHCI_EXTENSION EhciExtension,
44624475 ULONG FrameIndex ;
44634476 ULONG TargetPhysicalAddress ;
44644477 EHCI_LINK_POINTER CurrentLink ;
4465- PEHCI_HCD_ITD PrevITD , CurrentITD ;
4478+
44664479
44674480 HcResourcesVA = EhciExtension -> HcResourcesVA ;
44684481 FrameIndex = Frame % EHCI_FRAME_LIST_MAX_ENTRIES ;
@@ -4481,29 +4494,7 @@ EHCI_UnlinkITDFromFrameList(IN PEHCI_EXTENSION EhciExtension,
44814494 HcResourcesVA -> PeriodicFrameList [FrameIndex ] = ITD -> HwTD .NextLink .AsULONG ;
44824495 DPRINT_EHCI ("EHCI_UnlinkITDFromFrameList: Unlinked iTD from frame %d head\n" , FrameIndex );
44834496 }
4484- PrevITD = NULL ;
4485- CurrentITD = EhciTransfer -> ActiveITD ;
4486- do
4487- {
4488- ASSERT (CurrentITD -> EhciTransfer == EhciTransfer );
4489- if (CurrentITD == ITD )
4490- {
4491- /* unlink */
4492- if (PrevITD )
4493- {
4494- PrevITD -> NextHcdTD = CurrentITD -> NextHcdTD ;
4495- }
4496- else
4497- {
4498- EhciTransfer -> ActiveITD = CurrentITD -> NextHcdTD ;
4499- }
4500- break ;
4501- }
4502- PrevITD = CurrentITD ;
4503- CurrentITD = CurrentITD -> NextHcdTD ;
4504- } while (CurrentITD != NULL );
4505-
4506- ASSERT (CurrentITD == ITD );
4497+ RemoveEntryList (& ITD -> ActiveITDEntry );
45074498 RtlClearBits (& EhciExtension -> IsoBitmap , ITD -> ScheduledFrame , 1 );
45084499 ITD -> NextHcdTD = NULL ;
45094500 ITD -> EhciTransfer = NULL ;
0 commit comments