/* * PROJECT: ReactOS USB Port Driver * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) * PURPOSE: USBPort USB 2.0 functions * COPYRIGHT: Copyright 2017 Vadim Galyant */ #include "usbport.h" //#define NDEBUG #include 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) { RtlZeroMemory(TtEndpoint, sizeof(USB2_TT_ENDPOINT)); TtEndpoint->TtEndpointParams.TransferType = TransferType; TtEndpoint->TtEndpointParams.Direction = Direction; TtEndpoint->TtEndpointParams.DeviceSpeed = DeviceSpeed; TtEndpoint->Period = Period; TtEndpoint->MaxPacketSize = MaxPacketSize; TtEndpoint->Tt = Tt; } BOOLEAN NTAPI USBPORT_AllocateBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint) { DPRINT1("USBPORT_AllocateBandwidthUSB2: UNIMPLEMENTED. FIXME. \n"); return TRUE; } VOID NTAPI USBPORT_FreeBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint) { DPRINT1("USBPORT_FreeBandwidthUSB2: UNIMPLEMENTED. FIXME. \n"); } VOID NTAPI USB2_InitTT(IN PUSB2_HC_EXTENSION HcExtension, IN PUSB2_TT Tt) { ULONG ix; ULONG jx; DPRINT("USB2_InitTT: HcExtension - %p, Tt - %p\n", HcExtension, Tt); Tt->HcExtension = HcExtension; Tt->DelayTime = 1; Tt->MaxTime = USB2_FS_MAX_PERIODIC_ALLOCATION; for (ix = 0; ix < USB2_FRAMES; ix++) { Tt->FrameBudget[ix].TimeUsed = USB2_MAX_MICROFRAMES; Tt->FrameBudget[ix].AltEndpoint = NULL; for (jx = 0; jx < USB2_MICROFRAMES; jx++) { Tt->TimeCS[ix][jx] = 0; Tt->NumStartSplits[ix][jx] = 0; } Tt->FrameBudget[ix].IsoEndpoint = &Tt->IsoEndpoint[ix]; USB2_InitTtEndpoint(&Tt->IsoEndpoint[ix], USBPORT_TRANSFER_TYPE_ISOCHRONOUS, USBPORT_TRANSFER_DIRECTION_OUT, UsbFullSpeed, USB2_FRAMES, 0, Tt); Tt->IsoEndpoint[ix].ActualPeriod = USB2_FRAMES; Tt->IsoEndpoint[ix].CalcBusTime = USB2_FS_SOF_TIME + USB2_HUB_DELAY; Tt->IsoEndpoint[ix].StartFrame = ix; Tt->IsoEndpoint[ix].StartMicroframe = 0xFF; Tt->FrameBudget[ix].IntEndpoint = &Tt->IntEndpoint[ix]; USB2_InitTtEndpoint(&Tt->IntEndpoint[ix], USBPORT_TRANSFER_TYPE_INTERRUPT, USBPORT_TRANSFER_DIRECTION_OUT, UsbFullSpeed, USB2_FRAMES, 0, Tt); Tt->IntEndpoint[ix].ActualPeriod = USB2_FRAMES; Tt->IntEndpoint[ix].CalcBusTime = USB2_FS_SOF_TIME + USB2_HUB_DELAY; Tt->IntEndpoint[ix].StartFrame = ix; Tt->IntEndpoint[ix].StartMicroframe = 0xFF; } } VOID NTAPI USB2_InitController(IN PUSB2_HC_EXTENSION HcExtension) { ULONG ix; ULONG jx; DPRINT("USB2_InitController: HcExtension - %p\n", HcExtension); HcExtension->MaxHsBusAllocation = USB2_MAX_MICROFRAME_ALLOCATION; for (ix = 0; ix < USB2_FRAMES; ix++) { for (jx = 0; jx < USB2_MICROFRAMES; jx++) { HcExtension->TimeUsed[ix][jx] = 0; } } HcExtension->HcDelayTime = USB2_CONTROLLER_DELAY; USB2_InitTT(HcExtension, &HcExtension->HcTt); }