Author: rgampa
Date: Tue Aug 8 09:43:52 2017
New Revision: 75503
URL:
http://svn.reactos.org/svn/reactos?rev=75503&view=rev
Log:
[USBXHCI]
-implemented roothub functions.
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] Tue Aug
8 09:43:52 2017
@@ -15,7 +15,7 @@
#define XHCI_CRCR 6
#define XHCI_DCBAAP 12
#define XHCI_CONFIG 14
-#define XHCI_PORTSC 100
+#define XHCI_PORTSC 256
// runtime register offsets
#define XHCI_IMAN 8
#define XHCI_IMOD 9
@@ -131,7 +131,7 @@
};
ULONG AsULONG;
} XHCI_USB_COMMAND;
-
+C_ASSERT(sizeof(XHCI_USB_COMMAND)==sizeof(ULONG));
typedef volatile union _XHCI_USB_STATUS {
struct {
ULONG HCHalted : 1;
@@ -149,7 +149,7 @@
};
ULONG AsULONG;
} XHCI_USB_STATUS;
-
+C_ASSERT(sizeof(XHCI_USB_STATUS)==sizeof(ULONG));
typedef volatile union _XHCI_PAGE_SIZE {
struct {
ULONG PageSize : 16;
@@ -197,7 +197,9 @@
};
ULONG AsULONG;
} XHCI_CONFIGURE;
-
+C_ASSERT(sizeof(XHCI_CONFIGURE) == sizeof(ULONG));
+
+#define PORT_STATUS_MASK 0x4F01FFE5 // 0100 1111 0000 0001 1111 1111 1110 0101 // RW
1, RW1C/RW1S 0, RO 1
typedef volatile union _XHCI_PORT_STATUS_CONTROL {
struct {
ULONG CurrentConnectStatus : 1;
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] Tue Aug
8 09:43:52 2017
@@ -61,7 +61,8 @@
XhciExtension = (PXHCI_EXTENSION)xhciExtension;
PortStatusRegPointer = (XhciExtension->OperationalRegs) + (XHCI_PORTSC + (Port -
1)*4);
PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
-
+ //DPRINT("XHCI_RH_GetPortStatus: Port - %i\n", Port);
+ DPRINT("XHCI_RH_GetPortStatus: PortStatus Register, port - %p , %i\n",
PortStatusRegister.AsULONG, Port);
/*
ULONG ConnectStatus : 1; // Current Connect Status
ULONG EnableStatus : 1; // Port Enabled/Disabled
@@ -88,7 +89,7 @@
ULONG IndicatorControlChange : 1;
ULONG Reserved4 : 3;
*/
- /*
+ /* register interface
ULONG CurrentConnectStatus : 1;
ULONG PortEnableDisable : 1;
ULONG RsvdZ1 : 1;
@@ -139,8 +140,9 @@
portstatus.UsbPortStatusChange.TestModeChange =
0;//PortStatusRegister.ConnectStatusChange;
portstatus.UsbPortStatusChange.IndicatorControlChange =0;//
PortStatusRegister.ConnectStatusChange;
- DPRINT("XHCI_RH_GetPortStatus: PortStatus - %p\n",
portstatus.AsULONG);
- DPRINT("XHCI_RH_GetPortStatus: Port - %i\n", Port);
+
+ //DPRINT("XHCI_RH_GetPortStatus: PortStatus - %p\n",
portstatus.AsULONG);
+
*PortStatus = portstatus.AsULONG;
return MP_STATUS_SUCCESS;
@@ -179,7 +181,43 @@
IN USHORT Port)
{
DPRINT1("XHCI_RH_SetFeaturePortReset: function initiated\n");
- return 0;
+ PXHCI_EXTENSION XhciExtension;
+ PULONG PortStatusRegPointer;
+ XHCI_PORT_STATUS_CONTROL PortStatusRegister;
+ LARGE_INTEGER CurrentTime = {{0, 0}};
+ LARGE_INTEGER LastTime = {{0, 0}};
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ PortStatusRegPointer = (XhciExtension->OperationalRegs) + (XHCI_PORTSC + (Port -
1)*4);
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
+
+ PortStatusRegister.AsULONG = PortStatusRegister.AsULONG & PORT_STATUS_MASK;
+ PortStatusRegister.PortReset = 1;
+
+ WRITE_REGISTER_ULONG(PortStatusRegPointer , PortStatusRegister.AsULONG );
+
+ KeQuerySystemTime(&CurrentTime);
+ CurrentTime.QuadPart += 100 * 10000; // 100 msec
+ while(TRUE)
+ {
+ KeQuerySystemTime(&LastTime);
+
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
+
+ if (PortStatusRegister.PortReset!= 1)
+ {
+ break;
+ }
+
+ if (LastTime.QuadPart >= CurrentTime.QuadPart)
+ {
+ DPRINT1("XHCI_RH_SetFeaturePortReset: Software Reset failed!\n");
+ return MP_STATUS_FAILURE;
+ }
+ }
+
+
+ return MP_STATUS_SUCCESS;
}
MPSTATUS
@@ -187,8 +225,21 @@
XHCI_RH_SetFeaturePortPower(IN PVOID xhciExtension,
IN USHORT Port)
{
- DPRINT1("XHCI_RH_SetFeaturePortPower: function initiated\n");
- return 0;
+ DPRINT1("XHCI_RH_SetFeaturePortPower: function initiated\n");
+ PXHCI_EXTENSION XhciExtension;
+ PULONG PortStatusRegPointer;
+ XHCI_PORT_STATUS_CONTROL PortStatusRegister;
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ PortStatusRegPointer = (XhciExtension->OperationalRegs) + (XHCI_PORTSC + (Port -
1)*4);
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
+
+ PortStatusRegister.AsULONG = PortStatusRegister.AsULONG & PORT_STATUS_MASK;
+ PortStatusRegister.PortPower = 1;
+
+ WRITE_REGISTER_ULONG(PortStatusRegPointer , PortStatusRegister.AsULONG );
+
+ return MP_STATUS_SUCCESS;
}
MPSTATUS
NTAPI
@@ -213,7 +264,7 @@
XHCI_RH_ClearFeaturePortEnable(IN PVOID xhciExtension,
IN USHORT Port)
{
- DPRINT1("XHCI_RH_ClearFeaturePortEnable: function initiated\n");
+ DPRINT1("XHCI_RH_ClearFeaturePortEnable: function initiated\n");
return 0;
}
@@ -259,7 +310,24 @@
IN USHORT Port)
{
DPRINT1("XHCI_RH_ClearFeaturePortConnectChange: function initiated\n");
- return 0;
+ PXHCI_EXTENSION XhciExtension;
+ PULONG PortStatusRegPointer;
+ XHCI_PORT_STATUS_CONTROL PortStatusRegister;
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ PortStatusRegPointer = (XhciExtension->OperationalRegs) + (XHCI_PORTSC + (Port -
1)*4);
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
+
+ PortStatusRegister.AsULONG = PortStatusRegister.AsULONG & PORT_STATUS_MASK;
+ PortStatusRegister.ConnectStatusChange = 1;
+
+ WRITE_REGISTER_ULONG(PortStatusRegPointer , PortStatusRegister.AsULONG );
+
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
+ if (PortStatusRegister.ConnectStatusChange == 1){
+ return MP_STATUS_FAILURE;
+ }
+ return MP_STATUS_SUCCESS;
}
MPSTATUS
@@ -268,7 +336,25 @@
IN USHORT Port)
{
DPRINT1("XHCI_RH_ClearFeaturePortResetChange: function initiated\n");
- return 0;
+ PXHCI_EXTENSION XhciExtension;
+ PULONG PortStatusRegPointer;
+ XHCI_PORT_STATUS_CONTROL PortStatusRegister;
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ PortStatusRegPointer = (XhciExtension->OperationalRegs) + (XHCI_PORTSC + (Port -
1)*4);
+
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
+
+ PortStatusRegister.AsULONG = PortStatusRegister.AsULONG & PORT_STATUS_MASK;
+ PortStatusRegister.PortResetChange = 1;
+
+ WRITE_REGISTER_ULONG(PortStatusRegPointer , PortStatusRegister.AsULONG );
+
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusRegPointer) ;
+ if (PortStatusRegister.PortResetChange == 1){
+ return MP_STATUS_FAILURE;
+ }
+ return MP_STATUS_SUCCESS;
}
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] Tue Aug
8 09:43:52 2017
@@ -184,6 +184,7 @@
HcResourcesVA = (PXHCI_HC_RESOURCES)resourcesStartVA;
ASSERT((ULONG_PTR)HcResourcesVA % PAGE_SIZE == 0);
+ XhciExtension->HcResourcesVA = HcResourcesVA;
HcResourcesPA.QuadPart = (ULONG_PTR)resourcesStartPA;
BaseIoAdress = XhciExtension->BaseIoAdress;
OperationalRegs = XhciExtension->OperationalRegs;
@@ -341,13 +342,8 @@
if (LastTime.QuadPart >= CurrentTime.QuadPart)
{
- if (Command.HCReset == 1)
- {
- DPRINT1("XHCI_InitializeHardware: Software Reset failed!\n");
- return 7;
- }
-
- break;
+ DPRINT1("XHCI_InitializeHardware: Software Reset failed!\n");
+ return 7;
}
}
DPRINT("XHCI_InitializeHardware: Reset - OK\n");
@@ -360,6 +356,8 @@
Config.AsULONG = READ_REGISTER_ULONG(OperationalRegs + XHCI_CONFIG);
ASSERT(Command.RunStop==0); //required before setting max device slots enabled.
Config.MaxDeviceSlotsEnabled = 1; // max possible value is number of slots
HCSPARAMS1
+ Config.U3EntryEnable = 0;
+ Config.ConfigurationInfoEnable = 0;
WRITE_REGISTER_ULONG(OperationalRegs + XHCI_CONFIG, Config.AsULONG);
return MP_STATUS_SUCCESS;
@@ -463,8 +461,8 @@
Command.RunStop =1;
WRITE_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD, Command.AsULONG );
- MPStatus = XHCI_ControllerWorkTest(XhciExtension,Resources->StartVA,
Resources->StartPA );
- //DPRINT1("XHCI_StartController: UNIMPLEMENTED. FIXME\n");
+ //MPStatus = XHCI_ControllerWorkTest(XhciExtension,Resources->StartVA,
Resources->StartPA );
+
return MP_STATUS_SUCCESS;
}
@@ -561,6 +559,14 @@
erstdp.DequeueERSTIndex =0;
XHCI_Write64bitReg (RunTimeRegisterBase + XHCI_ERSTDP, erstdp.AsULONGLONG);
+ PXHCI_HC_RESOURCES HcResourcesVA;
+ XHCI_TRB eventtrb;
+ HcResourcesVA = XhciExtension->HcResourcesVA;
+ eventtrb = HcResourcesVA -> EventRing.firstSeg.XhciTrb[0];
+ DPRINT("XHCI_ControllerWorkTest: eventtrb word0 - %p\n",
eventtrb.EventTRB.Word0);
+ DPRINT("XHCI_ControllerWorkTest: eventtrb word1 - %p\n",
eventtrb.EventTRB.Word1);
+ DPRINT("XHCI_ControllerWorkTest: eventtrb word2 - %p\n",
eventtrb.EventTRB.Word2);
+ DPRINT("XHCI_ControllerWorkTest: eventtrb word3 - %p\n",
eventtrb.EventTRB.Word3);
return TRUE;
}
@@ -655,14 +661,14 @@
XHCI_CheckController(IN PVOID xhciExtension)
{
//RegPacket.UsbPortInvalidateController(xhciExtension, 2);
- DPRINT1("XHCI_CheckController: function initiated\n");
+ //DPRINT1("XHCI_CheckController: function initiated\n");
}
ULONG
NTAPI
XHCI_Get32BitFrameNumber(IN PVOID xhciExtension)
{
- DPRINT1("XHCI_Get32BitFrameNumber: function initiated\n");
+ //DPRINT1("XHCI_Get32BitFrameNumber: function initiated\n");
return 0;
}
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] Tue Aug
8 09:43:52 2017
@@ -203,6 +203,14 @@
PXHCI_SEGMENT dequeue_segment;
ULONGLONG Padding;
} XHCI_RING, *PXHCI_RING;
+typedef struct _XHCI_HC_RESOURCES {
+ XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY DCBAA;
+ DECLSPEC_ALIGN(16) XHCI_RING EventRing ;
+ DECLSPEC_ALIGN(64) XHCI_RING CommandRing ;
+ XHCI_EVENT_RING_SEGMENT_TABLE EventRingSegTable;
+} XHCI_HC_RESOURCES, *PXHCI_HC_RESOURCES;
+C_ASSERT (FIELD_OFFSET(XHCI_HC_RESOURCES,EventRing)% 16 == 0);
+C_ASSERT (FIELD_OFFSET(XHCI_HC_RESOURCES,CommandRing)% 64 == 0);
typedef struct _XHCI_EXTENSION {
ULONG Reserved;
@@ -221,16 +229,10 @@
USHORT MaxScratchPadBuffers;
PMDL ScratchPadArrayMDL;
PMDL ScratchPadBufferMDL;
+ PXHCI_HC_RESOURCES HcResourcesVA;
} XHCI_EXTENSION, *PXHCI_EXTENSION;
-typedef struct _XHCI_HC_RESOURCES {
- XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY DCBAA;
- DECLSPEC_ALIGN(16) XHCI_RING EventRing ;
- DECLSPEC_ALIGN(64) XHCI_RING CommandRing ;
- XHCI_EVENT_RING_SEGMENT_TABLE EventRingSegTable;
-} XHCI_HC_RESOURCES, *PXHCI_HC_RESOURCES;
-C_ASSERT (FIELD_OFFSET(XHCI_HC_RESOURCES,EventRing)% 16 == 0);
-C_ASSERT (FIELD_OFFSET(XHCI_HC_RESOURCES,CommandRing)% 64 == 0);
+
typedef struct _XHCI_ENDPOINT {
ULONG Reserved;
} XHCI_ENDPOINT, *PXHCI_ENDPOINT;