USB stack adapted from Linux 2.6.14.3.
Currently compiles with mingw and msvc, produces *lots* of warnings and doesn't work properly.
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/cleanup.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/close.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/common.xml
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/create.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/fdo.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/main.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/misc.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/pdo.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon_types.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/directory.xml
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/asm/bitops.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/bitops.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/cromwell_types.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/linux_wrapper.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/list.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/pci_hal.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/usb.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/usb_ch9.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/sys/linuxwrapper.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/sys/sys.xml
Modified: branches/usb2_6/reactos/drivers/usb/miniport/usb_wrapper.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/usbuhci/uhci-hcd.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/usbuhci/uhci-hcd.h
Modified: branches/usb2_6/reactos/drivers/usb/miniport/usbuhci/uhci-hub.c
Added: branches/usb2_6/reactos/drivers/usb/miniport/usbuhci/uhci-q.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/usbuhci/uhci.c
Modified: branches/usb2_6/reactos/drivers/usb/miniport/usbuhci/usbuhci.xml
Modified: branches/usb2_6/reactos/drivers/usb/usbhub/fdo.c
Modified: branches/usb2_6/reactos/drivers/usb/usbhub/usbhub.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/buffer_simple.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/config.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/core_drivers/usbkey.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/core_drivers/usbmouse.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/hcd-pci.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/hcd.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/hcd.h
Modified: branches/usb2_6/reactos/drivers/usb/usbport/hub.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/hub.h
Modified: branches/usb2_6/reactos/drivers/usb/usbport/message.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/urb.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/usb-debug.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/usb.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/usb.h
Modified: branches/usb2_6/reactos/drivers/usb/usbport/usbcore.c
Modified: branches/usb2_6/reactos/drivers/usb/usbport/usbcore.rc
Modified: branches/usb2_6/reactos/drivers/usb/usbport/usbport.def
Added: branches/usb2_6/reactos/drivers/usb/usbport/usbport.mingw.def
Modified: branches/usb2_6/reactos/drivers/usb/usbport/usbport.xml

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/cleanup.c
--- branches/usb2_6/reactos/drivers/usb/miniport/common/cleanup.c	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/cleanup.c	2006-01-08 09:24:55 UTC (rev 20702)
@@ -8,8 +8,6 @@
  */
 
 #define NDEBUG
-#include <debug.h>
-
 #include "usbcommon.h"
 
 NTSTATUS STDCALL

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/close.c
--- branches/usb2_6/reactos/drivers/usb/miniport/common/close.c	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/close.c	2006-01-08 09:24:55 UTC (rev 20702)
@@ -8,8 +8,6 @@
  */
 
 #define NDEBUG
-#include <debug.h>
-
 #include "usbcommon.h"
 
 NTSTATUS STDCALL

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/common.xml
--- branches/usb2_6/reactos/drivers/usb/miniport/common/common.xml	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/common.xml	2006-01-08 09:24:55 UTC (rev 20702)
@@ -1,4 +1,4 @@
-<module name="usbminiportcommon" type="objectlibrary">
+<module name="usbminiportcommon" type="objectlibrary" allowwarnings="true">
 	<define name="__USE_W32API" />
 	<include>../linux</include>
 	<include base="usbport">.</include>

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/create.c
--- branches/usb2_6/reactos/drivers/usb/miniport/common/create.c	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/create.c	2006-01-08 09:24:55 UTC (rev 20702)
@@ -8,8 +8,6 @@
  */
 
 #define NDEBUG
-#include <debug.h>
-
 #include "usbcommon.h"
 
 NTSTATUS STDCALL

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/fdo.c
--- branches/usb2_6/reactos/drivers/usb/miniport/common/fdo.c	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/fdo.c	2006-01-08 09:24:55 UTC (rev 20702)
@@ -8,9 +8,7 @@
  *                  James Tabor (jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net)
  */
 
-#define NDEBUG
-#include <debug.h>
-
+//#define NDEBUG
 #include "usbcommon.h"
 
 #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
@@ -48,6 +46,35 @@
 	}
 }
 
