Author: rgampa
Date: Thu Jun 8 13:57:41 2017
New Revision: 74959
URL:
http://svn.reactos.org/svn/reactos?rev=74959&view=rev
Log:
[USBXHCI]
-defined register address offsets and elaborate naming given for register internals
-XHCI_startController and intialise hardware functions are implementd.
-in rothub.c XHCI_RH_GetRootHubData function is implemented.
-In this version both usbport and usbxhci drivers are being loaded successfully.
CORE-13344
Modified:
branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h
branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c
branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c
branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h
Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
==============================================================================
--- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h [iso-8859-1] Thu Jun
8 13:57:41 2017
@@ -1,11 +1,25 @@
/* XHCI hardware registers */
+#define XHCI_HCSP1 1
+#define XHCI_HCSP2 2
+#define XHCI_HCSP3 3
+#define XHCI_HCCP1 4
+#define XHCI_DBOFF 5
+#define XHCI_HCCP2 6
+
+#define XHCI_USBCMD 0
+#define XHCI_USBSTS 1
+#define XHCI_DNCTRL 5
+#define XHCI_CRCR 6
+#define XHCI_DCBAAP 12
+#define XHCI_CONFIG 14
+
typedef union _XHCI_HC_STRUCTURAL_PARAMS_1 {
struct {
- ULONG MaxDeviceSlots : 8;
- ULONG MaxInterrupters : 11;
- ULONG Rsvd : 5;
- ULONG MaxPorts : 8;
+ ULONG NumberOfDeviceSlots : 8;
+ ULONG NumberOfInterrupters : 11;
+ ULONG Rsvd : 5;
+ ULONG NumberOfPorts : 8;
};
ULONG AsULONG;
} XHCI_HC_STRUCTURAL_PARAMS_1;
@@ -82,37 +96,37 @@
typedef union _XHCI_USB_COMMAND {
struct {
- ULONG RunStop : 1;
- ULONG HCReset : 1;
- ULONG INTEnable : 1;
- ULONG HSEEnable : 1;
- ULONG RsvdP1 : 3;
- ULONG LHCReset : 1;
- ULONG CSS : 1;
- ULONG CRS : 1;
- ULONG EWE : 1;
- ULONG EU3S : 1;
- ULONG RsvdP2 : 1;
- ULONG CME : 1;
- ULONG RsvdP3 : 18;
+ ULONG RunStop : 1;
+ ULONG HCReset : 1;
+ ULONG InterrupterEnable : 1;
+ ULONG HostSystemErrorEnable : 1;
+ ULONG RsvdP1 : 3;
+ ULONG LightHCReset : 1;
+ ULONG ControllerSaveState : 1;
+ ULONG ControllerRestoreState : 1;
+ ULONG EnableWrapEvent : 1;
+ ULONG EnableU3Stop : 1;
+ ULONG RsvdP2 : 1;
+ ULONG CEMEnable : 1;
+ ULONG RsvdP3 : 18;
};
ULONG AsULONG;
} XHCI_USB_COMMAND;
typedef union _XHCI_USB_STATUS {
struct {
- ULONG HCH : 1;
- ULONG RsvdZ1 : 1;
- ULONG HSE : 1;
- ULONG EINT : 1;
- ULONG PCD : 1;
- ULONG RsvdZ2 : 3;
- ULONG SSS : 1;
- ULONG RSS : 1;
- ULONG SRE : 1;
- ULONG CNR : 1;
- ULONG HCE : 1;
- ULONG RsvdZ3 : 19;
+ ULONG HCHalted : 1;
+ ULONG RsvdZ1 : 1;
+ ULONG HostSystemError : 1;
+ ULONG EventInterrupt : 1;
+ ULONG PortChangeDetect : 1;
+ ULONG RsvdZ2 : 3;
+ ULONG SaveStateStatus : 1;
+ ULONG RestoreStateStatus : 1;
+ ULONG SaveRestoreError : 1;
+ ULONG ControllerNotReady : 1;
+ ULONG HCError : 1;
+ ULONG RsvdZ3 : 19;
};
ULONG AsULONG;
} XHCI_USB_STATUS;
Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
==============================================================================
--- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c [iso-8859-1]
(original)
+++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c [iso-8859-1] Thu Jun
8 13:57:41 2017
@@ -11,7 +11,28 @@
XHCI_RH_GetRootHubData(IN PVOID xhciExtension,
IN PVOID rootHubData)
{
-
+ PXHCI_EXTENSION XhciExtension;
+ PUSBPORT_ROOT_HUB_DATA RootHubData;
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+
+ DPRINT_RH("XHCI_RH_GetRootHubData: XhciExtension - %p, rootHubData -
%p\n",
+ XhciExtension,
+ rootHubData);
+
+ RootHubData = (PUSBPORT_ROOT_HUB_DATA)rootHubData;
+
+ RootHubData->NumberOfPorts = XhciExtension->NumberOfPorts;
+
+
+ /*
+ Identifies a Compound Device: Hub is not part of a compound device.
+ Over-current Protection Mode: Global Over-current Protection.
+ */
+ RootHubData->HubCharacteristics &= 3;
+
+ RootHubData->PowerOnToPowerGood = 2;
+ RootHubData->HubControlCurrent = 0;
}
MPSTATUS
Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
==============================================================================
--- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c [iso-8859-1]
(original)
+++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c [iso-8859-1] Thu Jun
8 13:57:41 2017
@@ -7,193 +7,6 @@
USBPORT_REGISTRATION_PACKET RegPacket;
-
-//---------------------------------------roothub functions copied
over-----------------------------------------------
-
-/*
-VOID
-NTAPI
-XHCI_RH_GetRootHubData(IN PVOID xhciExtension,
- IN PVOID rootHubData)
-{
-
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_GetStatus(IN PVOID xhciExtension,
- IN PUSHORT Status)
-{
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_GetPortStatus(IN PVOID xhciExtension,
- IN USHORT Port,
- IN PULONG PortStatus)
-{
-
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_GetHubStatus(IN PVOID xhciExtension,
- IN PULONG HubStatus)
-{
-
- return 0;
-}
-
-VOID
-NTAPI
-XHCI_RH_FinishReset(IN PVOID xhciExtension,
- IN PUSHORT Port)
-{
-
-}
-
-ULONG
-NTAPI
-XHCI_RH_PortResetComplete(IN PVOID xhciExtension,
- IN PUSHORT Port)
-{
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_SetFeaturePortReset(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_SetFeaturePortPower(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-MPSTATUS
-NTAPI
-XHCI_RH_SetFeaturePortEnable(IN PVOID xhciExtension,
- IN USHORT Port)
-{
- DPRINT_RH("XHCI_RH_SetFeaturePortEnable: Not supported\n");
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_SetFeaturePortSuspend(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortEnable(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortPower(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-VOID
-NTAPI
-XHCI_RH_PortResumeComplete(IN PULONG xhciExtension,
- IN PUSHORT Port)
-{
-
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortSuspend(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortEnableChange(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortConnectChange(IN PVOID xhciExtension,
- IN USHORT Port)
-{
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortResetChange(IN PVOID xhciExtension,
- IN USHORT Port)
-{
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortSuspendChange(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-MPSTATUS
-NTAPI
-XHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID xhciExtension,
- IN USHORT Port)
-{
-
- return 0;
-}
-
-VOID
-NTAPI
-XHCI_RH_DisableIrq(IN PVOID xhciExtension)
-{
-
-}
-
-VOID
-NTAPI
-XHCI_RH_EnableIrq(IN PVOID xhciExtension)
-{
-
-}
-
-*/
-
-//-------------------------------------------------------------------------------------------------------------------
MPSTATUS
NTAPI
@@ -233,10 +46,133 @@
MPSTATUS
NTAPI
+XHCI_InitializeSchedule(IN PXHCI_EXTENSION XhciExtension,
+ IN PVOID resourcesStartVA,
+ IN PVOID resourcesStartPA)
+{
+ return MP_STATUS_SUCCESS;
+}
+
+MPSTATUS
+NTAPI
+XHCI_InitializeHardware(IN PXHCI_EXTENSION XhciExtension)
+{
+ PULONG BaseIoAdress;
+ PULONG OperationalRegs;
+ XHCI_USB_COMMAND Command;
+ XHCI_USB_STATUS Status;
+ LARGE_INTEGER CurrentTime = {{0, 0}};
+ LARGE_INTEGER LastTime = {{0, 0}};
+ XHCI_HC_STRUCTURAL_PARAMS_1 StructuralParams_1;
+
+ DPRINT1("EHCI_InitializeHardware: ... \n");
+
+ OperationalRegs = XhciExtension->OperationalRegs;
+ BaseIoAdress = XhciExtension->BaseIoAdress;
+
+
+ KeQuerySystemTime(&CurrentTime);
+ CurrentTime.QuadPart += 100 * 10000; // 100 msec
+
+ Status.AsULONG = READ_REGISTER_ULONG(OperationalRegs + XHCI_USBSTS);
+ ASSERT(Status.ControllerNotReady != 1); // this is needed before writing anything to
the operaational or doorbell registers
+
+ Command.AsULONG = READ_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD);
+ Command.HCReset = 1;
+ while(TRUE)
+ {
+ KeQuerySystemTime(&LastTime);
+
+ Command.AsULONG = READ_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD);
+
+ if (Command.HCReset != 1)
+ {
+ break;
+ }
+
+ if (LastTime.QuadPart >= CurrentTime.QuadPart)
+ {
+ if (Command.HCReset == 1)
+ {
+ DPRINT1("EHCI_InitializeHardware: Software Reset failed!\n");
+ return 7;
+ }
+
+ break;
+ }
+ }
+ DPRINT("EHCI_InitializeHardware: Reset - OK\n");
+
+ StructuralParams_1.AsULONG = READ_REGISTER_ULONG(BaseIoAdress + XHCI_HCSP1); //
HCSPARAMS1 register
+
+ XhciExtension->NumberOfPorts = StructuralParams_1.NumberOfPorts;
+ //EhciExtension->PortPowerControl = StructuralParams.PortPowerControl;
+ DbgBreakPoint();
+ return MP_STATUS_SUCCESS;
+}
+
+MPSTATUS
+NTAPI
XHCI_StartController(IN PVOID xhciExtension,
IN PUSBPORT_RESOURCES Resources)
{
- DPRINT1("XHCI_StartController: UNIMPLEMENTED. FIXME\n");
+ PXHCI_EXTENSION XhciExtension;
+ PULONG BaseIoAdress;
+ PULONG OperationalRegs;
+ MPSTATUS MPStatus;
+ XHCI_USB_COMMAND Command;
+ UCHAR CapabilityRegLength;
+ UCHAR Fladj;
+
+ DPRINT1("XHCI_StartController: function initiated\n");
+
+ if ((Resources->TypesResources & (USBPORT_RESOURCES_MEMORY |
USBPORT_RESOURCES_INTERRUPT)) !=
+ (USBPORT_RESOURCES_MEMORY |
USBPORT_RESOURCES_INTERRUPT))
+ {
+ DPRINT1("XHCI_StartController: Resources->TypesResources - %x\n",
+ Resources->TypesResources);
+
+ return MP_STATUS_ERROR;
+ }
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+
+ BaseIoAdress = (PULONG)Resources->ResourceBase;
+ XhciExtension->BaseIoAdress = BaseIoAdress;
+
+ CapabilityRegLength = (UCHAR)READ_REGISTER_ULONG(BaseIoAdress);
+ OperationalRegs = (PULONG)((ULONG)BaseIoAdress + CapabilityRegLength);
+ XhciExtension->OperationalRegs = OperationalRegs;
+
+ DPRINT("XHCI_StartController: BaseIoAdress - %p\n", BaseIoAdress);
+ DPRINT("XHCI_StartController: OperationalRegs - %p\n", OperationalRegs);
+
+ RegPacket.UsbPortReadWriteConfigSpace(XhciExtension,
+ 1,
+ &Fladj,
+ 0x61,
+ 1);
+
+ XhciExtension->FrameLengthAdjustment = Fladj;
+
+ MPStatus = XHCI_InitializeHardware(XhciExtension);
+
+ if (MPStatus)
+ {
+ DPRINT1("XHCI_StartController: Unsuccessful InitializeHardware()\n");
+ return MPStatus;
+ }
+
+ MPStatus = XHCI_InitializeSchedule(XhciExtension,
+ Resources->StartVA,
+ Resources->StartPA);
+
+ if (MPStatus)
+ {
+ DPRINT1("XHCI_StartController: Unsuccessful InitializeSchedule()\n");
+ return MPStatus;
+ }
+
+ //DPRINT1("XHCI_StartController: UNIMPLEMENTED. FIXME\n");
return MP_STATUS_SUCCESS;
}
Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
==============================================================================
--- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h [iso-8859-1] Thu Jun
8 13:57:41 2017
@@ -19,6 +19,11 @@
PULONG BaseIoAdress;
PULONG OperationalRegs;
UCHAR FrameLengthAdjustment;
+ BOOLEAN IsStarted;
+ USHORT HcSystemErrors;
+ ULONG PortRoutingControl;
+ USHORT NumberOfPorts; // HCSPARAMS1 => N_PORTS
+ USHORT PortPowerControl; // HCSPARAMS => Port Power Control (PPC)
} XHCI_EXTENSION, *PXHCI_EXTENSION;