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)
19 DRIVER_ADD_DEVICE USBLIB_AddDevice
;
27 PDRIVER_OBJECT DriverObject
,
28 PDEVICE_OBJECT PhysicalDeviceObject
)
31 PHCDCONTROLLER HcdController
;
33 DPRINT1("USBLIB_AddDevice\n");
35 /* first create the controller object */
36 Status
= CreateHCDController(&HcdController
);
37 if (!NT_SUCCESS(Status
))
39 /* failed to create hcd */
40 DPRINT1("AddDevice: Failed to create hcd with %x\n", Status
);
44 /* initialize the hcd */
45 Status
= HcdController
->Initialize(NULL
, // FIXME
47 PhysicalDeviceObject
);
49 /* check for success */
50 if (!NT_SUCCESS(Status
))
52 /* failed to initialize device */
53 DPRINT1("AddDevice: failed to initialize\n");
56 HcdController
->Release();
70 PDEVICE_OBJECT DeviceObject
,
73 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
74 PIO_STACK_LOCATION IoStack
;
78 // get common device extension
80 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
83 // get current stack location
85 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
90 PC_ASSERT(DeviceExtension
->Dispatcher
);
92 switch(IoStack
->MajorFunction
)
99 return DeviceExtension
->Dispatcher
->HandlePnp(DeviceObject
, Irp
);
107 return DeviceExtension
->Dispatcher
->HandlePower(DeviceObject
, Irp
);
109 case IRP_MJ_INTERNAL_DEVICE_CONTROL
:
110 case IRP_MJ_DEVICE_CONTROL
:
115 return DeviceExtension
->Dispatcher
->HandleDeviceControl(DeviceObject
, Irp
);
119 DPRINT1("USBLIB_Dispatch> Major %lu Minor %lu unhandeled\n", IoStack
->MajorFunction
, IoStack
->MinorFunction
);
120 Status
= STATUS_SUCCESS
;
127 Irp
->IoStatus
.Information
= 0;
128 Irp
->IoStatus
.Status
= Status
;
129 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);