+BOOLEAN STDCALL
+HciInterruptService(IN PKINTERRUPT Interrupt,
+					IN OUT PVOID ServiceContext)
+{
+	DPRINT1("USBMP Interrupt\n");
+	return FALSE;
+}
+
+static VOID
+UsbMpRegisterIsr(PDEVICE_OBJECT DeviceObject)
+{
+	NTSTATUS Status;
+	PUSBMP_DEVICE_EXTENSION DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+	/* Connect interrupt and enable them */
+	DPRINT("IoConnectInterrupt: vec=0x%x,lev=0x%x,mode=0x%x,aff=0x%x\n", DeviceExtension->InterruptVector, DeviceExtension->InterruptLevel, DeviceExtension->InterruptMode, DeviceExtension->InterruptAffinity);
+	Status = IoConnectInterrupt(
+		&DeviceExtension->InterruptObject, (PKSERVICE_ROUTINE)HciInterruptService,
+		DeviceObject, NULL,
+		DeviceExtension->InterruptVector, DeviceExtension->InterruptLevel, DeviceExtension->InterruptLevel,
+		DeviceExtension->InterruptMode, DeviceExtension->InterruptShare,
+		DeviceExtension->InterruptAffinity, FALSE);
+	if (!NT_SUCCESS(Status))
+	{
+		DPRINT1("usbmp: IoConnectInterrupt() failed with status 0x%08x\n", Status);
+		return;
+	}
+}
+
 NTSTATUS STDCALL
 UsbMpFdoStartDevice(
 	IN PDEVICE_OBJECT DeviceObject,
@@ -74,7 +101,7 @@
 	/*
 	* Store	some resources in the DeviceExtension.
 	*/
-	AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
+	AllocatedResources = Stack->Parameters.StartDevice.AllocatedResourcesTranslated;
 	if (AllocatedResources != NULL)
 	{
 		CM_FULL_RESOURCE_DESCRIPTOR    *FullList;
@@ -116,6 +143,14 @@
 				{
 					DeviceExtension->InterruptLevel  = Descriptor->u.Interrupt.Level;
 					DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
+					DeviceExtension->InterruptAffinity = Descriptor->u.Interrupt.Affinity;
+					if (Descriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
+						DeviceExtension->InterruptMode = Latched;
+					else
+						DeviceExtension->InterruptMode = LevelSensitive;
+
+					DeviceExtension->InterruptShare = (Descriptor->ShareDisposition == CmResourceShareShared);
+
 				}
 				else if (Descriptor->Type == CmResourceTypePort)
 				{
@@ -144,6 +179,11 @@
 		DeviceExtension->BaseAddress,
 		DeviceExtension->BaseAddrLength);
 
+	/* Register Interrupt Service Routine */
+	UsbMpRegisterIsr(DeviceObject);
+
+	/* Acquire some information about the placement of the controller in the bus */
+
 	/* Get bus number from the upper level bus driver. */
 	Size = sizeof(ULONG);
 	Status = IoGetDeviceProperty(
@@ -161,6 +201,23 @@
 
 	DPRINT("USBMP: Busnumber %d\n", DeviceExtension->SystemIoBusNumber);
 
+	/* Get bus device address from the upper level bus driver. */
+	Size = sizeof(ULONG);
+	IoGetDeviceProperty(
+		DeviceExtension->PhysicalDeviceObject,
+		DevicePropertyAddress,
+		Size,
+		&DeviceExtension->SystemIoSlotNumber,
+		&Size);
+
+	if (!NT_SUCCESS(Status))
+	{
+		DPRINT1("USBMP: IoGetDeviceProperty DevicePropertyAddress failed\n");
+		DeviceExtension->SystemIoSlotNumber = 0;
+	}
+
+	DPRINT("USBMP: Slotnumber 0x%x\n", DeviceExtension->SystemIoSlotNumber);
+
 	/* Init wrapper with this object */
 	return InitLinuxWrapper(DeviceObject);
 }

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/main.c
--- branches/usb2_6/reactos/drivers/usb/miniport/common/main.c	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/main.c	2006-01-08 09:24:55 UTC (rev 20702)
@@ -12,8 +12,6 @@
  */
 
 #define NDEBUG
-#include <debug.h>
-
 #define INITGUID
 #include "usbcommon.h"
 
@@ -197,8 +195,7 @@
 	UNICODE_STRING LinkDeviceName;
 	PUSBMP_DRIVER_EXTENSION DriverExtension;
 	PUSBMP_DEVICE_EXTENSION DeviceExtension;
-	static ULONG DeviceNumber = 0;
-	BOOL AlreadyRestarted = FALSE;
+	ULONG DeviceNumber;
 
 	// Allocate driver extension now
 	DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
@@ -217,33 +214,18 @@
 		}
 	}
 
-	/* Create a unicode device name. Allocate a new device number every time */
-	do
-	{
-		DeviceNumber++;
-		if (DeviceNumber == 9999)
-		{
-			/* Hmm. We don't have a free number. */ 
-			if (AlreadyRestarted)
-			{
-				Status = STATUS_UNSUCCESSFUL;
-				break;
-			}
-			/* Start again at DeviceNumber = 0 to find a free number */
-			DeviceNumber = 0;
-			AlreadyRestarted = TRUE;
-		}
-		swprintf(DeviceBuffer, L"\\Device\\USBFDO-%lu", DeviceNumber);
-		RtlInitUnicodeString(&DeviceName, DeviceBuffer);
+	// Create a unicode device name
+	DeviceNumber = 0; //TODO: Allocate new device number every time
+	swprintf(DeviceBuffer, L"\\Device\\USBFDO-%lu", DeviceNumber);
+	RtlInitUnicodeString(&DeviceName, DeviceBuffer);
 
-		Status = IoCreateDevice(DriverObject,
-					sizeof(USBMP_DEVICE_EXTENSION),
-					&DeviceName,
-					FILE_DEVICE_BUS_EXTENDER,
-					0,
-					FALSE,
-					&fdo);
-	} while (Status == STATUS_OBJECT_NAME_COLLISION);
+	Status = IoCreateDevice(DriverObject,
+				sizeof(USBMP_DEVICE_EXTENSION),
+				&DeviceName,
+				FILE_DEVICE_BUS_EXTENDER,
+				0,
+				FALSE,
+				&fdo);
 
 	if (!NT_SUCCESS(Status))
 	{
@@ -414,19 +396,19 @@
 	USBPORT_INTERFACE UsbPortInterface;
 	ULONG i;
 
-	DriverObject->DriverUnload = DriverUnload;
-	DriverObject->DriverExtension->AddDevice = AddDevice;
+	DriverObject->DriverUnload = (PDRIVER_UNLOAD)DriverUnload;
+	DriverObject->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)AddDevice;
 
-	for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
-		DriverObject->MajorFunction[i] = IrpStub;
+	for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
+		DriverObject->MajorFunction[i] = (PDRIVER_DISPATCH)IrpStub;
 
-	DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
-	DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
-	DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup;
-	DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl;
-	DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = DispatchInternalDeviceControl;
-	DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
-	DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
+	DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH)DispatchCreate;
+	DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH)DispatchClose;
+	DriverObject->MajorFunction[IRP_MJ_CLEANUP] = (PDRIVER_DISPATCH)DispatchCleanup;
+	DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = (PDRIVER_DISPATCH)DispatchDeviceControl;
+	DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = (PDRIVER_DISPATCH)DispatchInternalDeviceControl;
+	DriverObject->MajorFunction[IRP_MJ_PNP] = (PDRIVER_DISPATCH)DispatchPnp;
+	DriverObject->MajorFunction[IRP_MJ_POWER] = (PDRIVER_DISPATCH)DispatchPower;
 
 	// Register in usbcore.sys
 	UsbPortInterface.KbdConnectData = &KbdClassInformation;

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/misc.c
--- branches/usb2_6/reactos/drivers/usb/miniport/common/misc.c	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/misc.c	2006-01-08 09:24:55 UTC (rev 20702)
@@ -8,8 +8,6 @@
  */
 
 #define NDEBUG
