14 0x1C, 0x38, 0x70, 0xE0, 0xC1, 0x83, 0x07, 0x0E
26 BusTime = *OutTimeUsed + CalcBusTime;
27 *OutTimeUsed += CalcBusTime;
29 if (BusTime > LimitAllocation)
31 DPRINT(
"USB2_AllocateCheck: BusTime > LimitAllocation\n");
42 return (DataTime + (DataTime / 16));
79 DPRINT(
"USB2_CheckTtEndpointInsert: nextTtEndpoint - %p, TtEndpoint - %p\n",
87 DPRINT1(
"USB2_CheckTtEndpointInsert: Result - FALSE\n");
93 DPRINT(
"USB2_CheckTtEndpointInsert: Result - TRUE\n");
97 TransferType = TtEndpoint->TtEndpointParams.TransferType;
99 if (nextTtEndpoint->ActualPeriod < TtEndpoint->ActualPeriod &&
102 DPRINT(
"USB2_CheckTtEndpointInsert: Result - TRUE\n");
106 if ((nextTtEndpoint->ActualPeriod <= TtEndpoint->ActualPeriod &&
108 nextTtEndpoint == TtEndpoint)
110 DPRINT(
"USB2_CheckTtEndpointInsert: Result - TRUE\n");
114 DPRINT(
"USB2_CheckTtEndpointInsert: Result - FALSE\n");
128 TransferType = TtEndpoint->TtEndpointParams.TransferType;
129 Direction = TtEndpoint->TtEndpointParams.Direction;
130 DeviceSpeed = TtEndpoint->TtEndpointParams.DeviceSpeed;
132 HostDelay = TtEndpoint->Tt->HcExtension->HcDelayTime;
176 TransferType = TtEndpoint->TtEndpointParams.TransferType;
177 Direction = TtEndpoint->TtEndpointParams.Direction;
179 HostDelay = TtEndpoint->Tt->HcExtension->HcDelayTime;
223 if (nextTtEndpoint ||
246 DPRINT(
"USB2_GetStartTime: nextTtEndpoint - %p, TtEndpoint - %p, prevTtEndpoint - %p, Frame - %X\n",
252 TransferType = TtEndpoint->TtEndpointParams.TransferType;
257 return nextTtEndpoint->StartTime + nextTtEndpoint->CalcBusTime;
268 ttEndpoint = prevTtEndpoint;
287 TtEndpoint->TtEndpointParams.TransferType = TransferType;
288 TtEndpoint->TtEndpointParams.Direction =
Direction;
289 TtEndpoint->TtEndpointParams.DeviceSpeed =
DeviceSpeed;
291 TtEndpoint->Period =
Period;
292 TtEndpoint->MaxPacketSize = MaxPacketSize;
295 TtEndpoint->CalcBusTime = 0;
296 TtEndpoint->StartTime = 0;
297 TtEndpoint->ActualPeriod = 0;
298 TtEndpoint->StartFrame = 0;
299 TtEndpoint->StartMicroframe = 0;
301 TtEndpoint->Nums.AsULONG = 0;
302 TtEndpoint->NextTtEndpoint =
NULL;
303 TtEndpoint->Reserved2 = 0;
304 TtEndpoint->PreviosPeriod = 0;
305 TtEndpoint->IsPromoted =
FALSE;
319 ULONG RemainDataTime;
329 DPRINT(
"USB2_AllocateHS: TtEndpoint - %p, Frame - %X, StartFrame - %X\n",
332 TtEndpoint->StartFrame);
337 TransferType = TtEndpoint->TtEndpointParams.TransferType;
338 Direction = TtEndpoint->TtEndpointParams.Direction;
342 TtEndpoint->StartMicroframe =
345 DPRINT(
"USB2_AllocateHS: TtEndpoint->StartMicroframe - %X\n",
346 TtEndpoint->StartMicroframe);
355 TtEndpoint->Nums.NumStarts = 1;
358 TtEndpoint->Nums.NumCompletes = 3;
360 TtEndpoint->Nums.NumCompletes = 2;
367 DPRINT(
"USB2_AllocateHS: ISO UNIMPLEMENTED\n");
372 DPRINT(
"USB2_AllocateHS: ISO UNIMPLEMENTED\n");
377 frame = TtEndpoint->StartFrame + Frame;
378 uframe = TtEndpoint->StartMicroframe;
383 for (ix = 0; ix < TtEndpoint->Nums.NumStarts; ix++)
395 DPRINT1(
"USB2_AllocateHS: Num Start Splits - %X\n",
406 frame = TtEndpoint->StartFrame + Frame;
407 uframe = TtEndpoint->StartMicroframe + TtEndpoint->Nums.NumStarts + 1;
409 for (ix = 0; ix < TtEndpoint->Nums.NumCompletes; ix++)
421 PktSize = TtEndpoint->MaxPacketSize;
426 frame = TtEndpoint->StartFrame + Frame;
427 uframe = TtEndpoint->StartMicroframe;
434 for (ix = 0; ix < TtEndpoint->Nums.NumStarts; ix++)
436 DataSize = PktSizeBitStuff - DataTime;
443 DPRINT(
"USB2_AllocateHS: ix - %X, frame - %X, uframe - %X, TimeUsed - %X\n",
447 HcExtension->
TimeUsed[frame][uframe]);
462 frame = TtEndpoint->StartFrame + Frame;
463 uframe = TtEndpoint->StartMicroframe + TtEndpoint->Nums.NumStarts + 1;
465 for (ix = 0; ix < TtEndpoint->Nums.NumCompletes; ix++)
470 Tt->
TimeCS[frame][uframe];
472 if (RemainDataTime >= PktSizeBitStuff)
474 DataTime = PktSizeBitStuff;
476 else if (RemainDataTime > 0)
478 DataTime = RemainDataTime;
494 Tt->
TimeCS[frame][uframe] += PktSizeBitStuff;
517 ULONG CurrentDataTime;
518 ULONG RemainDataTime;
526 DPRINT(
"USB2_DeallocateHS: TtEndpoint - %p, Frame - %X\n",
535 frame = TtEndpoint->StartFrame + Frame;
536 uframe = TtEndpoint->StartMicroframe;
541 for (ix = 0; ix < TtEndpoint->Nums.NumStarts; ix++)
543 HcExtension->
TimeUsed[frame][uframe] -= OverheadSS;
548 frame = TtEndpoint->StartFrame + Frame;
549 uframe = TtEndpoint->StartMicroframe + TtEndpoint->Nums.NumStarts + 1;
551 for (ix = 0; ix < TtEndpoint->Nums.NumCompletes; ix++)
553 HcExtension->
TimeUsed[frame][uframe] -= OverheadCS;
557 Direction = TtEndpoint->TtEndpointParams.Direction;
558 PktSize = TtEndpoint->MaxPacketSize;
563 frame = TtEndpoint->StartFrame + Frame;
564 uframe = TtEndpoint->StartMicroframe;
571 for (ix = 0; ix < TtEndpoint->Nums.NumStarts; ix++)
573 DataSize = PktSizeBitStuff - DataTime;
576 CurrentDataTime = PktSizeBitStuff - DataTime;
580 HcExtension->
TimeUsed[frame][uframe] -= CurrentDataTime;
587 frame = TtEndpoint->StartFrame + Frame;
588 uframe = TtEndpoint->StartMicroframe + TtEndpoint->Nums.NumStarts + 1;
590 for (ix = 0; ix < TtEndpoint->Nums.NumCompletes; ix++)
595 CurrentDataTime = PktSizeBitStuff;
597 Tt->
TimeCS[frame][uframe] -= CurrentDataTime;
602 Tt->
TimeCS[frame][uframe];
604 if (RemainDataTime >= PktSizeBitStuff)
605 RemainDataTime = PktSizeBitStuff;
607 HcExtension->
TimeUsed[frame][uframe] -= RemainDataTime;
630 DPRINT(
"USB2_MoveTtEndpoint: TtEndpoint - %p, BusTime - %X\n",
636 for (Num = 0; Rebalance->RebalanceEndpoint[Num]; Num++)
638 if (Rebalance->RebalanceEndpoint[Num] == TtEndpoint)
642 DPRINT(
"USB2_MoveTtEndpoint: Num - %X\n", Num);
644 TransferType = TtEndpoint->TtEndpointParams.TransferType;
646 if (Rebalance->RebalanceEndpoint[Num] &&
647 TtEndpoint->TtEndpointParams.EndpointMoved &&
650 DPRINT(
"USB2_MoveTtEndpoint: result - FALSE\n");
656 ix += TtEndpoint->ActualPeriod)
661 TtEndpoint->StartTime += BusTime;
663 EndBusTime = TtEndpoint->StartTime + TtEndpoint->CalcBusTime;
667 DPRINT(
"USB2_MoveTtEndpoint: EndBusTime is too large!\n");
671 TtEndpoint->TtEndpointParams.EndpointMoved = 1;
673 if (Rebalance->RebalanceEndpoint[Num] ==
NULL)
675 if (Num >= RebalanceListEntries)
677 DPRINT(
"USB2_MoveTtEndpoint: Too many changes!\n");
682 Rebalance->RebalanceEndpoint[Num] = TtEndpoint;
683 Rebalance->RebalanceEndpoint[Num + 1] =
NULL;
689 ix += TtEndpoint->ActualPeriod)
693 DPRINT(
"USB2_MoveTtEndpoint: OutResult - FALSE\n");
698 DPRINT(
"USB2_MoveTtEndpoint: result - TRUE\n");
709 DPRINT(
"USB2_CommonFrames: \n");
717 if (NextTtEndpoint->ActualPeriod < TtEndpoint->ActualPeriod)
718 Frame = TtEndpoint->StartFrame % TtEndpoint->ActualPeriod;
720 Frame = NextTtEndpoint->StartFrame % TtEndpoint->ActualPeriod;
722 return (Frame == TtEndpoint->StartFrame);
732 DPRINT(
"USB2_ConvertFrame: Frame - %x, Microframe - %x\n",
745 *HcMicroframe = Microframe + 1;
750 *HcFrame = Frame + 1;
764 if (TtEndpoint->TtEndpointParams.DeviceSpeed ==
UsbHighSpeed)
766 SMask = (1 << TtEndpoint->StartMicroframe);
771 TtEndpoint->StartMicroframe,
775 for (ix = 0; ix < TtEndpoint->Nums.NumStarts; ix++)
777 SMask |= (1 << HcMicroFrame);
799 TransferType = TtEndpoint->TtEndpointParams.TransferType;
800 DeviceSpeed = TtEndpoint->TtEndpointParams.DeviceSpeed;
801 Direction = TtEndpoint->TtEndpointParams.Direction;
809 TtEndpoint->StartMicroframe,
821 TtEndpoint->StartMicroframe,
825 NumCompletes = TtEndpoint->Nums.NumCompletes;
827 for (MicroFrameCS = HcMicroFrame + 2;
831 MaskCS |= (1 << MicroFrameCS);
838 for (; NumCompletes; NumCompletes--)
858 ULONG AllocedBusTime;
859 ULONG EndpointBandwidth;
861 ULONG ScheduleOffset;
879 RebalanceLink.Flink);
881 DPRINT(
"USB2_RebalanceEndpoint: Endpoint - %p\n", Endpoint);
906 for (ix = 0; ix < Factor; ix++)
920 for (ix = 0; ix < Factor; ix++)
922 n = Factor * ScheduleOffset;
951 ULONG ScheduleOffset;
956 DPRINT(
"USB2_Rebalance: FdoDevice - %p, RebalanceList - %p\n",
965 Entry = RebalanceList->Flink;
969 RebalanceLink.Flink);
971 DPRINT(
"USBPORT_Rebalance: Entry - %p, Endpoint - %p\n",
988 switch (TransferType)
991 DPRINT(
"USBPORT_Rebalance: USBPORT_TRANSFER_TYPE_ISOCHRONOUS. FIXME\n");
999 ActualPeriod != EndpointProperties->
Period)
1001 if (ActualPeriod == EndpointProperties->
Period &&
1036 ULONG StartMicroframe;
1052 DPRINT(
"USB2_DeallocateEndpointBudget: TtEndpoint - %p, MaxFrames - %X, CalcBusTime - %X\n",
1055 TtEndpoint->CalcBusTime);
1057 if (TtEndpoint->CalcBusTime == 0)
1059 DPRINT(
"USB2_DeallocateEndpointBudget: TtEndpoint not allocated!\n");
1063 Tt = TtEndpoint->Tt;
1066 Speed = TtEndpoint->TtEndpointParams.DeviceSpeed;
1067 DPRINT(
"USB2_DeallocateEndpointBudget: DeviceSpeed - %X\n", Speed);
1070 TtEndpoint->StartMicroframe;
1074 for (ix = StartMicroframe;
1076 ix += TtEndpoint->ActualPeriod)
1081 HcExtension->
TimeUsed[frame][uframe] -= TtEndpoint->CalcBusTime;
1084 TtEndpoint->CalcBusTime = 0;
1086 DPRINT(
"USB2_DeallocateEndpointBudget: return TRUE\n");
1092 TransferType = TtEndpoint->TtEndpointParams.TransferType;
1094 for (ix = MaxFrames, Frame = (MaxFrames - 1) - TtEndpoint->StartFrame;
1098 frame = TtEndpoint->StartFrame + Frame;
1100 DPRINT(
"USB2_DeallocateEndpointBudget: frame - %X, Frame - %X, StartFrame - %X\n",
1103 TtEndpoint->StartFrame);
1105 if ((Frame % TtEndpoint->ActualPeriod) == 0)
1116 nextEndpoint =
endpoint->NextTtEndpoint;
1118 DPRINT(
"USB2_DeallocateEndpointBudget: TtEndpoint - %p, nextEndpoint - %p\n",
1124 while (nextEndpoint)
1130 nextEndpoint = TtEndpoint;
1132 DPRINT(
"USB2_DeallocateEndpointBudget: endpoint - %p, nextEndpoint - %p\n",
1138 while (nextEndpoint &&
1148 DPRINT1(
"USB2_DeallocateEndpointBudget: Iso Ep UNIMPLEMENTED. FIXME\n");
1152 DPRINT(
"USB2_DeallocateEndpointBudget: endpoint - %p, nextEndpoint - %p\n",
1157 if ((Frame % TtEndpoint->ActualPeriod) == 0)
1163 else if (nextEndpoint)
1166 endpoint->NextTtEndpoint = nextEndpoint;
1168 DPRINT(
"USB2_DeallocateEndpointBudget: endpoint - %p, nextEndpoint - %p\n",
1190 DPRINT1(
"USB2_DeallocateEndpointBudget: Iso Ep UNIMPLEMENTED. FIXME\n");
1194 Period = TtEndpoint->ActualPeriod;
1201 DPRINT(
"USB2_DeallocateEndpointBudget: endpoint - %p, nextEndpoint - %p\n",
1206 maxEndTime = endTime;
1208 if (
Period > nextEndpoint->ActualPeriod ||
1209 TtEndpoint->StartFrame != nextEndpoint->StartFrame)
1212 Factor =
Period / nextEndpoint->ActualPeriod;
1214 Factor =
USB2_FRAMES / nextEndpoint->ActualPeriod;
1216 maxEndTime = endTime;
1218 for (jx = 0, frame = nextEndpoint->StartFrame;
1220 jx++, frame += nextEndpoint->ActualPeriod)
1222 if (nextEndpoint->StartFrame != TtEndpoint->StartFrame)
1236 tmpEndpoint && tmpEndpoint != nextEndpoint;
1239 lastEndpoint = tmpEndpoint;
1244 if (endTime < (lastEndTime - 1))
1246 maxEndTime = lastEndTime;
1247 endTime = maxEndTime;
1249 if (nextEndpoint->StartTime == maxEndTime)
1254 maxEndTime = endTime;
1260 if (maxEndTime >= nextEndpoint->StartTime)
1264 maxEndTime - nextEndpoint->StartTime,
1266 *RebalanceListEntries,
1271 DPRINT(
"USB2_DeallocateEndpointBudget: Not moved!\n");
1277 if (
Period > nextEndpoint->ActualPeriod)
1278 Period = nextEndpoint->ActualPeriod;
1282 TtEndpoint->CalcBusTime = 0;
1284 DPRINT(
"USB2_DeallocateEndpointBudget: return TRUE\n");
1313 DPRINT(
"USB2_AllocateTimeForEndpoint: TtEndpoint - %p\n", TtEndpoint);
1315 Tt = TtEndpoint->Tt;
1318 TtEndpoint->Nums.NumStarts = 0;
1319 TtEndpoint->Nums.NumCompletes = 0;
1321 TtEndpoint->StartFrame = 0;
1322 TtEndpoint->StartMicroframe = 0;
1324 if (TtEndpoint->CalcBusTime)
1326 DPRINT(
"USB2_AllocateTimeForEndpoint: TtEndpoint already allocated!\n");
1330 Speed = TtEndpoint->TtEndpointParams.DeviceSpeed;
1337 TtEndpoint->ActualPeriod = TtEndpoint->Period;
1339 MinTimeUsed = HcExtension->
TimeUsed[0][0];
1341 for (ix = 1; ix < TtEndpoint->ActualPeriod; ix++)
1346 TimeUsed = HcExtension->
TimeUsed[frame][uframe];
1348 if (TimeUsed < MinTimeUsed)
1350 MinTimeUsed = TimeUsed;
1351 TtEndpoint->StartFrame = frame;
1352 TtEndpoint->StartMicroframe = uframe;
1359 DPRINT(
"USB2_AllocateTimeForEndpoint: StartFrame - %X, StartMicroframe - %X, CalcBusTime - %X\n",
1360 TtEndpoint->StartFrame,
1361 TtEndpoint->StartMicroframe,
1362 TtEndpoint->CalcBusTime);
1365 TtEndpoint->StartMicroframe;
1369 DPRINT(
"USB2_AllocateTimeForEndpoint: Microframe >= 256. Result - TRUE\n");
1373 for (ix = Microframe;
1375 ix += TtEndpoint->ActualPeriod)
1380 DPRINT(
"USB2_AllocateTimeForEndpoint: frame - %X, uframe - %X, TimeUsed[f][uf] - %X\n",
1383 HcExtension->
TimeUsed[frame][uframe]);
1386 TtEndpoint->CalcBusTime,
1389 DPRINT(
"USB2_AllocateTimeForEndpoint: Result = FALSE\n");
1396 for (ix = Microframe;
1398 ix += TtEndpoint->ActualPeriod)
1403 HcExtension->
TimeUsed[frame][uframe] -= TtEndpoint->CalcBusTime;
1407 DPRINT(
"USB2_AllocateTimeForEndpoint: Result - TRUE\n");
1416 TtEndpoint->ActualPeriod = TtEndpoint->Period;
1420 for (ix = 1; ix < TtEndpoint->ActualPeriod; ix++)
1425 TtEndpoint->StartFrame = ix;
1429 TransferType = TtEndpoint->TtEndpointParams.TransferType;
1439 DPRINT(
"USB2_AllocateTimeForEndpoint: ISO can not be on a LS bus!\n");
1452 TtEndpoint->CalcBusTime = TtEndpoint->MaxPacketSize * 8 + Overhead;
1454 TtEndpoint->CalcBusTime = TtEndpoint->MaxPacketSize + Overhead;
1460 ix += TtEndpoint->ActualPeriod)
1462 frame = TtEndpoint->StartFrame + ix;
1467 DPRINT(
"USB2_AllocateTimeForEndpoint: return FALSE\n");
1483 prevEndpoint = nextEndpoint;
1494 TtEndpoint->StartTime = LatestStart;
1498 TtEndpoint->CalcBusTime = 0;
1499 DPRINT(
"USB2_AllocateTimeForEndpoint: return FALSE\n");
1503 for (ix = 0, frame = -TtEndpoint->StartFrame;
1507 DPRINT(
"USB2_AllocateTimeForEndpoint: ix - %X, frame - %X, StartFrame - %X\n",
1510 TtEndpoint->StartFrame);
1514 DPRINT1(
"USB2_AllocateTimeForEndpoint: Iso Ep UNIMPLEMENTED. FIXME\n");
1528 IntEndpoint = nextEndpoint;
1531 if ((frame % TtEndpoint->ActualPeriod) == 0)
1539 calcBusTime = LatestStart + TtEndpoint->
CalcBusTime -
1544 calcBusTime = TtEndpoint->CalcBusTime;
1547 if (calcBusTime > 0)
1555 DPRINT(
"USB2_AllocateTimeForEndpoint: Result = FALSE\n");
1561 if (nextEndpoint != TtEndpoint)
1563 if ((frame % TtEndpoint->ActualPeriod) == 0)
1567 DPRINT(
"USB2_AllocateTimeForEndpoint: frame == 0\n");
1568 TtEndpoint->NextTtEndpoint = nextEndpoint;
1573 DPRINT(
"USB2_AllocateTimeForEndpoint: TtEndpoint - %p, nextEndpoint - %p\n",
1578 if (calcBusTime > 0)
1583 DPRINT(
"USB2_AllocateTimeForEndpoint: nextEndpoint - %p, calcBusTime - %X\n",
1594 *RebalanceListEntries,
1599 DPRINT(
"USB2_AllocateTimeForEndpoint: Result = FALSE\n");
1610 if ((frame % TtEndpoint->ActualPeriod) == 0)
1614 DPRINT1(
"USB2_AllocateTimeForEndpoint: USB2_AllocateHS return FALSE\n");
1625 RebalanceListEntries,
1628 DPRINT(
"USB2_AllocateTimeForEndpoint: return FALSE\n");
1633 DPRINT(
"USB2_AllocateTimeForEndpoint: Result - %X\n",
Result);
1645 DPRINT(
"USB2_ChangePeriod: RebalanceListEntries - %X\n",
1646 *RebalanceListEntries);
1650 RebalanceListEntries,
1653 TtEndpoint->PreviosPeriod = TtEndpoint->Period;
1658 RebalanceListEntries);
1677 (
CHAR)TtEndpoint->StartMicroframe > 2 &&
1680 DPRINT(
"USB2_PromotePeriods: return FALSE\n");
1684 if (Rebalance->RebalanceEndpoint[0] ==
NULL)
1686 DPRINT(
"USB2_PromotePeriods: return TRUE\n");
1690 DPRINT(
"USB2_PromotePeriods: RebalanceListEntries - %X\n",
1691 *RebalanceListEntries);
1693 for (ix = 0; Rebalance->RebalanceEndpoint[ix]; ix++)
1695 Rebalance->RebalanceEndpoint[ix]->IsPromoted =
FALSE;
1698 for (ix = 0; ; ix++)
1700 ttEndpoint = Rebalance->RebalanceEndpoint[ix];
1709 RebalanceListEntries,
1718 RebalanceListEntries))
1724 if (Rebalance->RebalanceEndpoint[ix + 1] ==
NULL)
1726 DPRINT(
"USB2_PromotePeriods: return TRUE\n");
1733 RebalanceListEntries,
1736 TtEndpoint->Period = TtEndpoint->PreviosPeriod;
1737 TtEndpoint->PreviosPeriod = 0;
1739 for (ix = 0; Rebalance->RebalanceEndpoint[ix]; ix++)
1741 ttEndpoint = Rebalance->RebalanceEndpoint[ix];
1749 RebalanceListEntries,
1753 TtEndpoint->Period = TtEndpoint->PreviosPeriod;
1754 TtEndpoint->PreviosPeriod = 0;
1758 RebalanceListEntries);
1762 DPRINT(
"USB2_PromotePeriods: return FALSE\n");
1771 ULONG NewBusBandwidth;
1772 ULONG MaxBusBandwidth = 0;
1773 ULONG MinBusBandwidth;
1776 DPRINT(
"USBPORT_UpdateAllocatedBwTt: TtExtension - %p\n", TtExtension);
1778 BusBandwidth = TtExtension->BusBandwidth;
1779 MinBusBandwidth = BusBandwidth;
1783 NewBusBandwidth = BusBandwidth - TtExtension->Bandwidth[ix];
1785 MaxBusBandwidth =
max(MaxBusBandwidth, NewBusBandwidth);
1786 MinBusBandwidth =
min(MinBusBandwidth, NewBusBandwidth);
1789 TtExtension->MaxBandwidth = MaxBusBandwidth;
1791 if (MinBusBandwidth == BusBandwidth)
1792 TtExtension->MinBandwidth = 0;
1794 TtExtension->MinBandwidth = MinBusBandwidth;
1808 ULONG RebalanceListEntries;
1814 ULONG AllocedBusTime;
1815 ULONG EndpointBandwidth;
1816 ULONG ScheduleOffset;
1826 DPRINT(
"USBPORT_AllocateBandwidthUSB2: FdoDevice - %p, Endpoint - %p\n",
1830 EndpointProperties = &Endpoint->EndpointProperties;
1835 DPRINT(
"USBPORT_AllocateBandwidthUSB2: ENDPOINT_FLAG_ROOTHUB_EP0\n");
1842 DPRINT(
"USBPORT_AllocateBandwidthUSB2: TransferType - %X\n", TransferType);
1850 if (Endpoint->TtExtension)
1851 TtExtension = Endpoint->TtExtension;
1861 DPRINT(
"USBPORT_AllocateBandwidthUSB2: Rebalance - %p, TtExtension - %p\n",
1869 TtEndpoint = Endpoint->TtEndpoint;
1880 Tt = &TtExtension->
Tt;
1888 DPRINT(
"USBPORT_AllocateBandwidthUSB2: Period - %X\n",
Period);
1902 DPRINT1(
"USBPORT_AllocateBandwidthUSB2: DeviceSpeed - %X!\n",
1907 Tt = &TtExtension->
Tt;
1924 &RebalanceListEntries);
1930 &RebalanceListEntries);
1933 RebalanceListEntries = 0;
1937 RebalanceListEntries = ix + 1;
1942 RebalanceListEntries = 0;
1946 DPRINT(
"USBPORT_AllocateBandwidthUSB2: RebalanceListEntries - %X, Result - %X\n",
1947 RebalanceListEntries,
1950 for (ix = 0; ix < RebalanceListEntries; ix++)
1954 DPRINT(
"USBPORT_AllocateBandwidthUSB2: RebalanceTtEndpoint[%X] - %p, RebalanceTtEndpoint - %p, RebalanceLink - %p\n",
1956 RebalanceTtEndpoint,
1979 ActualPeriod = Endpoint->TtEndpoint->ActualPeriod;
1980 EndpointProperties->
Period = ActualPeriod;
1982 ScheduleOffset = Endpoint->TtEndpoint->StartFrame;
1987 n = ScheduleOffset * Factor;
1991 for (ix = 0; ix < Factor; ix++)
1993 TtExtension->
Bandwidth[
n + ix] -= EndpointBandwidth;
1998 for (ix = 1; ix < Factor; ix++)
2009 DPRINT1(
"USBPORT_AllocateBandwidthUSB2: AllocedBusTime >= 0.5 * MAX_ALLOCATION \n");
2017 DPRINT(
"USBPORT_AllocateBandwidthUSB2: Result - %X\n",
Result);
2033 DPRINT(
"USBPORT_AllocateBandwidthUSB2: Result - %X\n",
Result);
2045 ULONG ScheduleOffset;
2046 ULONG EndpointBandwidth;
2050 ULONG RebalanceListEntries;
2057 DPRINT(
"USBPORT_FreeBandwidthUSB2: Endpoint - %p\n", Endpoint);
2061 Period = Endpoint->EndpointProperties.Period;
2062 ScheduleOffset = Endpoint->EndpointProperties.ScheduleOffset;
2063 EndpointBandwidth = Endpoint->EndpointProperties.UsbBandwidth;
2067 TransferType = Endpoint->EndpointProperties.TransferType;
2082 DPRINT1(
"USBPORT_FreeBandwidthUSB2: Rebalance == NULL!\n");
2090 n = ScheduleOffset * Factor;
2092 TtExtension = Endpoint->TtExtension;
2096 for (ix = 0; ix < Factor; ix++)
2098 TtExtension->
Bandwidth[
n + ix] += EndpointBandwidth;
2103 for (ix = 1; ix < Factor; ix++)
2113 &RebalanceListEntries,
2116 RebalanceListEntries = 0;
2120 RebalanceListEntries = ix + 1;
2123 for (ix = 0; ix < RebalanceListEntries; ix++)
2127 DPRINT(
"USBPORT_AllocateBandwidthUSB2: RebalanceTtEndpoint[%X] - %p, RebalanceTtEndpoint - %p, RebalanceLink - %p\n",
2129 RebalanceTtEndpoint,
2155 DPRINT1(
"USBPORT_FreeBandwidthUSB2: exit\n");
2166 DPRINT(
"USB2_InitTT: HcExtension - %p, Tt - %p\n", HcExtension, Tt);
2168 Tt->HcExtension = HcExtension;
2175 Tt->FrameBudget[ix].AltEndpoint =
NULL;
2179 Tt->TimeCS[ix][jx] = 0;
2180 Tt->NumStartSplits[ix][jx] = 0;
2183 Tt->FrameBudget[ix].IsoEndpoint = &Tt->IsoEndpoint[ix];
2195 Tt->IsoEndpoint[ix].StartFrame = ix;
2198 Tt->FrameBudget[ix].IntEndpoint = &Tt->IntEndpoint[ix];
2210 Tt->IntEndpoint[ix].StartFrame = ix;
2222 DPRINT(
"USB2_InitController: HcExtension - %p\n", HcExtension);
2230 HcExtension->TimeUsed[ix][jx] = 0;
VOID NTAPI USBPORT_DumpingEndpointProperties(IN PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties)
VOID NTAPI USBPORT_DumpingTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint)
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IsListEmpty(ListHead)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
_In_ PUSBD_PIPE_INFORMATION _In_ USB_DEVICE_SPEED DeviceSpeed
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define ExFreePoolWithTag(_P, _T)
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
base of all file and directory entries
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
PUSB2_TT_ENDPOINT IntEndpoint
PUSB2_TT_ENDPOINT IsoEndpoint
PUSB2_TT_ENDPOINT AltEndpoint
ULONG TimeUsed[USB2_FRAMES][USB2_MICROFRAMES]
PUSB2_TT_ENDPOINT RebalanceEndpoint[USB2_FRAMES - 2]
USB2_TT_ENDPOINT_PARAMS TtEndpointParams
PUSBPORT_ENDPOINT Endpoint
struct _USB2_TT_ENDPOINT * NextTtEndpoint
ULONG Bandwidth[USB2_FRAMES]
ULONG TimeCS[USB2_FRAMES][USB2_MICROFRAMES]
PUSB2_HC_EXTENSION HcExtension
USB2_FRAME_BUDGET FrameBudget[USB2_FRAMES]
ULONG NumStartSplits[USB2_FRAMES][USB2_MICROFRAMES]
UCHAR SplitCompletionMask
UCHAR InterruptScheduleMask
USB_DEVICE_SPEED DeviceSpeed
KSPIN_LOCK EndpointSpinLock
PUSB2_TT_ENDPOINT TtEndpoint
PUSB2_TT_EXTENSION TtExtension
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
static LARGE_INTEGER StartTime
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
enum _USB_DEVICE_SPEED USB_DEVICE_SPEED
BOOLEAN NTAPI USB2_ChangePeriod(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_REBALANCE Rebalance, IN PULONG RebalanceListEntries)
UCHAR NTAPI USB2_GetSMASK(IN PUSB2_TT_ENDPOINT TtEndpoint)
VOID NTAPI USB2_InitTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint, IN UCHAR TransferType, IN UCHAR Direction, IN UCHAR DeviceSpeed, IN USHORT Period, IN USHORT MaxPacketSize, IN PUSB2_TT Tt)
VOID NTAPI USB2_IncMicroFrame(OUT PUCHAR frame, OUT PUCHAR uframe)
BOOLEAN NTAPI USBPORT_AllocateBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
VOID NTAPI USB2_GetHsOverhead(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PULONG OverheadSS, IN PULONG OverheadCS)
VOID NTAPI USB2_InitController(IN PUSB2_HC_EXTENSION HcExtension)
UCHAR NTAPI USB2_GetCMASK(IN PUSB2_TT_ENDPOINT TtEndpoint)
VOID NTAPI USB2_RebalanceEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PLIST_ENTRY List)
BOOLEAN NTAPI USB2_AllocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint, IN LONG Frame)
VOID NTAPI USB2_InitTT(IN PUSB2_HC_EXTENSION HcExtension, IN PUSB2_TT Tt)
BOOLEAN NTAPI USB2_AllocateTimeForEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_REBALANCE Rebalance, IN PULONG RebalanceListEntries)
BOOLEAN NTAPI USB2_AllocateCheck(IN OUT PULONG OutTimeUsed, IN ULONG CalcBusTime, IN ULONG LimitAllocation)
ULONG NTAPI USB2_GetLastIsoTime(IN PUSB2_TT_ENDPOINT TtEndpoint, IN ULONG Frame)
BOOLEAN NTAPI USB2_CommonFrames(IN PUSB2_TT_ENDPOINT NextTtEndpoint, IN PUSB2_TT_ENDPOINT TtEndpoint)
static const UCHAR CMASKS[USB2_MICROFRAMES]
VOID NTAPI USBPORT_UpdateAllocatedBwTt(IN PUSB2_TT_EXTENSION TtExtension)
VOID NTAPI USB2_DeallocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint, IN ULONG Frame)
VOID NTAPI USB2_Rebalance(IN PDEVICE_OBJECT FdoDevice, IN PLIST_ENTRY RebalanceList)
BOOLEAN NTAPI USB2_DeallocateEndpointBudget(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_REBALANCE Rebalance, IN PULONG RebalanceListEntries, IN ULONG MaxFrames)
VOID NTAPI USBPORT_FreeBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
ULONG NTAPI USB2_GetOverhead(IN PUSB2_TT_ENDPOINT TtEndpoint)
BOOLEAN NTAPI USB2_MoveTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint, IN LONG BusTime, IN PUSB2_REBALANCE Rebalance, IN ULONG RebalanceListEntries, OUT BOOLEAN *OutResult)
USHORT NTAPI USB2_AddDataBitStuff(IN USHORT DataTime)
VOID NTAPI USB2_GetPrevMicroFrame(OUT PUCHAR frame, OUT PUCHAR uframe)
BOOLEAN NTAPI USB2_PromotePeriods(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_REBALANCE Rebalance, IN PULONG RebalanceListEntries)
VOID NTAPI USB2_ConvertFrame(IN UCHAR Frame, IN UCHAR Microframe, OUT PUCHAR HcFrame, OUT PUCHAR HcMicroframe)
ULONG NTAPI USB2_GetStartTime(IN PUSB2_TT_ENDPOINT nextTtEndpoint, IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_TT_ENDPOINT prevTtEndpoint, IN ULONG Frame)
BOOLEAN NTAPI USB2_CheckTtEndpointInsert(IN PUSB2_TT_ENDPOINT nextTtEndpoint, IN PUSB2_TT_ENDPOINT TtEndpoint)
#define USBPORT_TRANSFER_TYPE_INTERRUPT
#define USBPORT_TRANSFER_TYPE_ISOCHRONOUS
#define ENDPOINT_INTERRUPT_1ms
#define USBPORT_TRANSFER_TYPE_CONTROL
#define USBPORT_TRANSFER_DIRECTION_OUT
#define USBPORT_TRANSFER_TYPE_BULK
#define USB2_HS_CS_INTERRUPT_OUT_OVERHEAD
#define USB2_FS_RAW_BYTES_IN_MICROFRAME
#define USB2_CONTROLLER_DELAY
#define USB2_HS_ISOCHRONOUS_OUT_OVERHEAD
#define USB2_LS_INTERRUPT_OVERHEAD
#define USB2_MAX_MICROFRAME_ALLOCATION
#define USB2_HS_SS_ISOCHRONOUS_IN_OVERHEAD
#define ENDPOINT_FLAG_ROOTHUB_EP0
#define USB2_HS_ISOCHRONOUS_IN_OVERHEAD
#define USB2_HS_CS_INTERRUPT_IN_OVERHEAD
#define USB2_FS_INTERRUPT_OVERHEAD
#define USB2_HS_SS_INTERRUPT_OUT_OVERHEAD
#define USB2_PREV_MICROFRAME
#define USB2_MAX_MICROFRAMES
#define USB2_HS_CS_ISOCHRONOUS_IN_OVERHEAD
#define USB2_FS_ISOCHRONOUS_OVERHEAD
#define USB2_HS_SS_INTERRUPT_IN_OVERHEAD
#define USB2_HS_INTERRUPT_OUT_OVERHEAD
#define USB2_FS_MAX_PERIODIC_ALLOCATION
#define USB2_HS_SS_ISOCHRONOUS_OUT_OVERHEAD
#define USB2_MAX_FS_LS_TRANSACTIONS_IN_UFRAME
#define USB2_HS_INTERRUPT_IN_OVERHEAD
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_Must_inspect_result_ _In_ WDFCMRESLIST List
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
_In_ LARGE_INTEGER _In_ ULONG Period