Author: janderwald
Date: Thu Jan 26 03:42:56 2012
New Revision: 55195
URL:
http://svn.reactos.org/svn/reactos?rev=55195&view=rev
Log:
[USBCCGP]
- Start implement USB Composite generic parent driver which is used for USB composite
devices
- Start implement FDO initialization, needs to implement parsing of usb interface
assocaition descriptor to complete FDO initialization
Added:
branches/usb-bringup-trunk/drivers/usb/usbccgp/ (with props)
branches/usb-bringup-trunk/drivers/usb/usbccgp/CMakeLists.txt (with props)
branches/usb-bringup-trunk/drivers/usb/usbccgp/descriptor.c
- copied, changed from r55188,
branches/usb-bringup-trunk/drivers/usb/usbstor/descriptor.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c (with props)
branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c (with props)
branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c (with props)
branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.h (with props)
branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.rc (with props)
Modified:
branches/usb-bringup-trunk/drivers/usb/CMakeLists.txt
Modified: branches/usb-bringup-trunk/drivers/usb/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/C…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/CMakeLists.txt [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/CMakeLists.txt [iso-8859-1] Thu Jan 26 03:42:56
2012
@@ -1,3 +1,4 @@
+add_subdirectory(usbccgp)
add_subdirectory(usbd)
add_subdirectory(usbehci_new)
add_subdirectory(usbhub_new)
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Thu Jan 26 03:42:56 2012
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Added: branches/usb-bringup-trunk/drivers/usb/usbccgp/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/CMakeLists.txt (added)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/CMakeLists.txt [iso-8859-1] Thu Jan 26
03:42:56 2012
@@ -1,0 +1,13 @@
+
+add_definitions(-DDEBUG_MODE)
+
+include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
+
+add_library(usbccgp SHARED descriptor.c fdo.c misc.c pdo.c usbccgp.c usbccgp.rc)
+
+target_link_libraries(usbccgp ${PSEH_LIB})
+
+set_module_type(usbccgp kernelmodedriver)
+add_importlibs(usbccgp ntoskrnl hal usbd)
+
+add_cd_file(TARGET usbccgp DESTINATION reactos/system32/drivers NO_CAB FOR all)
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Copied: branches/usb-bringup-trunk/drivers/usb/usbccgp/descriptor.c (from r55188,
branches/usb-bringup-trunk/drivers/usb/usbstor/descriptor.c)
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbstor/descriptor.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/descriptor.c [iso-8859-1] Thu Jan 26
03:42:56 2012
@@ -1,19 +1,19 @@
/*
- * PROJECT: ReactOS Universal Serial Bus Bulk Storage Driver
+ * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
- * FILE: drivers/usb/usbstor/descriptor.c
- * PURPOSE: USB block storage device driver.
+ * FILE: drivers/usb/usbccgp/descriptor.c
+ * PURPOSE: USB device driver.
* PROGRAMMERS:
- * James Tabor
* Michael Martin (michael.martin(a)reactos.org)
* Johannes Anderwald (johannes.anderwald(a)reactos.org)
+ * Cameron Gutman
*/
-#include "usbstor.h"
+#include "usbccgp.h"
NTSTATUS
NTAPI
-USBSTOR_GetDescriptor(
+USBCCGP_GetDescriptor(
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR DescriptorType,
IN ULONG DescriptorLength,
@@ -73,7 +73,7 @@
//
// submit urb
//
- Status = USBSTOR_SyncUrbRequest(DeviceObject, Urb);
+ Status = USBCCGP_SyncUrbRequest(DeviceObject, Urb);
//
// free urb
@@ -96,7 +96,7 @@
NTSTATUS
-USBSTOR_GetDescriptors(
+USBCCGP_GetDescriptors(
IN PDEVICE_OBJECT DeviceObject)
{
NTSTATUS Status;
@@ -111,7 +111,7 @@
//
// first get device descriptor
//
- Status = USBSTOR_GetDescriptor(DeviceExtension->LowerDeviceObject,
USB_DEVICE_DESCRIPTOR_TYPE, sizeof(USB_DEVICE_DESCRIPTOR), 0, 0,
(PVOID*)&DeviceExtension->DeviceDescriptor);
+ Status = USBCCGP_GetDescriptor(DeviceExtension->NextDeviceObject,
USB_DEVICE_DESCRIPTOR_TYPE, sizeof(USB_DEVICE_DESCRIPTOR), 0, 0,
(PVOID*)&DeviceExtension->DeviceDescriptor);
if (!NT_SUCCESS(Status))
{
//
@@ -124,7 +124,7 @@
//
// now get basic configuration descriptor
//
- Status = USBSTOR_GetDescriptor(DeviceExtension->LowerDeviceObject,
USB_CONFIGURATION_DESCRIPTOR_TYPE, sizeof(USB_CONFIGURATION_DESCRIPTOR), 0, 0,
(PVOID*)&DeviceExtension->ConfigurationDescriptor);
+ Status = USBCCGP_GetDescriptor(DeviceExtension->NextDeviceObject,
USB_CONFIGURATION_DESCRIPTOR_TYPE, sizeof(USB_CONFIGURATION_DESCRIPTOR), 0, 0,
(PVOID*)&DeviceExtension->ConfigurationDescriptor);
if (!NT_SUCCESS(Status))
{
//
@@ -149,7 +149,7 @@
//
// allocate full descriptor
//
- Status = USBSTOR_GetDescriptor(DeviceExtension->LowerDeviceObject,
USB_CONFIGURATION_DESCRIPTOR_TYPE, DescriptorLength, 0, 0,
(PVOID*)&DeviceExtension->ConfigurationDescriptor);
+ Status = USBCCGP_GetDescriptor(DeviceExtension->NextDeviceObject,
USB_CONFIGURATION_DESCRIPTOR_TYPE, DescriptorLength, 0, 0,
(PVOID*)&DeviceExtension->ConfigurationDescriptor);
if (!NT_SUCCESS(Status))
{
//
@@ -159,171 +159,65 @@
DeviceExtension->DeviceDescriptor = NULL;
return Status;
}
-
- //
- // check if there is a serial number provided
- //
- if (DeviceExtension->DeviceDescriptor->iSerialNumber)
- {
- //
- // get serial number
- //
- Status = USBSTOR_GetDescriptor(DeviceExtension->LowerDeviceObject,
USB_STRING_DESCRIPTOR_TYPE, 100 * sizeof(WCHAR),
DeviceExtension->DeviceDescriptor->iSerialNumber, 0x0409,
(PVOID*)&DeviceExtension->SerialNumber);
- if (!NT_SUCCESS(Status))
- {
- //
- // failed to get serial number descriptor, free device descriptor
- //
- FreeItem(DeviceExtension->DeviceDescriptor);
- DeviceExtension->DeviceDescriptor = NULL;
-
- //
- // free configuration descriptor
- //
- FreeItem(DeviceExtension->ConfigurationDescriptor);
- DeviceExtension->ConfigurationDescriptor = NULL;
-
- //
- // set serial number to zero
- //
- DeviceExtension->SerialNumber = NULL;
- return Status;
- }
- }
-
return Status;
}
NTSTATUS
NTAPI
-USBSTOR_ScanConfigurationDescriptor(
- IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
- OUT PUSB_INTERFACE_DESCRIPTOR * OutInterfaceDescriptor,
- OUT PUSB_ENDPOINT_DESCRIPTOR * InEndpointDescriptor,
- OUT PUSB_ENDPOINT_DESCRIPTOR * OutEndpointDescriptor)
-{
- PUSB_CONFIGURATION_DESCRIPTOR CurrentDescriptor;
- PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
+USBCCGP_ScanConfigurationDescriptor(
+ IN OUT PFDO_DEVICE_EXTENSION FDODeviceExtension,
+ IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
+{
+ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
+ ULONG InterfaceIndex = 0;
//
// sanity checks
//
ASSERT(ConfigurationDescriptor);
- ASSERT(OutInterfaceDescriptor);
- ASSERT(InEndpointDescriptor);
- ASSERT(OutEndpointDescriptor);
-
- //
- // nullify pointers
- //
- *OutInterfaceDescriptor = NULL;
- *InEndpointDescriptor = NULL;
- *OutEndpointDescriptor = NULL;
-
- //
- // start scanning
- //
- CurrentDescriptor = ConfigurationDescriptor;
+ ASSERT(ConfigurationDescriptor->bNumInterfaces);
+
+ //
+ // allocate array holding the interface descriptors
+ //
+ FDODeviceExtension->InterfaceList = AllocateItem(NonPagedPool,
sizeof(USB_CONFIGURATION_DESCRIPTOR) * (ConfigurationDescriptor->bNumInterfaces + 1));
+ if (!FDODeviceExtension->InterfaceList)
+ {
+ //
+ // no memory
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
do
{
//
- // check current descriptor type
- //
- if (CurrentDescriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE)
+ // parse configuration descriptor
+ //
+ InterfaceDescriptor =
USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor, ConfigurationDescriptor,
InterfaceIndex, 0, -1, -1, -1);
+ if (InterfaceDescriptor)
{
//
- // found interface descriptor
+ // store in interface list
//
- if (*OutInterfaceDescriptor)
- {
- //
- // we only process the first interface descriptor as ms does -> see
documentation
- //
- break;
- }
-
- //
- // store interface descriptor
- //
- *OutInterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)CurrentDescriptor;
+
FDODeviceExtension->InterfaceList[FDODeviceExtension->InterfaceListCount].InterfaceDescriptor
= InterfaceDescriptor;
+ FDODeviceExtension->InterfaceListCount++;
}
- else if (CurrentDescriptor->bDescriptorType == USB_ENDPOINT_DESCRIPTOR_TYPE)
- {
- //
- // convert to endpoint descriptor
- //
- EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR)CurrentDescriptor;
-
- //
- // sanity check
- //
- ASSERT(*OutInterfaceDescriptor);
-
- //
- // get endpoint type
- //
- if ((EndpointDescriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK) ==
USB_ENDPOINT_TYPE_BULK)
- {
- //
- // bulk endpoint type
- //
- if (USB_ENDPOINT_DIRECTION_IN(EndpointDescriptor->bEndpointAddress))
- {
- //
- // bulk in
- //
- *InEndpointDescriptor = EndpointDescriptor;
- }
- else
- {
- //
- // bulk out
- //
- *OutEndpointDescriptor = EndpointDescriptor;
- }
- }
- else if ((EndpointDescriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK)
== USB_ENDPOINT_TYPE_INTERRUPT)
- {
- //
- // interrupt endpoint type
- //
- UNIMPLEMENTED
- }
- }
-
- //
- // move to next descriptor
- //
- CurrentDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR)((ULONG_PTR)CurrentDescriptor
+ CurrentDescriptor->bLength);
-
- //
- // was it the last descriptor
- //
- if ((ULONG_PTR)CurrentDescriptor >= ((ULONG_PTR)ConfigurationDescriptor +
ConfigurationDescriptor->wTotalLength))
- {
- //
- // reached last descriptor
- //
- break;
- }
-
- }while(TRUE);
-
- //
- // check if everything has been found
- //
- if (*OutInterfaceDescriptor == NULL || *InEndpointDescriptor == NULL ||
*OutEndpointDescriptor == NULL)
- {
- //
- // failed to find interface / endpoint descriptor
- //
- DPRINT1("USBSTOR_ScanConfigurationDescriptor: Failed to find
InterfaceDescriptor %p InEndpointDescriptor %p OutEndpointDescriptor %p\n",
*OutInterfaceDescriptor, *InEndpointDescriptor, *OutEndpointDescriptor);
- return STATUS_UNSUCCESSFUL;
- }
-
- //
- // completed successfully
+
+ //
+ // move to next interface
+ //
+ InterfaceIndex++;
+
+ }while(InterfaceIndex < ConfigurationDescriptor->bNumInterfaces);
+
+ //
+ // sanity check
+ //
+ ASSERT(FDODeviceExtension->InterfaceListCount);
+
+ //
+ // done
//
return STATUS_SUCCESS;
}
@@ -343,20 +237,78 @@
}
NTSTATUS
-USBSTOR_SelectConfigurationAndInterface(
+USBCCGP_SelectInterface(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PFDO_DEVICE_EXTENSION DeviceExtension,
+ IN ULONG InterfaceIndex)
+{
+ NTSTATUS Status;
+ PURB Urb;
+
+ //
+ // allocate urb
+ //
+ Urb = AllocateItem(NonPagedPool, sizeof(struct _URB_SELECT_INTERFACE));
+ if (!Urb)
+ {
+ //
+ // no memory
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // now prepare interface urb
+ //
+ UsbBuildSelectInterfaceRequest(Urb,
GET_SELECT_INTERFACE_REQUEST_SIZE(DeviceExtension->InterfaceList[InterfaceIndex].InterfaceDescriptor->bNumEndpoints),
DeviceExtension->ConfigurationHandle,
DeviceExtension->InterfaceList[InterfaceIndex].InterfaceDescriptor->bInterfaceNumber,
DeviceExtension->InterfaceList[InterfaceIndex].InterfaceDescriptor->bAlternateSetting);
+
+ //
+ // copy interface information structure back - as offset for SelectConfiguration /
SelectInterface request do differ
+ //
+ RtlCopyMemory(&Urb->UrbSelectInterface.Interface,
DeviceExtension->InterfaceList[InterfaceIndex].Interface,
DeviceExtension->InterfaceList[InterfaceIndex].Interface->Length);
+
+ //
+ // now select the interface
+ //
+ Status = USBCCGP_SyncUrbRequest(DeviceExtension->NextDeviceObject, Urb);
+
+ //
+ // did it succeeed
+ //
+ if (NT_SUCCESS(Status))
+ {
+ //
+ // update configuration info
+ //
+ ASSERT(Urb->UrbSelectInterface.Interface.Length ==
DeviceExtension->InterfaceList[InterfaceIndex].Interface->Length);
+ RtlCopyMemory(DeviceExtension->InterfaceList[InterfaceIndex].Interface,
&Urb->UrbSelectInterface.Interface, Urb->UrbSelectInterface.Interface.Length);
+ }
+
+ //
+ // free urb
+ //
+ FreeItem(Urb);
+
+ //
+ // done
+ //
+ return Status;
+}
+
+NTSTATUS
+USBCCGP_SelectConfiguration(
IN PDEVICE_OBJECT DeviceObject,
IN PFDO_DEVICE_EXTENSION DeviceExtension)
{
- PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- PUSB_ENDPOINT_DESCRIPTOR InEndpointDescriptor, OutEndpointDescriptor;
+ PUSBD_INTERFACE_INFORMATION InterfaceInformation;
NTSTATUS Status;
PURB Urb;
- PUSBD_INTERFACE_LIST_ENTRY InterfaceList;
+ ULONG Index;
//
// now scan configuration descriptors
//
- Status =
USBSTOR_ScanConfigurationDescriptor(DeviceExtension->ConfigurationDescriptor,
&InterfaceDescriptor, &InEndpointDescriptor, &OutEndpointDescriptor);
+ Status = USBCCGP_ScanConfigurationDescriptor(DeviceExtension,
DeviceExtension->ConfigurationDescriptor);
if (!NT_SUCCESS(Status))
{
//
@@ -366,181 +318,69 @@
}
//
- // now allocate one interface entry and terminating null entry
- //
- InterfaceList = (PUSBD_INTERFACE_LIST_ENTRY)AllocateItem(PagedPool,
sizeof(USBD_INTERFACE_LIST_ENTRY) * 2);
- if (!InterfaceList)
- {
- //
- // no memory
- //
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- //
- // initialize interface list entry
- //
- InterfaceList[0].InterfaceDescriptor = InterfaceDescriptor;
-
- //
// now allocate the urb
//
- Urb = USBD_CreateConfigurationRequestEx(DeviceExtension->ConfigurationDescriptor,
InterfaceList);
+ Urb = USBD_CreateConfigurationRequestEx(DeviceExtension->ConfigurationDescriptor,
DeviceExtension->InterfaceList);
if (!Urb)
{
//
// no memory
//
- FreeItem(InterfaceList);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- //
- // sanity check
- //
- ASSERT(InterfaceList[0].Interface);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
//
// submit urb
//
- Status = USBSTOR_SyncUrbRequest(DeviceExtension->LowerDeviceObject, Urb);
+ Status = USBCCGP_SyncUrbRequest(DeviceExtension->NextDeviceObject, Urb);
if (!NT_SUCCESS(Status))
{
//
// failed to set configuration
//
- DPRINT1("USBSTOR_SelectConfiguration failed to set interface %x\n",
Status);
- FreeItem(InterfaceList);
+ DPRINT1("USBCCGP_SyncUrbRequest failed to set interface %x\n",
Status);
ExFreePool(Urb);
return Status;
}
//
- // backup interface information
- //
- DeviceExtension->InterfaceInformation =
(PUSBD_INTERFACE_INFORMATION)AllocateItem(NonPagedPool,
Urb->UrbSelectConfiguration.Interface.Length);
- if (!NT_SUCCESS(Status))
- {
- //
- // failed to allocate interface information structure
- //
- FreeItem(InterfaceList);
- ExFreePool(Urb);
- return Status;
- }
-
- //
- // copy interface information
- //
- RtlCopyMemory(DeviceExtension->InterfaceInformation,
&Urb->UrbSelectConfiguration.Interface,
Urb->UrbSelectConfiguration.Interface.Length);
-
- //
- // store pipe handle
- //
- DeviceExtension->ConfigurationHandle =
Urb->UrbSelectConfiguration.ConfigurationHandle;
-
- //
- // now prepare interface urb
- //
- UsbBuildSelectInterfaceRequest(Urb,
GET_SELECT_INTERFACE_REQUEST_SIZE(InterfaceDescriptor->bNumEndpoints),
DeviceExtension->ConfigurationHandle, InterfaceDescriptor->bInterfaceNumber,
InterfaceDescriptor->bAlternateSetting);
-
- //
- // copy interface information structure back - as offset for SelectConfiguration /
SelectInterface request do differ
- //
- RtlCopyMemory(&Urb->UrbSelectInterface.Interface,
DeviceExtension->InterfaceInformation,
DeviceExtension->InterfaceInformation->Length);
-
- //
- // now select the interface
- //
- Status = USBSTOR_SyncUrbRequest(DeviceExtension->LowerDeviceObject, Urb);
-
- //
- // did it succeeed
- //
- if (NT_SUCCESS(Status))
- {
- //
- // update configuration info
- //
- ASSERT(Urb->UrbSelectInterface.Interface.Length ==
DeviceExtension->InterfaceInformation->Length);
- RtlCopyMemory(DeviceExtension->InterfaceInformation,
&Urb->UrbSelectInterface.Interface, Urb->UrbSelectInterface.Interface.Length);
- }
-
- //
- // free interface list & urb
- //
- FreeItem(InterfaceList);
- ExFreePool(Urb);
-
- //
- // done
- //
- return Status;
-}
-
-NTSTATUS
-USBSTOR_GetPipeHandles(
- IN PFDO_DEVICE_EXTENSION DeviceExtension)
-{
- ULONG Index;
- BOOLEAN BulkInFound = FALSE, BulkOutFound = FALSE;
-
- //
- // no enumerate all pipes and extract bulk-in / bulk-out pipe handle
- //
- for(Index = 0; Index < DeviceExtension->InterfaceInformation->NumberOfPipes;
Index++)
- {
- //
- // check pipe type
- //
- if (DeviceExtension->InterfaceInformation->Pipes[Index].PipeType ==
UsbdPipeTypeBulk)
+ // get interface information
+ //
+ InterfaceInformation = &Urb->UrbSelectConfiguration.Interface;
+
+ for(Index = 0; Index < DeviceExtension->InterfaceListCount; Index++)
+ {
+ //
+ // allocate buffer to store interface information
+ //
+ DeviceExtension->InterfaceList[Index].Interface = AllocateItem(NonPagedPool,
InterfaceInformation[Index].Length);
+ if (!DeviceExtension->InterfaceList[Index].Interface)
{
//
- // check direction
+ // no memory
//
- if
(USB_ENDPOINT_DIRECTION_IN(DeviceExtension->InterfaceInformation->Pipes[Index].EndpointAddress))
- {
- //
- // bulk in pipe
- //
- DeviceExtension->BulkInPipeIndex = Index;
-
- //
- // there should not be another bulk in pipe
- //
- ASSERT(BulkInFound == FALSE);
- BulkInFound = TRUE;
- }
- else
- {
- //
- // bulk out pipe
- //
- DeviceExtension->BulkOutPipeIndex = Index;
-
- //
- // there should not be another bulk out pipe
- //
- ASSERT(BulkOutFound == FALSE);
- BulkOutFound = TRUE;
- }
+ return STATUS_INSUFFICIENT_RESOURCES;
}
- }
-
- //
- // check if both bulk pipes have been found
- //
- if (!BulkInFound || !BulkOutFound)
- {
- //
- // WTF? usb port driver does not give us bulk pipe access
- //
- DPRINT1("USBSTOR_GetPipeHandles> BulkInFound %d BulkOutFound %d
missing!!!\n", BulkInFound, BulkOutFound);
- return STATUS_DEVICE_CONFIGURATION_ERROR;
- }
-
- //
- // device is configured
- //
- return STATUS_SUCCESS;
-}
+
+ //
+ // copy interface information
+ //
+ RtlCopyMemory(DeviceExtension->InterfaceList[Index].Interface,
InterfaceInformation, InterfaceInformation->Length);
+ }
+
+ //
+ // store pipe handle
+ //
+ DeviceExtension->ConfigurationHandle =
Urb->UrbSelectConfiguration.ConfigurationHandle;
+
+ //
+ // free interface list & urb
+ //
+ ExFreePool(Urb);
+
+ //
+ // done
+ //
+ return Status;
+}
+
Added: branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c (added)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c [iso-8859-1] Thu Jan 26 03:42:56
2012
@@ -1,0 +1,289 @@
+/*
+ * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/usbccgp/fdo.c
+ * PURPOSE: USB device driver.
+ * PROGRAMMERS:
+ * Michael Martin (michael.martin(a)reactos.org)
+ * Johannes Anderwald (johannes.anderwald(a)reactos.org)
+ * Cameron Gutman
+ */
+
+#include "usbccgp.h"
+
+NTSTATUS
+NTAPI
+FDO_QueryCapabilitiesCompletionRoutine(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PVOID Context)
+{
+ //
+ // set event
+ //
+ KeSetEvent((PRKEVENT)Context, 0, FALSE);
+
+ //
+ // completion is done in the HidClassFDO_QueryCapabilities routine
+ //
+ return STATUS_MORE_PROCESSING_REQUIRED;
+}
+
+NTSTATUS
+FDO_QueryCapabilities(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN OUT PDEVICE_CAPABILITIES Capabilities)
+{
+ PIRP Irp;
+ KEVENT Event;
+ NTSTATUS Status;
+ PIO_STACK_LOCATION IoStack;
+ PFDO_DEVICE_EXTENSION FDODeviceExtension;
+
+ //
+ // get device extension
+ //
+ FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ ASSERT(FDODeviceExtension->Common.IsFDO);
+
+ //
+ // init event
+ //
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ //
+ // now allocte the irp
+ //
+ Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
+ if (!Irp)
+ {
+ //
+ // no memory
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // get next stack location
+ //
+ IoStack = IoGetNextIrpStackLocation(Irp);
+
+ //
+ // init stack location
+ //
+ IoStack->MajorFunction = IRP_MJ_PNP;
+ IoStack->MinorFunction = IRP_MN_QUERY_CAPABILITIES;
+ IoStack->Parameters.DeviceCapabilities.Capabilities = Capabilities;
+
+ //
+ // set completion routine
+ //
+ IoSetCompletionRoutine(Irp, FDO_QueryCapabilitiesCompletionRoutine,
(PVOID)&Event, TRUE, TRUE, TRUE);
+
+ //
+ // init capabilities
+ //
+ RtlZeroMemory(Capabilities, sizeof(DEVICE_CAPABILITIES));
+ Capabilities->Size = sizeof(DEVICE_CAPABILITIES);
+ Capabilities->Version = 1; // FIXME hardcoded constant
+ Capabilities->Address = MAXULONG;
+ Capabilities->UINumber = MAXULONG;
+
+ //
+ // pnp irps have default completion code
+ //
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+
+ //
+ // call lower device
+ //
+ Status = IoCallDriver(FDODeviceExtension->NextDeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ //
+ // wait for completion
+ //
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+ }
+
+ //
+ // get status
+ //
+ Status = Irp->IoStatus.Status;
+
+ //
+ // complete request
+ //
+ IoFreeIrp(Irp);
+
+ //
+ // done
+ //
+ return Status;
+}
+
+NTSTATUS
+FDO_DeviceRelations(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ UNIMPLEMENTED
+ ASSERT(FALSE);
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+FDO_StartDevice(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ NTSTATUS Status;
+ PFDO_DEVICE_EXTENSION FDODeviceExtension;
+
+ //
+ // get device extension
+ //
+ FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ ASSERT(FDODeviceExtension->Common.IsFDO);
+
+ //
+ // first start lower device
+ //
+ Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
+
+ if (!NT_SUCCESS(Status))
+ {
+ //
+ // failed to start lower device
+ //
+ DPRINT1("FDO_StartDevice lower device failed to start with %x\n",
Status);
+ return Status;
+ }
+
+ // get descriptors
+ Status = USBCCGP_GetDescriptors(DeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ // failed to start lower device
+ DPRINT1("FDO_StartDevice failed to get descriptors with %x\n",
Status);
+ return Status;
+ }
+
+ // get capabilities
+ Status = FDO_QueryCapabilities(DeviceObject,
&FDODeviceExtension->Capabilities);
+ if (!NT_SUCCESS(Status))
+ {
+ // failed to start lower device
+ DPRINT1("FDO_StartDevice failed to get capabilities with %x\n",
Status);
+ return Status;
+ }
+
+ // now select the configuration
+ Status = USBCCGP_SelectConfiguration(DeviceObject, FDODeviceExtension);
+ if (!NT_SUCCESS(Status))
+ {
+ // failed to select interface
+ DPRINT1("FDO_StartDevice failed to get capabilities with %x\n",
Status);
+ return Status;
+ }
+
+ //
+ // FIXME: parse usb interface association descriptor
+ // and create PDO for each function
+ //
+ ASSERT(FALSE);
+ return Status;
+}
+
+
+NTSTATUS
+FDO_HandlePnp(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PIO_STACK_LOCATION IoStack;
+ NTSTATUS Status;
+ PFDO_DEVICE_EXTENSION FDODeviceExtension;
+
+ // get device extension
+ FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ ASSERT(FDODeviceExtension->Common.IsFDO);
+
+
+ // get stack location
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ switch(IoStack->MinorFunction)
+ {
+ case IRP_MN_START_DEVICE:
+ {
+ Status = FDO_StartDevice(DeviceObject, Irp);
+ break;
+ }
+ case IRP_MN_QUERY_DEVICE_RELATIONS:
+ {
+ Status = FDO_DeviceRelations(DeviceObject, Irp);
+ break;
+ }
+ case IRP_MN_QUERY_CAPABILITIES:
+ {
+ //
+ // copy capabilities
+ //
+ RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities,
&FDODeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));
+ Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject,
Irp);
+ if (NT_SUCCESS(Status))
+ {
+ //
+ // surprise removal ok
+ //
+
IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
+ }
+ break;
+ }
+ default:
+ {
+ //
+ // forward irp to next device object
+ //
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(FDODeviceExtension->NextDeviceObject, Irp);
+ }
+
+ }
+
+ //
+ // complete request
+ //
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+
+
+}
+
+NTSTATUS
+FDO_Dispatch(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PIO_STACK_LOCATION IoStack;
+ NTSTATUS Status;
+
+ /* get stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ switch(IoStack->MajorFunction)
+ {
+ case IRP_MJ_PNP:
+ return FDO_HandlePnp(DeviceObject, Irp);
+ default:
+ DPRINT1("FDO_Dispatch Function %x not implemented\n",
IoStack->MajorFunction);
+ ASSERT(FALSE);
+ Status = Irp->IoStatus.Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+}
+
+
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c (added)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c [iso-8859-1] Thu Jan 26 03:42:56
2012
@@ -1,0 +1,24 @@
+/*
+ * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/usbccgp/fdo.c
+ * PURPOSE: USB device driver.
+ * PROGRAMMERS:
+ * Michael Martin (michael.martin(a)reactos.org)
+ * Johannes Anderwald (johannes.anderwald(a)reactos.org)
+ * Cameron Gutman
+ */
+
+#include "usbccgp.h"
+
+
+
+NTSTATUS
+PDO_Dispatch(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ UNIMPLEMENTED
+ ASSERT(FALSE);
+ return STATUS_NOT_IMPLEMENTED;
+}
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c (added)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c [iso-8859-1] Thu Jan 26
03:42:56 2012
@@ -1,0 +1,150 @@
+/*
+ * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/usbccgp/fdo.c
+ * PURPOSE: USB device driver.
+ * PROGRAMMERS:
+ * Michael Martin (michael.martin(a)reactos.org)
+ * Johannes Anderwald (johannes.anderwald(a)reactos.org)
+ * Cameron Gutman
+ */
+
+#include "usbccgp.h"
+
+//
+// driver verifier
+//
+DRIVER_ADD_DEVICE USBCCGP_AddDevice;
+
+NTSTATUS
+NTAPI
+USBCCGP_AddDevice(
+ PDRIVER_OBJECT DriverObject,
+ PDEVICE_OBJECT PhysicalDeviceObject)
+{
+ NTSTATUS Status;
+ PDEVICE_OBJECT DeviceObject;
+ PFDO_DEVICE_EXTENSION FDODeviceExtension;
+
+ // lets create the device
+ Status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_EXTENSION), NULL,
FILE_DEVICE_USB, FILE_AUTOGENERATED_DEVICE_NAME, FALSE, &DeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ // failed to create device
+ DPRINT1("USBCCGP_AddDevice failed to create device with %x\n",
Status);
+ return Status;
+ }
+
+ // get device extension
+ FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ // init device extension
+ RtlZeroMemory(FDODeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
+ FDODeviceExtension->Common.IsFDO = TRUE;
+ FDODeviceExtension->DriverObject = DriverObject;
+ FDODeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
+ FDODeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack(DeviceObject,
PhysicalDeviceObject);
+ if (!FDODeviceExtension->NextDeviceObject)
+ {
+ // failed to attach
+ DPRINT1("USBCCGP_AddDevice failed to attach device\n");
+ IoDeleteDevice(DeviceObject);
+ return STATUS_DEVICE_REMOVED;
+ }
+
+ // set device flags
+ DeviceObject->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE;
+
+ // device is initialized
+ DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+
+ // device initialized
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+USBCCGP_CreateClose(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PCOMMON_DEVICE_EXTENSION DeviceExtension;
+ PFDO_DEVICE_EXTENSION FDODeviceExtension;
+
+ // get common device extension
+ DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ // is it a fdo
+ if (DeviceExtension->IsFDO)
+ {
+ // forward and forget
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ // get fdo
+ FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ // call lower driver
+ return IoCallDriver(FDODeviceExtension->NextDeviceObject, Irp);
+ }
+ else
+ {
+ // pdo not supported
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_SUPPORTED;
+ }
+}
+
+NTSTATUS
+NTAPI
+USBCCGP_Dispatch(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PCOMMON_DEVICE_EXTENSION DeviceExtension;
+ PIO_STACK_LOCATION IoStack;
+
+ // get common device extension
+ DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ // get current stack location
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ if (IoStack->MajorFunction == IRP_MJ_CREATE || IoStack->MajorFunction ==
IRP_MJ_CLOSE)
+ {
+ // dispatch to default handler
+ return USBCCGP_CreateClose(DeviceObject, Irp);
+ }
+
+ if (DeviceExtension->IsFDO)
+ {
+ // handle request for FDO
+ return FDO_Dispatch(DeviceObject, Irp);
+ }
+ else
+ {
+ // handle request for PDO
+ return PDO_Dispatch(DeviceObject, Irp);
+ }
+}
+
+NTSTATUS
+NTAPI
+DriverEntry(
+ PDRIVER_OBJECT DriverObject,
+ PUNICODE_STRING RegistryPath)
+{
+
+ // initialize driver object
+ DriverObject->DriverExtension->AddDevice = USBCCGP_AddDevice;
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = USBCCGP_Dispatch;
+ DriverObject->MajorFunction[IRP_MJ_CLOSE] = USBCCGP_Dispatch;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = USBCCGP_Dispatch;
+ DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = USBCCGP_Dispatch;
+ DriverObject->MajorFunction[IRP_MJ_POWER] = USBCCGP_Dispatch;
+ DriverObject->MajorFunction[IRP_MJ_PNP] = USBCCGP_Dispatch;
+
+ // FIMXE query GenericCompositeUSBDeviceString
+
+ return STATUS_SUCCESS;
+}
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.h (added)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.h [iso-8859-1] Thu Jan 26
03:42:56 2012
@@ -1,0 +1,96 @@
+#ifndef USBEHCI_H__
+#define USBEHCI_H__
+
+#include <ntddk.h>
+#define YDEBUG
+#include <debug.h>
+#include <hubbusif.h>
+#include <usbbusif.h>
+#include <usbioctl.h>
+#include <usbdlib.h>
+
+//
+// FIXME:
+// #include <usbprotocoldefs.h>
+//
+#include <usb.h>
+#include <stdio.h>
+#include <wdmguid.h>
+
+typedef struct
+{
+ BOOLEAN IsFDO; // is device a FDO or
PDO
+}COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
+
+typedef struct
+{
+ COMMON_DEVICE_EXTENSION Common; // shared with PDO
+ PDRIVER_OBJECT DriverObject; // driver object
+ PDEVICE_OBJECT PhysicalDeviceObject; // physical device object
+ PDEVICE_OBJECT NextDeviceObject; // lower device object
+ PUSB_DEVICE_DESCRIPTOR DeviceDescriptor; // usb device descriptor
+ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; // usb configuration
descriptor
+ DEVICE_CAPABILITIES Capabilities; // device capabilities
+ PUSBD_INTERFACE_LIST_ENTRY InterfaceList; // interface list
+ ULONG InterfaceListCount; // interface list count
+ USBD_CONFIGURATION_HANDLE ConfigurationHandle; // configuration handle
+}FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
+
+#define USBCCPG_TAG 'cbsu'
+
+typedef struct
+{
+ COMMON_DEVICE_EXTENSION Common; // shared with FDO
+
+}PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
+
+/* descriptor.c */
+
+NTSTATUS
+USBCCGP_GetDescriptors(
+ IN PDEVICE_OBJECT DeviceObject);
+
+NTSTATUS
+USBCCGP_SelectConfiguration(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PFDO_DEVICE_EXTENSION DeviceExtension);
+
+/* misc.c */
+
+NTSTATUS
+NTAPI
+USBCCGP_SyncForwardIrp(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+NTSTATUS
+USBCCGP_SyncUrbRequest(
+ IN PDEVICE_OBJECT DeviceObject,
+ OUT PURB UrbRequest);
+
+PVOID
+AllocateItem(
+ IN POOL_TYPE PoolType,
+ IN ULONG ItemSize);
+
+VOID
+FreeItem(
+ IN PVOID Item);
+
+/* fdo.c */
+
+NTSTATUS
+FDO_Dispatch(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+/* pdo.c */
+
+NTSTATUS
+PDO_Dispatch(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+
+
+#endif
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.rc
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.rc (added)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.rc [iso-8859-1] Thu Jan 26
03:42:56 2012
@@ -1,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION "USBCCGP Driver\0"
+#define REACTOS_STR_INTERNAL_NAME "usccpg\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "usbccpg.sys\0"
+#include <reactos/version.rc>
Propchange: branches/usb-bringup-trunk/drivers/usb/usbccgp/usbccgp.rc
------------------------------------------------------------------------------
svn:eol-style = native