-#include <debug.h>
-
 #include "usbcommon.h"
 #include <stdarg.h>
 
@@ -39,7 +37,7 @@
 	IoCopyCurrentIrpStackLocationToNext(Irp);
 
 	DPRINT("USBMP: Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
-	IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
+	IoSetCompletionRoutine(Irp, (PIO_COMPLETION_ROUTINE)ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
 
 	Status = IoCallDriver(LowerDevice, Irp);
 	if (Status == STATUS_PENDING)

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/pdo.c
--- branches/usb2_6/reactos/drivers/usb/miniport/common/pdo.c	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/pdo.c	2006-01-08 09:24:55 UTC (rev 20702)
@@ -9,8 +9,6 @@
  */
 
 #define NDEBUG
-#include <debug.h>
-
 #include "usbcommon.h"
 
 extern struct usb_driver hub_driver;
@@ -87,7 +85,8 @@
 	DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 	RtlInitUnicodeString(&String, NULL);
 	DeviceExtension = (PUSBMP_DEVICE_EXTENSION)DeviceExtension->FunctionalDeviceObject->DeviceExtension;
-	roothub = ((struct usb_hcd*)DeviceExtension->pdev->data)->self.root_hub;
+	//roothub = ((struct usb_hcd*)DeviceExtension->pdev->data)->self.root_hub;
+	roothub = hcd_to_bus(DeviceExtension->pdev->data)->root_hub;
 
 	switch (IdType)
 	{
@@ -297,7 +296,7 @@
 					
 					DPRINT("USBMP: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
 					
-					Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &SourceString, &Description);
+					Status = _RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &SourceString, &Description);
 					if (NT_SUCCESS(Status))
 						Information = (ULONG_PTR)Description.Buffer;
 					break;

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon.h
--- branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon.h	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon.h	2006-01-08 09:24:55 UTC (rev 20702)
@@ -12,6 +12,10 @@
 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
 #define USB_MINIPORT_TAG TAG('u','s','b','m')
 
+#ifndef RTL_CONSTANT_STRING
+#define RTL_CONSTANT_STRING(s) { sizeof(s) - sizeof((s)[0]), sizeof(s), s }
+#endif
+
 #include "../../usbport/hcd.h"
 #include "usbcommon_types.h"
 

Modified: branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon_types.h
--- branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon_types.h	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/common/usbcommon_types.h	2006-01-08 09:24:55 UTC (rev 20702)
@@ -6,7 +6,7 @@
    //OHCI_HW_INITIALIZATION_DATA InitializationData;
    //PVOID HwContext;
    //UNICODE_STRING RegistryPath;
-
+   void *dummy;
 } USBMP_DRIVER_EXTENSION, *PUSBMP_DRIVER_EXTENSION;
 
 typedef struct _USBMP_DEVICE_EXTENSTION

Modified: branches/usb2_6/reactos/drivers/usb/miniport/directory.xml
--- branches/usb2_6/reactos/drivers/usb/miniport/directory.xml	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/directory.xml	2006-01-08 09:24:55 UTC (rev 20702)
@@ -6,10 +6,10 @@
 </directory>
 <!--directory name="usbehci">
 	<xi:include href="usbehci/usbehci.xml" />
-</directory-->
+</directory
 <directory name="usbohci">
 	<xi:include href="usbohci/usbohci.xml" />
-</directory>
+</directory>-->
 <directory name="usbuhci">
 	<xi:include href="usbuhci/usbuhci.xml" />
 </directory>

Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/asm/bitops.h
--- branches/usb2_6/reactos/drivers/usb/miniport/linux/asm/bitops.h	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/linux/asm/bitops.h	2006-01-08 09:24:55 UTC (rev 20702)
@@ -33,12 +33,24 @@
  * Note that @nr may be almost arbitrarily large; this function is not
  * restricted to acting on a single-word quantity.
  */
-static __inline__ void set_bit(int nr, volatile void * addr)
+static __inline void set_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	__asm__ __volatile__( LOCK_PREFIX
 		"btsl %1,%0"
 		:"=m" (ADDR)
 		:"Ir" (nr));
+#elif defined(_MSC_VER)
+	__asm {
+           mov eax, nr
+           mov ecx, addr
+           lock bts [ecx], eax
+           setc al
+    };
+#else
+	InterlockedBitTestAndSet(addr, nr);
+#endif
+
 }
 
 /**
@@ -50,12 +62,18 @@
  * If it's called on the same region of memory simultaneously, the effect
  * may be that only one operation succeeds.
  */
