Author: rgampa
Date: Thu Jul 6 07:36:05 2017
New Revision: 75291
URL:
http://svn.reactos.org/svn/reactos?rev=75291&view=rev
Log:
[USBXHCI]
- added dprints to all the xhci functions.
- some fixes suggested in code review.
- have written interrupt code (rudimentary).
CORE-13344
Modified:
branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbport/roothub.c
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/usbport/roothub.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
==============================================================================
--- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbport/roothub.c [iso-8859-1]
(original)
+++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbport/roothub.c [iso-8859-1] Thu Jul
6 07:36:05 2017
@@ -3,7 +3,7 @@
#define NDEBUG
#include <debug.h>
-#define NDEBUG_USBPORT_CORE
+//#define NDEBUG_USBPORT_CORE
#include "usbdebug.h"
RHSTATUS
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 Jul
6 07:36:05 2017
@@ -5,7 +5,8 @@
#define XHCI_HCSP3 3
#define XHCI_HCCP1 4
#define XHCI_DBOFF 5
-#define XHCI_HCCP2 6
+#define XHCI_RTSOFF 6
+#define XHCI_HCCP2 7
#define XHCI_USBCMD 0
#define XHCI_USBSTS 1
@@ -13,8 +14,15 @@
#define XHCI_CRCR 6
#define XHCI_DCBAAP 12
#define XHCI_CONFIG 14
-
-typedef unsigned long long ULONGULONG ;
+#define XHCI_PORTSC 100
+
+#define XHCI_IMAN 0
+#define XHCI_IMOD 1
+#define XHCI_ERSTSZ 2
+#define XHCI_ERSTBA 4
+#define XHCI_ERSTDP 6
+
+
typedef union _XHCI_HC_STRUCTURAL_PARAMS_1 {
struct {
@@ -77,8 +85,8 @@
typedef union _XHCI_RT_REGISTER_SPACE_OFFSET { //RUNTIME REGISTER SPACE OFFSET
struct {
- ULONG Rsvd : 2;
- ULONG RTSOffset : 30;
+ ULONG Rsvd : 5;
+ ULONG RTSOffset : 27;
};
ULONG AsULONG;
} XHCI_RT_REGISTER_SPACE_OFFSET;
@@ -149,12 +157,34 @@
ULONG AsULONG;
} XHCI_DEVICE_NOTIFICATION_CONTROL;
+typedef union _XHCI_COMMAND_RING_CONTROL {
+ struct {
+ ULONGLONG RingCycleState : 1;
+ ULONGLONG CommandStop : 1;
+ ULONGLONG CommandAbort : 1;
+ ULONGLONG CommandRingRunning : 1;
+ ULONGLONG RsvdP : 2;
+ ULONGLONG CommandRingPointerLo : 26;
+ ULONGLONG CommandRingPointerHi : 32;
+ };
+ ULONGLONG AsULONGLONG;
+} XHCI_COMMAND_RING_CONTROL;
+
+typedef union _XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER {
+ struct {
+ ULONGLONG RsvdZ : 6;
+ ULONGLONG DCBAAPointerLo : 26;
+ ULONGLONG DCBAAPointerHi : 32;
+ };
+ ULONGLONG AsULONGLONG;
+} XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER;
+
typedef union _XHCI_CONFIGURE {
struct {
ULONG MaxDeviceSlotsEnabled : 8;
ULONG U3EntryEnable : 1;
ULONG ConfigurationInfoEnable : 1;
- ULONG Rsvd : 21;
+ ULONG Rsvd : 22;
};
ULONG AsULONG;
} XHCI_CONFIGURE;
@@ -189,25 +219,45 @@
ULONG AsULONG;
} XHCI_PORT_STATUS_CONTROL;
-typedef union _XHCI_COMMAND_RING_CONTROL {
- struct {
- ULONGULONG RingCycleState : 1;
- ULONGULONG CommandStop : 1;
- ULONGULONG CommandAbort : 1;
- ULONGULONG CommandRingRunning : 1;
- ULONGULONG RsvdP : 2;
- ULONGULONG CommandRingPointerLo : 26;
- ULONGULONG CommandRingPointerHi : 32;
- };
- ULONGULONG AsULONGULONG;
-} XHCI_COMMAND_RING_CONTROL;
-
-typedef union _XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER {
- struct {
- ULONGULONG RsvdZ : 6;
- ULONGULONG DCBAAPointerLo : 26;
- ULONGULONG DCBAAPointerHi : 32;
- };
- ULONGULONG AsULONGULONG;
-} XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER;
-
+// Interrupt Register Set
+typedef union _XHCI_INTERRUPTER_MANAGEMENT {
+ struct {
+ ULONG InterruptPending : 1;
+ ULONG InterruptEnable : 1;
+ ULONG RsvdP : 30;
+ };
+ ULONG AsULONG;
+} XHCI_INTERRUPTER_MANAGEMENT;
+
+typedef union _XHCI_INTERRUPTER_MODERATION {
+ struct {
+ ULONG InterruptModIterval : 16;
+ ULONG InterruptModCounter : 16;
+ };
+ ULONG AsULONG;
+} XHCI_INTERRUPTER_MODERATION;
+
+typedef union _XHCI_EVENT_RING_TABLE_SIZE {
+ struct {
+ ULONG EventRingSegTableSize : 16;
+ ULONG RsvdP : 16;
+ };
+ ULONG AsULONG;
+} XHCI_EVENT_RING_TABLE_SIZE;
+
+typedef union _XHCI_EVENT_RING_TABLE_BASE_ADDR {
+ struct {
+ ULONGLONG RsvdP : 6;
+ ULONGLONG EventRingSegTableBaseAddr : 58;
+ };
+ ULONGLONG AsULONGLONG;
+} XHCI_EVENT_RING_TABLE_BASE_ADDR;
+
+typedef union _XHCI_EVENT_RING_DEQUEUE_POINTER {
+ struct {
+ ULONGLONG DequeueERSTIndex : 3;
+ ULONGLONG EventHandlerBusy : 1;
+ ULONGLONG EventRingSegDequeuePointer : 60;
+ };
+ ULONGLONG AsULONGLONG;
+} XHCI_EVENT_RING_DEQUEUE_POINTER;
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 Jul
6 07:36:05 2017
@@ -11,6 +11,7 @@
XHCI_RH_GetRootHubData(IN PVOID xhciExtension,
IN PVOID rootHubData)
{
+ DPRINT1("XHCI_RH_GetRootHubData: function initiated\n");
PXHCI_EXTENSION XhciExtension;
PUSBPORT_ROOT_HUB_DATA RootHubData;
@@ -40,7 +41,7 @@
XHCI_RH_GetStatus(IN PVOID xhciExtension,
IN PUSHORT Status)
{
-
+ DPRINT1("XHCI_RH_GetStatus: function initiated\n");
return 0;
}
@@ -50,9 +51,20 @@
IN USHORT Port,
IN PULONG PortStatus)
{
+ int cntr = 0;
+ DPRINT1("XHCI_RH_GetPortStatus: function initiated\n" + cntr);
+ cntr = cntr + 1;
+ PXHCI_EXTENSION XhciExtension;
+ PULONG PortStatusReg;
+ XHCI_PORT_STATUS_CONTROL PortStatusRegister;
-
- return 0;
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ PortStatusReg = (XhciExtension->OperationalRegs) + (XHCI_PORTSC + (Port - 1)*4);
+ PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusReg) ;
+
+ *PortStatus = PortStatusRegister.AsULONG;
+
+ return MP_STATUS_SUCCESS;
}
MPSTATUS
@@ -60,7 +72,7 @@
XHCI_RH_GetHubStatus(IN PVOID xhciExtension,
IN PULONG HubStatus)
{
-
+ DPRINT1("XHCI_RH_GetHubStatus: function initiated\n");
return 0;
}
@@ -69,7 +81,7 @@
XHCI_RH_FinishReset(IN PVOID xhciExtension,
IN PUSHORT Port)
{
-
+ DPRINT1("XHCI_RH_FinishReset: function initiated\n");
}
ULONG
@@ -77,6 +89,7 @@
XHCI_RH_PortResetComplete(IN PVOID xhciExtension,
IN PUSHORT Port)
{
+ DPRINT1("XHCI_RH_PortResetComplete: function initiated\n");
return 0;
}
@@ -85,7 +98,7 @@
XHCI_RH_SetFeaturePortReset(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_SetFeaturePortReset: function initiated\n");
return 0;
}
@@ -94,7 +107,7 @@
XHCI_RH_SetFeaturePortPower(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_SetFeaturePortPower: function initiated\n");
return 0;
}
MPSTATUS
@@ -111,7 +124,7 @@
XHCI_RH_SetFeaturePortSuspend(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_SetFeaturePortSuspend: function initiated\n");
return 0;
}
@@ -120,7 +133,7 @@
XHCI_RH_ClearFeaturePortEnable(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_ClearFeaturePortEnable: function initiated\n");
return 0;
}
@@ -129,6 +142,7 @@
XHCI_RH_ClearFeaturePortPower(IN PVOID xhciExtension,
IN USHORT Port)
{
+ DPRINT1("XHCI_RH_ClearFeaturePortPower: function initiated\n");
return 0;
}
@@ -138,7 +152,7 @@
XHCI_RH_PortResumeComplete(IN PULONG xhciExtension,
IN PUSHORT Port)
{
-
+ DPRINT1("XHCI_RH_PortResumeComplete: function initiated\n");
}
MPSTATUS
@@ -146,7 +160,7 @@
XHCI_RH_ClearFeaturePortSuspend(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_ClearFeaturePortSuspend: function initiated\n");
return 0;
}
@@ -155,7 +169,7 @@
XHCI_RH_ClearFeaturePortEnableChange(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_ClearFeaturePortEnableChange: function initiated\n");
return 0;
}
@@ -164,6 +178,7 @@
XHCI_RH_ClearFeaturePortConnectChange(IN PVOID xhciExtension,
IN USHORT Port)
{
+ DPRINT1("XHCI_RH_ClearFeaturePortConnectChange: function initiated\n");
return 0;
}
@@ -172,6 +187,7 @@
XHCI_RH_ClearFeaturePortResetChange(IN PVOID xhciExtension,
IN USHORT Port)
{
+ DPRINT1("XHCI_RH_ClearFeaturePortResetChange: function initiated\n");
return 0;
}
@@ -180,7 +196,7 @@
XHCI_RH_ClearFeaturePortSuspendChange(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_ClearFeaturePortSuspendChange: function initiated\n");
return 0;
}
@@ -189,7 +205,7 @@
XHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID xhciExtension,
IN USHORT Port)
{
-
+ DPRINT1("XHCI_RH_ClearFeaturePortOvercurrentChange: function
initiated\n");
return 0;
}
@@ -197,12 +213,37 @@
NTAPI
XHCI_RH_DisableIrq(IN PVOID xhciExtension)
{
-
+ DPRINT1("XHCI_RH_DisableIrq: function initiated\n");
+ PXHCI_EXTENSION XhciExtension;
+ PULONG OperationalRegs;
+ XHCI_USB_COMMAND usbCommand;
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ OperationalRegs = XhciExtension->OperationalRegs;
+ usbCommand.AsULONG =READ_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD);
+
+ usbCommand.InterrupterEnable = 0;
+
+ WRITE_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD,usbCommand.AsULONG );
+ DPRINT1("XHCI_RH_DisableIrq: Disable Interupts succesfull\n");
}
VOID
NTAPI
XHCI_RH_EnableIrq(IN PVOID xhciExtension)
{
-
-}
+ DPRINT1("XHCI_RH_EnableIrq: function initiated\n");
+ PXHCI_EXTENSION XhciExtension;
+ PULONG OperationalRegs;
+ XHCI_USB_COMMAND usbCommand;
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ OperationalRegs = XhciExtension->OperationalRegs;
+ usbCommand.AsULONG =READ_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD);
+
+ usbCommand.InterrupterEnable = 1;
+
+ WRITE_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD,usbCommand.AsULONG );
+ DPRINT1("XHCI_RH_EnableIrq: Enable Interupts\n");
+
+}
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 Jul
6 07:36:05 2017
@@ -14,6 +14,7 @@
IN PVOID endpointParameters,
IN PVOID xhciEndpoint)
{
+ DPRINT1("XHCI_OpenEndpoint: function initiated\n");
return MP_STATUS_SUCCESS;
}
@@ -23,6 +24,7 @@
IN PVOID endpointParameters,
IN PVOID xhciEndpoint)
{
+ DPRINT1("XHCI_ReopenEndpoint: function initiated\n");
return MP_STATUS_SUCCESS;
}
@@ -32,7 +34,7 @@
IN PVOID endpointParameters,
IN PULONG EndpointRequirements)
{
-
+ DPRINT1("XHCI_QueryEndpointRequirements: function initiated\n");
}
VOID
@@ -50,13 +52,24 @@
IN PVOID resourcesStartVA,
IN PVOID resourcesStartPA)
{
+ DPRINT1("XHCI_InitializeResources: function initiated\n");
PXHCI_HC_RESOURCES HcResourcesVA;
PHYSICAL_ADDRESS HcResourcesPA;
+ PULONG BaseIoAdress;
+ PULONG OperationalRegs;
+
+
+ PULONG RunTimeRegisterBase;
+ XHCI_INTERRUPTER_MANAGEMENT Iman;
+ XHCI_INTERRUPTER_MODERATION Imod;
+ XHCI_EVENT_RING_TABLE_SIZE erstz;
+ XHCI_EVENT_RING_TABLE_BASE_ADDR erstba;
+ XHCI_EVENT_RING_DEQUEUE_POINTER erstdp;
+ XHCI_EVENT_RING_SEGMENT_TABLE EventRingSegTable;
XHCI_COMMAND_RING_CONTROL CommandRingControlRegister;
XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER DCBAAPointer;
- PULONG OperationalRegs;
unsigned long X, Y;
DPRINT_XHCI("XHCI_InitializeResources: BaseVA - %p, BasePA - %p\n",
@@ -65,17 +78,19 @@
HcResourcesVA = (PXHCI_HC_RESOURCES)resourcesStartVA;
HcResourcesPA.QuadPart = (ULONG_PTR)resourcesStartPA;
-
- DCBAAPointer.AsULONGULONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES,
DCBAA);
-
+
+ //DCBAA init
+ DCBAAPointer.AsULONGLONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES,
DCBAA);
+
+ BaseIoAdress = XhciExtension->BaseIoAdress;
OperationalRegs = XhciExtension->OperationalRegs;
- //DCBAAPointer.RsvdZ =0;
+
WRITE_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP, DCBAAPointer.DCBAAPointerLo |
DCBAAPointer.RsvdZ );
WRITE_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP + 1,
DCBAAPointer.DCBAAPointerHi);
X = READ_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP) ;
Y = READ_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP + 1) ;
- DCBAAPointer.AsULONGULONG = Y|X ;
+ DCBAAPointer.AsULONGLONG = Y|X ;
ASSERT(DCBAAPointer.RsvdZ == 0);
// command ring intialisation.
@@ -88,17 +103,42 @@
HcResourcesVA->CommandRing.CREnquePointer=
&HcResourcesVA->CommandRing.Segment[0];
HcResourcesVA->CommandRing.CRDequePointer=
HcResourcesVA->CommandRing.CREnquePointer;
- CommandRingControlRegister.AsULONGULONG = HcResourcesPA.QuadPart +
FIELD_OFFSET(XHCI_HC_RESOURCES, CommandRing.Segment);
+ CommandRingControlRegister.AsULONGLONG = HcResourcesPA.QuadPart +
FIELD_OFFSET(XHCI_HC_RESOURCES, CommandRing.Segment);
ASSERT(CommandRingControlRegister.RingCycleState == 0);
ASSERT(CommandRingControlRegister.CommandStop == 0);
ASSERT(CommandRingControlRegister.CommandAbort == 0);
ASSERT(CommandRingControlRegister.CommandRingRunning == 0);
ASSERT(CommandRingControlRegister.RsvdP == 0);
- WRITE_REGISTER_ULONG(OperationalRegs + XHCI_CRCR,
CommandRingControlRegister.AsULONGULONG);
+ WRITE_REGISTER_ULONG(OperationalRegs + XHCI_CRCR,
CommandRingControlRegister.AsULONGLONG);
WRITE_REGISTER_ULONG(OperationalRegs + XHCI_CRCR + 1,
CommandRingControlRegister.CommandRingPointerHi);
-
- DbgBreakPoint();
+ // end of command ring init
+
+ //Primary Interrupter init
+ RunTimeRegisterBase = XhciExtension -> RunTimeRegisterBase;
+
+ Iman.InterruptEnable = 1;
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_IMAN , Iman.AsULONG);
+
+ // dont change imod now
+ erstz.EventRingSegTableSize = 1;
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTSZ , erstz.AsULONG);
+
+ erstba.AsULONGLONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES,
EventRingSegTable);
+
+ EventRingSegTable.RingSegmentBaseAddr = HcResourcesPA.QuadPart +
FIELD_OFFSET(XHCI_HC_RESOURCES, EventRing);
+ EventRingSegTable.RingSegmentSize = 16;
+ HcResourcesVA->EventRingSegTable = EventRingSegTable;
+
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTBA, erstba.AsULONGLONG);
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTBA + 1, erstba.AsULONGLONG
>> 32);
+ // intially enque and deque are equal.
+ erstdp.AsULONGLONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES,
EventRing);
+ erstdp.DequeueERSTIndex =0;
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP, erstdp.AsULONGLONG);
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP + 1, erstdp.AsULONGLONG
>> 32);
+
+ //DbgBreakPoint();
return MP_STATUS_SUCCESS;
}
@@ -106,8 +146,11 @@
NTAPI
XHCI_InitializeHardware(IN PXHCI_EXTENSION XhciExtension)
{
+ DPRINT1("XHCI_InitializeHardware: function initiated\n");
PULONG BaseIoAdress;
PULONG OperationalRegs;
+
+
XHCI_USB_COMMAND Command;
XHCI_USB_STATUS Status;
LARGE_INTEGER CurrentTime = {{0, 0}};
@@ -119,8 +162,7 @@
OperationalRegs = XhciExtension->OperationalRegs;
BaseIoAdress = XhciExtension->BaseIoAdress;
-
-
+
KeQuerySystemTime(&CurrentTime);
CurrentTime.QuadPart += 100 * 10000; // 100 msec
@@ -166,7 +208,7 @@
// Device Context base aaddress array to be defined
// Commnad ring deque pointer to be defined in CRCR
- DbgBreakPoint();
+ //DbgBreakPoint();
return MP_STATUS_SUCCESS;
}
@@ -175,15 +217,19 @@
XHCI_StartController(IN PVOID xhciExtension,
IN PUSBPORT_RESOURCES Resources)
{
+ DPRINT1("XHCI_StartController: function initiated\n");
PXHCI_EXTENSION XhciExtension;
PULONG BaseIoAdress;
PULONG OperationalRegs;
+ PULONG RunTimeRegisterBase;
+
MPSTATUS MPStatus;
XHCI_USB_COMMAND Command;
+ XHCI_RT_REGISTER_SPACE_OFFSET RTSOffsetRegister;
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))
@@ -199,9 +245,14 @@
XhciExtension->BaseIoAdress = BaseIoAdress;
CapabilityRegLength = (UCHAR)READ_REGISTER_ULONG(BaseIoAdress);
- OperationalRegs = (PULONG)((ULONG)BaseIoAdress + CapabilityRegLength);
+ OperationalRegs = (PULONG)((ULONG_PTR)BaseIoAdress + CapabilityRegLength);
XhciExtension->OperationalRegs = OperationalRegs;
-
+
+ RTSOffsetRegister.AsULONG = READ_REGISTER_ULONG(BaseIoAdress + XHCI_RTSOFF);
+ RunTimeRegisterBase = BaseIoAdress + RTSOffsetRegister.AsULONG ;
+
+ XhciExtension->RunTimeRegisterBase = RunTimeRegisterBase;
+
DPRINT("XHCI_StartController: BaseIoAdress - %p\n", BaseIoAdress);
DPRINT("XHCI_StartController: OperationalRegs - %p\n", OperationalRegs);
@@ -230,7 +281,9 @@
DPRINT1("XHCI_StartController: Unsuccessful InitializeSchedule()\n");
return MPStatus;
}
-
+
+ //Command.RunStop =1;
+ //WRITE_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD, Command.AsULONG );
//DPRINT1("XHCI_StartController: UNIMPLEMENTED. FIXME\n");
return MP_STATUS_SUCCESS;
}
@@ -247,13 +300,14 @@
NTAPI
XHCI_SuspendController(IN PVOID xhciExtension)
{
-
+ DPRINT1("XHCI_SuspendController: function initiated\n");
}
MPSTATUS
NTAPI
XHCI_ResumeController(IN PVOID xhciExtension)
{
+ DPRINT1("XHCI_ResumeController: function initiated\n");
return MP_STATUS_SUCCESS;
}
@@ -262,6 +316,7 @@
XHCI_HardwarePresent(IN PXHCI_EXTENSION xhciExtension,
IN BOOLEAN IsInvalidateController)
{
+ DPRINT1("XHCI_HardwarePresent: function initiated\n");
return TRUE;
}
@@ -269,6 +324,29 @@
NTAPI
XHCI_InterruptService(IN PVOID xhciExtension)
{
+ DPRINT1("XHCI_InterruptService: function initiated\n");
+ XHCI_RT_REGISTER_SPACE_OFFSET RTSOffsetRegister;
+ PULONG RunTimeRegisterBase;
+ XHCI_INTERRUPTER_MANAGEMENT Iman;
+ PXHCI_EXTENSION XhciExtension;
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ XHCI_EVENT_RING_DEQUEUE_POINTER erstdp;
+
+ RunTimeRegisterBase = XhciExtension-> RunTimeRegisterBase;
+
+ Iman.AsULONG = READ_REGISTER_ULONG(RunTimeRegisterBase + XHCI_IMAN);
+
+ Iman.InterruptPending =0;
+
+ WRITE_REGISTER_ULONG(RunTimeRegisterBase + XHCI_IMAN, Iman.AsULONG);
+ DPRINT1("XHCI_InterruptService: Succesful Interupt\n");
+ // changing the enque pointer
+ erstdp.AsULONGLONG = READ_REGISTER_ULONG(RunTimeRegisterBase + XHCI_ERSTDP +
1)||READ_REGISTER_ULONG(RunTimeRegisterBase + XHCI_ERSTDP);
+ erstdp.AsULONGLONG = erstdp.AsULONGLONG +2;
+ erstdp.DequeueERSTIndex =0;
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP, erstdp.AsULONGLONG);
+ WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP + 1, erstdp.AsULONGLONG
>> 32);
+
return TRUE;
}
@@ -277,7 +355,7 @@
XHCI_InterruptDpc(IN PVOID xhciExtension,
IN BOOLEAN IsDoEnableInterrupts)
{
-
+ DPRINT1("XHCI_InterruptDpc: function initiated\n");
}
MPSTATUS
@@ -288,7 +366,7 @@
IN PVOID xhciTransfer,
IN PVOID sgList)
{
-
+ DPRINT1("XHCI_SubmitTransfer: function initiated\n");
return MP_STATUS_SUCCESS;
}
@@ -319,7 +397,7 @@
IN PXHCI_ENDPOINT xhciEndpoint,
IN PXHCI_TRANSFER xhciTransfer)
{
-
+ DPRINT1("XHCI_AbortAsyncTransfer: function initiated\n");
}
VOID
@@ -329,7 +407,7 @@
IN PVOID xhciTransfer,
IN PULONG CompletedLength)
{
-
+ DPRINT1("XHCI_AbortTransfer: function initiated\n");
}
ULONG
@@ -347,7 +425,7 @@
IN PVOID xhciEndpoint,
IN ULONG EndpointState)
{
-
+ DPRINT1("XHCI_SetEndpointState: function initiated\n");
}
VOID
@@ -355,20 +433,21 @@
XHCI_PollEndpoint(IN PVOID xhciExtension,
IN PVOID xhciEndpoint)
{
-
+ DPRINT1("XHCI_PollEndpoint: function initiated\n");
}
VOID
NTAPI
XHCI_CheckController(IN PVOID xhciExtension)
{
-
+ DPRINT1("XHCI_CheckController: function initiated\n");
}
ULONG
NTAPI
XHCI_Get32BitFrameNumber(IN PVOID xhciExtension)
{
+ DPRINT1("XHCI_Get32BitFrameNumber: function initiated\n");
return 0;
}
@@ -376,27 +455,40 @@
NTAPI
XHCI_InterruptNextSOF(IN PVOID xhciExtension)
{
-
+ DPRINT1("XHCI_InterruptNextSOF: function initiated\n");
}
VOID
NTAPI
XHCI_EnableInterrupts(IN PVOID xhciExtension)
{
-
+ DPRINT1("XHCI_EnableInterrupts: function initiated\n");
+ PXHCI_EXTENSION XhciExtension;
+ PULONG OperationalRegs;
+ XHCI_USB_COMMAND usbCommand;
+
+ XhciExtension = (PXHCI_EXTENSION)xhciExtension;
+ OperationalRegs = XhciExtension->OperationalRegs;
+ usbCommand.AsULONG =READ_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD);
+
+ usbCommand.InterrupterEnable = 1;
+
+ WRITE_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD,usbCommand.AsULONG );
+ DPRINT1("XHCI_EnableInterrupts: Interrupts enabled\n");
}
VOID
NTAPI
XHCI_DisableInterrupts(IN PVOID xhciExtension)
{
+ DPRINT1("XHCI_DisableInterrupts: function initiated\n");
}
VOID
NTAPI
XHCI_PollController(IN PVOID xhciExtension)
{
-
+ DPRINT1("XHCI_PollController: function initiated\n");
}
VOID
@@ -405,7 +497,7 @@
IN PVOID xhciEndpoint,
IN ULONG DataToggle)
{
-
+ DPRINT1("XHCI_SetEndpointDataToggle: function initiated\n");
}
ULONG
@@ -413,7 +505,7 @@
XHCI_GetEndpointStatus(IN PVOID xhciExtension,
IN PVOID xhciEndpoint)
{
-
+ DPRINT1("XHCI_GetEndpointStatus: function initiated\n");
return 0;
}
@@ -423,6 +515,7 @@
IN PVOID xhciEndpoint,
IN ULONG EndpointStatus)
{
+ DPRINT1("XHCI_SetEndpointStatus: function initiated\n");
}
MPSTATUS
@@ -479,7 +572,7 @@
NTAPI
XHCI_FlushInterrupts(IN PVOID xhciExtension)
{
-
+ DPRINT1("XHCI_FlushInterrupts: function initiated\n");
}
MPSTATUS
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 Jul
6 07:36:05 2017
@@ -4,7 +4,6 @@
#include <ntddk.h>
#include <windef.h>
#include <stdio.h>
-#include <wdm.h>
#include <hubbusif.h>
#include <usbbusif.h>
#include <usbdlib.h>
@@ -161,13 +160,40 @@
XHCI_CONTROL_STATUS_TRB StatusTRB[4];
} XHCI_CONTROL_TRB, *PXHCI_CONTROL_TRB;
-
+//----------------event strucs-------------------
+typedef struct _XHCI_EVENT_TRB {
+ ULONG Word0;
+ ULONG Word1;
+ ULONG Word2;
+ ULONG Word3;
+}XHCI_EVENT_TRB, *PXHCI_EVENT_TRB;
+
+typedef struct _XHCI_EVENT_RING_SEGMENT_TABLE{
+ ULONGLONG RingSegmentBaseAddr;
+ ULONGLONG RingSegmentSize : 16;
+ ULONGLONG RsvdZ : 48;
+
+} XHCI_EVENT_RING_SEGMENT_TABLE;
//------------------------------------main structs-----------------------
+
+typedef union _XHCI_TRB {
+ XHCI_COMMAND_TRB CommandTRB;
+ XHCI_LINK_TRB LinkTRB;
+ XHCI_CONTROL_TRB ControlTRB;
+ XHCI_EVENT_TRB EventTRB;
+} XHCI_TRB, *PXHCI_TRB;
+
+typedef struct _XHCI_RING {
+ XHCI_TRB ring[16];
+ //PXHCI_TRB dequeue_pointer;
+}XHCI_RING , *PXHCI_RING;
+
typedef struct _XHCI_EXTENSION {
ULONG Reserved;
ULONG Flags;
PULONG BaseIoAdress;
PULONG OperationalRegs;
+ PULONG RunTimeRegisterBase;
UCHAR FrameLengthAdjustment;
BOOLEAN IsStarted;
USHORT HcSystemErrors;
@@ -180,6 +206,8 @@
typedef struct _XHCI_HC_RESOURCES {
XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY DCBAA;
XHCI_COMMAND_RING CommandRing;
+ XHCI_RING EventRing;
+ XHCI_EVENT_RING_SEGMENT_TABLE EventRingSegTable;
} XHCI_HC_RESOURCES, *PXHCI_HC_RESOURCES;
typedef struct _XHCI_ENDPOINT {