2 * PROJECT: ReactOS Universal Serial Bus Bulk Driver Library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/drivers/libusb/libusb.cpp
5 * PURPOSE: USB Common Driver Library.
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
17 DRIVER_ADD_DEVICE USBLIB_AddDevice
;
25 PDRIVER_OBJECT DriverObject
,
26 PDEVICE_OBJECT PhysicalDeviceObject
)
29 PHCDCONTROLLER HcdController
;
31 DPRINT1("USBLIB_AddDevice\n");
33 /* first create the controller object */
34 Status
= CreateHCDController(&HcdController
);
35 if (!NT_SUCCESS(Status
))
37 /* failed to create hcd */
38 DPRINT1("AddDevice: Failed to create hcd with %x\n", Status
);
42 /* initialize the hcd */
43 Status
= HcdController
->Initialize(NULL
, // FIXME
45 PhysicalDeviceObject
);
47 /* check for success */
48 if (!NT_SUCCESS(Status
))
50 /* failed to initialize device */
51 DPRINT1("AddDevice: failed to initialize\n");
54 HcdController
->Release();
68 PDEVICE_OBJECT DeviceObject
,
71 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
72 PIO_STACK_LOCATION IoStack
;
76 // get common device extension
78 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
81 // get current stack location
83 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
88 PC_ASSERT(DeviceExtension
->Dispatcher
);
90 switch(IoStack
->MajorFunction
)
97 return DeviceExtension
->Dispatcher
->HandlePnp(DeviceObject
, Irp
);
105 return DeviceExtension
->Dispatcher
->HandlePower(DeviceObject
, Irp
);
107 case IRP_MJ_INTERNAL_DEVICE_CONTROL
:
108 case IRP_MJ_DEVICE_CONTROL
:
113 return DeviceExtension
->Dispatcher
->HandleDeviceControl(DeviceObject
, Irp
);
117 DPRINT1("USBLIB_Dispatch> Major %lu Minor %lu unhandeled\n", IoStack
->MajorFunction
, IoStack
->MinorFunction
);
118 Status
= STATUS_SUCCESS
;
125 Irp
->IoStatus
.Information
= 0;
126 Irp
->IoStatus
.Status
= Status
;
127 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);