-static __inline__ void __set_bit(int nr, volatile void * addr)
+static __inline void __set_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	__asm__(
 		"btsl %1,%0"
 		:"=m" (ADDR)
 		:"Ir" (nr));
+#elif defined(_MSC_VER)
+	set_bit(nr, addr);
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /**
@@ -68,12 +86,22 @@
  * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
  * in order to ensure changes are visible on other processors.
  */
-static __inline__ void clear_bit(int nr, volatile void * addr)
+static __inline void clear_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	__asm__ __volatile__( LOCK_PREFIX
 		"btrl %1,%0"
 		:"=m" (ADDR)
 		:"Ir" (nr));
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           lock btr [ecx], eax
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 #define smp_mb__before_clear_bit()	barrier()
 #define smp_mb__after_clear_bit()	barrier()
@@ -87,12 +115,22 @@
  * If it's called on the same region of memory simultaneously, the effect
  * may be that only one operation succeeds.
  */
-static __inline__ void __change_bit(int nr, volatile void * addr)
+static __inline void __change_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	__asm__ __volatile__(
 		"btcl %1,%0"
 		:"=m" (ADDR)
 		:"Ir" (nr));
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           btc [ecx], eax
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /**
@@ -104,12 +142,22 @@
  * Note that @nr may be almost arbitrarily large; this function is not
  * restricted to acting on a single-word quantity.
  */
