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
;
28 PVOID result
= ExAllocatePoolWithTag(poolType
, iSize
, tag
);
30 RtlZeroMemory(result
, iSize
);
40 if (pVoid
) ExFreePool(pVoid
);
46 PVOID pVoid
, UINT_PTR
)
48 if (pVoid
) ExFreePool(pVoid
);
57 PDRIVER_OBJECT DriverObject
,
58 PDEVICE_OBJECT PhysicalDeviceObject
)
61 PHCDCONTROLLER HcdController
;
63 DPRINT("USBLIB_AddDevice\n");
65 /* first create the controller object */
66 Status
= CreateHCDController(&HcdController
);
67 if (!NT_SUCCESS(Status
))
69 /* failed to create hcd */
70 DPRINT1("AddDevice: Failed to create hcd with %x\n", Status
);
74 /* initialize the hcd */
75 Status
= HcdController
->Initialize(NULL
, // FIXME
77 PhysicalDeviceObject
);
79 /* check for success */
80 if (!NT_SUCCESS(Status
))
82 /* failed to initialize device */
83 DPRINT1("AddDevice: failed to initialize\n");
86 HcdController
->Release();
100 PDEVICE_OBJECT DeviceObject
,
103 PCOMMON_DEVICE_EXTENSION DeviceExtension
;
104 PIO_STACK_LOCATION IoStack
;
108 // get common device extension
110 DeviceExtension
= (PCOMMON_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
113 // get current stack location
115 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
120 PC_ASSERT(DeviceExtension
->Dispatcher
);
122 switch(IoStack
->MajorFunction
)
129 return DeviceExtension
->Dispatcher
->HandlePnp(DeviceObject
, Irp
);
137 return DeviceExtension
->Dispatcher
->HandlePower(DeviceObject
, Irp
);
139 case IRP_MJ_INTERNAL_DEVICE_CONTROL
:
140 case IRP_MJ_DEVICE_CONTROL
:
143 // dispatch io control
145 return DeviceExtension
->Dispatcher
->HandleDeviceControl(DeviceObject
, Irp
);
147 case IRP_MJ_SYSTEM_CONTROL
:
150 // dispatch system control
152 return DeviceExtension
->Dispatcher
->HandleSystemControl(DeviceObject
, Irp
);
156 DPRINT1("USBLIB_Dispatch> Major %lu Minor %lu unhandeled\n", IoStack
->MajorFunction
, IoStack
->MinorFunction
);
157 Status
= STATUS_SUCCESS
;
164 Irp
->IoStatus
.Information
= 0;
165 Irp
->IoStatus
.Status
= Status
;
166 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);