2 * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/usb/usbccgp/usbccgp.c
5 * PURPOSE: USB device driver.
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
17 DRIVER_ADD_DEVICE USBCCGP_AddDevice
;
22 PDRIVER_OBJECT DriverObject
,
23 PDEVICE_OBJECT PhysicalDeviceObject
)
26 PDEVICE_OBJECT DeviceObject
;
27 PFDO_DEVICE_EXTENSION FDODeviceExtension
;
29 // lets create the device
30 Status
= IoCreateDevice(DriverObject
, sizeof(FDO_DEVICE_EXTENSION
), NULL
, FILE_DEVICE_USB
, FILE_AUTOGENERATED_DEVICE_NAME
, FALSE
, &DeviceObject
);
31 if (!NT_SUCCESS(Status
))
33 // failed to create device
34 DPRINT1("USBCCGP_AddDevice failed to create device with %x\n", Status
);
38 // get device extension
39 FDODeviceExtension
= (PFDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
41 // init device extension
42 RtlZeroMemory(FDODeviceExtension
, sizeof(FDO_DEVICE_EXTENSION
));
43 FDODeviceExtension
->Common
.IsFDO
= TRUE
;
44 FDODeviceExtension
->DriverObject
= DriverObject
;
45 FDODeviceExtension
->PhysicalDeviceObject
= PhysicalDeviceObject
;
46 FDODeviceExtension
->NextDeviceObject
= IoAttachDeviceToDeviceStack(DeviceObject
, PhysicalDeviceObject
);
47 if (!FDODeviceExtension
->NextDeviceObject
)
50 DPRINT1("USBCCGP_AddDevice failed to attach device\n");
51 IoDeleteDevice(DeviceObject
);
52 return STATUS_DEVICE_REMOVED
;
56 DeviceObject
->Flags
|= DO_BUFFERED_IO
| DO_POWER_PAGABLE
;
58 // device is initialized
59 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
68 PDEVICE_OBJECT DeviceObject
,
71 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
72 PFDO_DEVICE_EXTENSION FDODeviceExtension
;
74 // get common device extension
75 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
78 if (DeviceExtension
->IsFDO
)
81 IoSkipCurrentIrpStackLocation(Irp
);
84 FDODeviceExtension
= (PFDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
87 return IoCallDriver(FDODeviceExtension
->NextDeviceObject
, Irp
);
92 Irp
->IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
93 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
94 return STATUS_NOT_SUPPORTED
;
101 PDEVICE_OBJECT DeviceObject
,
104 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
105 PIO_STACK_LOCATION IoStack
;
107 // get common device extension
108 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
110 // get current stack location
111 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
113 if (IoStack
->MajorFunction
== IRP_MJ_CREATE
|| IoStack
->MajorFunction
== IRP_MJ_CLOSE
)
115 // dispatch to default handler
116 return USBCCGP_CreateClose(DeviceObject
, Irp
);
119 if (DeviceExtension
->IsFDO
)
121 // handle request for FDO
122 return FDO_Dispatch(DeviceObject
, Irp
);
126 // handle request for PDO
127 return PDO_Dispatch(DeviceObject
, Irp
);
134 PDRIVER_OBJECT DriverObject
,
135 PUNICODE_STRING RegistryPath
)
138 // initialize driver object
139 DriverObject
->DriverExtension
->AddDevice
= USBCCGP_AddDevice
;
140 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = USBCCGP_Dispatch
;
141 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = USBCCGP_Dispatch
;
142 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = USBCCGP_Dispatch
;
143 DriverObject
->MajorFunction
[IRP_MJ_INTERNAL_DEVICE_CONTROL
] = USBCCGP_Dispatch
;
144 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = USBCCGP_Dispatch
;
145 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = USBCCGP_Dispatch
;
147 // FIMXE query GenericCompositeUSBDeviceString
149 return STATUS_SUCCESS
;