-static __inline__ void change_bit(int nr, volatile void * addr)
+static __inline void change_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	__asm__ __volatile__( LOCK_PREFIX
 		"btcl %1,%0"
 		:"=m" (ADDR)
 		:"Ir" (nr));
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           lock btc [ecx], eax
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /**
@@ -120,15 +168,27 @@
  * This operation is atomic and cannot be reordered.  
  * It also implies a memory barrier.
  */
-static __inline__ int test_and_set_bit(int nr, volatile void * addr)
+static __inline int test_and_set_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	int oldbit;
 
 	__asm__ __volatile__( LOCK_PREFIX
 		"btsl %2,%1\n\tsbbl %0,%0"
 		:"=r" (oldbit),"=m" (ADDR)
 		:"Ir" (nr) : "memory");
+
 	return oldbit;
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           lock bts [ecx], eax
+           setc al
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /**
@@ -140,8 +200,9 @@
  * If two examples of this operation race, one can appear to succeed
  * but actually fail.  You must protect multiple accesses with a lock.
  */
-static __inline__ int __test_and_set_bit(int nr, volatile void * addr)
+static __inline int __test_and_set_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	int oldbit;
 
 	__asm__(
@@ -149,6 +210,16 @@
 		:"=r" (oldbit),"=m" (ADDR)
 		:"Ir" (nr));
 	return oldbit;
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           lock bts [ecx], eax
+           setc al
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /**
@@ -159,8 +230,9 @@
  * This operation is atomic and cannot be reordered.  
  * It also implies a memory barrier.
  */
-static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
+static __inline int test_and_clear_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	int oldbit;
 
 	__asm__ __volatile__( LOCK_PREFIX
@@ -168,6 +240,16 @@
 		:"=r" (oldbit),"=m" (ADDR)
 		:"Ir" (nr) : "memory");
 	return oldbit;
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           lock btr [ecx], eax
+           setc al
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /**
@@ -179,8 +261,9 @@
  * If two examples of this operation race, one can appear to succeed
  * but actually fail.  You must protect multiple accesses with a lock.
  */
-static __inline__ int __test_and_clear_bit(int nr, volatile void * addr)
+static __inline int __test_and_clear_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	int oldbit;
 
 	__asm__(
@@ -188,11 +271,22 @@
 		:"=r" (oldbit),"=m" (ADDR)
 		:"Ir" (nr));
 	return oldbit;
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           lock btr [ecx], eax
+           setc al
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /* WARNING: non atomic and it can be reordered! */
-static __inline__ int __test_and_change_bit(int nr, volatile void * addr)
+static __inline int __test_and_change_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	int oldbit;
 
 	__asm__ __volatile__(
@@ -200,6 +294,16 @@
 		:"=r" (oldbit),"=m" (ADDR)
 		:"Ir" (nr) : "memory");
 	return oldbit;
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           btc [ecx], eax
+           setc al
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 /**
@@ -210,8 +314,9 @@
  * This operation is atomic and cannot be reordered.  
  * It also implies a memory barrier.
  */
-static __inline__ int test_and_change_bit(int nr, volatile void * addr)
+static __inline int test_and_change_bit(int nr, volatile void * addr)
 {
+#if defined(__GNUC__)
 	int oldbit;
 
 	__asm__ __volatile__( LOCK_PREFIX
@@ -219,6 +324,16 @@
 		:"=r" (oldbit),"=m" (ADDR)
 		:"Ir" (nr) : "memory");
 	return oldbit;
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           btc [ecx], eax
+           setc al
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
 }
 
 #if 0 /* Fool kernel-doc since it doesn't do macros yet */
@@ -230,26 +345,42 @@
 static int test_bit(int nr, const volatile void * addr);
 #endif
 
-static __inline__ int constant_test_bit(int nr, const volatile void * addr)
+static __inline int constant_test_bit(int nr, const volatile void * addr)
 {
 	return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
 }
 
-static __inline__ int variable_test_bit(int nr, volatile void * addr)
+static __inline int variable_test_bit(int nr, volatile void * addr)
 {
 	int oldbit;
-
+#if defined(__GNUC__)
 	__asm__ __volatile__(
 		"btl %2,%1\n\tsbbl %0,%0"
 		:"=r" (oldbit)
 		:"m" (ADDR),"Ir" (nr));
+#elif defined(_MSC_VER)
+    __asm {
+           mov eax, nr
+           mov ecx, addr
+           bt [ecx], eax
+		   setc al
+           //mov oldbit, al
+    };
+#else
+#error Unknown compiler for inline assembler
+#endif
+
 	return oldbit;
 }
 
+/*
 #define test_bit(nr,addr) \
 (__builtin_constant_p(nr) ? \
  constant_test_bit((nr),(addr)) : \
  variable_test_bit((nr),(addr)))
+ */
+#define test_bit(nr,addr) \
+( variable_test_bit( (nr),(addr) ) )
 
 /**
  * find_first_zero_bit - find the first zero bit in a memory region
@@ -259,7 +390,8 @@
  * Returns the bit-number of the first zero bit, not the number of the byte
  * containing a bit.
  */
-static __inline__ int find_first_zero_bit(void * addr, unsigned size)
+#if defined(__GNUC__)
+static __inline int find_first_zero_bit(void * addr, unsigned size)
 {
 	int d0, d1, d2;
 	int res;
@@ -282,14 +414,43 @@
 		:"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
 	return res;
 }
+#elif defined(_MSC_VER)
+#define find_first_zero_bit(addr, size) \
+	find_next_zero_bit((addr), (size), 0)
+#else
+#error Unknown compiler for inline assembler
+#endif
 
 /**
+ * ffz - find first zero in word.
+ * @word: The word to search
+ *
+ * Undefined if no zero exists, so code should check against ~0UL first.
+ */
+static __inline unsigned long ffz(unsigned long word)
+{
+#if defined(__GNUC__)
+	__asm__("bsfl %1,%0"
+		:"=r" (word)
+		:"r" (~word));
+	return word;
+#elif defined(_MSC_VER)
+	ULONG index;
+	BitScanForward(&index, ~word);
+	return index;
+#else
+#error Unknown compiler for inline assembler
+#endif
+}
+
+/**
  * find_next_zero_bit - find the first zero bit in a memory region
  * @addr: The address to base the search on
  * @offset: The bitnumber to start searching at
  * @size: The maximum size to search
  */
-static __inline__ int find_next_zero_bit (void * addr, int size, int offset)
+#if defined(__GNUC__)
+static __inline int find_next_zero_bit (void * addr, int size, int offset)
 {
 	unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
 	int set = 0, bit = offset & 31, res;
@@ -315,20 +476,47 @@
 	res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr));
 	return (offset + set + res);
 }
+#elif defined(_MSC_VER)
+static __inline unsigned long find_next_zero_bit(const void *addr, unsigned long size, unsigned long offset)
+{
+	const unsigned long *p = addr;
+	unsigned long result = offset & ~63UL;
+	unsigned long tmp;
 
-/**
- * ffz - find first zero in word.
- * @word: The word to search
- *
- * Undefined if no zero exists, so code should check against ~0UL first.
- */
-static __inline__ unsigned long ffz(unsigned long word)
-{
-	__asm__("bsfl %1,%0"
-		:"=r" (word)
-		:"r" (~word));
-	return word;
+	p += offset >> 6;
+	if (offset >= size)
+		return size;
+	size -= result;
+	offset &= 63UL;
+	if (offset) {
+		tmp = *(p++);
+		tmp |= ~0UL >> (64-offset);
+		if (size < 64)
+			goto found_first;
+		if (~tmp)
+			goto found_middle;
+		size -= 64;
+		result += 64;
+	}
+	while (size & ~63UL) {
+		if (~(tmp = *(p++)))
+			goto found_middle;
+		result += 64;
+		size -= 64;
+	}
+	if (!size)
+		return result;
+	tmp = *p;
+ found_first:
+	tmp |= ~0UL << size;
+	if (tmp == ~0UL)        /* Are any bits zero? */
+		return result + size; /* Nope. */
+ found_middle:
+	return result + ffz(tmp);
 }
+#else
+#error Unknown compiler for inline assembler
+#endif
 
 #ifdef __KERNEL__
 

Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/bitops.h
--- branches/usb2_6/reactos/drivers/usb/miniport/linux/bitops.h	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/linux/bitops.h	2006-01-08 09:24:55 UTC (rev 20702)
@@ -1,6 +1,27 @@
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
 
+/**
+ * __ffs - find first bit in word.
+ * @word: The word to search
+ *
+ * Undefined if no bit exists, so code should check against 0 first.
+ */
+static __inline unsigned long __ffs(unsigned long wrd)
+{
+#if defined(__GNUC__)
+	__asm__("bsfl %1,%0"
+		:"=r" (wrd)
+		:"rm" (wrd));
+#elif defined(_MSC_VER)
+	__asm mov eax, wrd;
+	__asm bsf eax, eax;
+	__asm mov wrd, eax;
+#else
+#error Unknown compiler for inline assembler
+#endif
+	return wrd;
+}
 
 /*
  * ffs: find first bit set. This is defined the same way as
@@ -8,7 +29,7 @@
  * differs in spirit from the above ffz (man ffs).
  */
 
-static inline int generic_ffs(int x)
+static __inline int generic_ffs(int x)
 {
 	int r = 1;
 
@@ -42,7 +63,7 @@
  * of bits set) of a N-bit word
  */
 
-static inline unsigned int generic_hweight32(unsigned int w)
+static __inline unsigned int generic_hweight32(unsigned int w)
 {
         unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
         res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
@@ -51,7 +72,7 @@
         return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
 }
 
-static inline unsigned int generic_hweight16(unsigned int w)
+static __inline unsigned int generic_hweight16(unsigned int w)
 {
         unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
         res = (res & 0x3333) + ((res >> 2) & 0x3333);
@@ -59,7 +80,7 @@
         return (res & 0x00FF) + ((res >> 8) & 0x00FF);
 }
 
-static inline unsigned int generic_hweight8(unsigned int w)
+static __inline unsigned int generic_hweight8(unsigned int w)
 {
         unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
         res = (res & 0x33) + ((res >> 2) & 0x33);

Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/cromwell_types.h
--- branches/usb2_6/reactos/drivers/usb/miniport/linux/cromwell_types.h	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/linux/cromwell_types.h	2006-01-08 09:24:55 UTC (rev 20702)
@@ -5,9 +5,25 @@
 // some typedefs to make for easy sizing
 
 //typedef unsigned long ULONG;
+typedef long long u64;
 typedef unsigned int u32;
 typedef unsigned short u16;
 typedef unsigned char u8;
+
+typedef unsigned int __u32;
+typedef unsigned short __u16;
+typedef unsigned char __u8;
+
+// we don't care much about big-endian
+typedef unsigned int __le32;
+typedef unsigned short __le16;
+typedef unsigned char __le8;
+
+
+typedef short s16;
+
+typedef u32 dma_addr_t;
+
 #ifndef bool_already_defined_
 	typedef int bool;
 #endif
@@ -24,4 +40,9 @@
 #define NULL ((void *)0)
 #endif
 
+#define __iomem
+#define __user
+
+typedef u32 uid_t;
+
 #endif /* #ifndef cromwell_types_h */

Modified: branches/usb2_6/reactos/drivers/usb/miniport/linux/linux_wrapper.h
--- branches/usb2_6/reactos/drivers/usb/miniport/linux/linux_wrapper.h	2006-01-08 09:00:02 UTC (rev 20701)
+++ branches/usb2_6/reactos/drivers/usb/miniport/linux/linux_wrapper.h	2006-01-08 09:24:55 UTC (rev 20702)
@@ -11,6 +11,7 @@
  * macros
  *
  * All structs and prototypes are based on kernel source 2.5.72
+ *                                                       2.6.14.3
  *
  * Modified by Aleksey Bragin (aleksey@reactos.com) for ReactOS needs
  *
@@ -23,17 +24,6 @@
 /*------------------------------------------------------------------------*/ 
 #include "cromwell_types.h"
 
-typedef unsigned int __u32;
-//typedef __u32 u32;
-typedef unsigned short __u16;
-//typedef __u16 u16;
-typedef unsigned char __u8;
-//typedef __u8 u8;
-
-typedef short s16;
-
-typedef u32 dma_addr_t;
-
 typedef struct
 {
 	KSPIN_LOCK SpinLock;
@@ -59,7 +49,7 @@
 typedef int irqreturn_t;
 typedef unsigned long kernel_ulong_t;
 
-typedef int wait_queue_head_t;
+typedef KEVENT wait_queue_head_t;
 /*------------------------------------------------------------------------*/ 
 /* Stuff from xbox/linux environment */
 /*------------------------------------------------------------------------*/ 
@@ -93,7 +83,7 @@
 extern int memcmp(const void *,const void *,unsigned int);
 
 #else
-#include "boot.h"
+//#include "boot.h"
 #include "config.h"
 #endif
 #else
@@ -109,6 +99,9 @@
 /*------------------------------------------------------------------------*/ 
 
 struct timer_list { 
+	PKTIMER kTimer;
+	PKDPC kDPC;
+	// usual stuff
 	void (*function)(unsigned long);
 	unsigned long data;
 	int expires;
@@ -137,17 +130,25 @@
 struct device_driver{
 	char *name;
 	struct bus_type *bus;
+	int owner;
 	int     (*probe)        (struct device * dev);
         int     (*remove)       (struct device * dev);
 	struct list_head        devices;
 };
 
+typedef struct pm_message {
+	int event;
+} pm_message_t;
+
 struct bus_type {
         char                    * name;       
         int             (*match)(struct device * dev, struct device_driver * drv);
-        struct device * (*add)  (struct device * parent, char * bus_id);
-        int             (*hotplug) (struct device *dev, char **envp, 
-                                    int num_envp, char *buffer, int buffer_size);
+		struct device * (*add)  (struct device * parent, char * bus_id);
+		int             (*hotplug) (struct device *dev, char **envp, 
+		                            int num_envp, char *buffer, int buffer_size);
+		int		(*suspend)(struct device * dev, pm_message_t state);
+		int		(*resume)(struct device * dev);
+
 };
 
[truncated at 1000 lines; 20544 more skipped]