mirror of
https://github.com/reactos/reactos.git
synced 2025-05-02 04:05:56 +00:00
[USBHUB_NEW] Bring-in the USB Hub driver created by Vadim Galyant. GitHub PR #29. As usual, I thank the code reviewers, especially Thomas for contributing most of the reviews, improvements and fix suggestions.
svn path=/trunk/; revision=75227
This commit is contained in:
parent
922e006ea6
commit
dc50f1da19
11 changed files with 10983 additions and 0 deletions
|
@ -2,6 +2,7 @@ add_subdirectory(usbccgp)
|
|||
add_subdirectory(usbd)
|
||||
add_subdirectory(usbehci)
|
||||
add_subdirectory(usbhub)
|
||||
#add_subdirectory(usbhub_new)
|
||||
add_subdirectory(usbohci)
|
||||
add_subdirectory(usbport)
|
||||
add_subdirectory(usbstor)
|
||||
|
|
22
reactos/drivers/usb/usbhub_new/CMakeLists.txt
Normal file
22
reactos/drivers/usb/usbhub_new/CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
add_definitions(-DDEBUG_MODE)
|
||||
include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
|
||||
|
||||
list(APPEND SOURCE
|
||||
debug.c
|
||||
ioctl.c
|
||||
pnp.c
|
||||
power.c
|
||||
usbhub.c
|
||||
usbhub.h)
|
||||
|
||||
add_library(usbhub SHARED
|
||||
${SOURCE}
|
||||
guid.c
|
||||
usbhub.rc)
|
||||
|
||||
target_link_libraries(usbhub ${PSEH_LIB})
|
||||
set_module_type(usbhub kernelmodedriver)
|
||||
add_importlibs(usbhub ntoskrnl hal wmilib usbd)
|
||||
add_pch(usbhub usbhub.h SOURCE)
|
||||
add_cd_file(TARGET usbhub DESTINATION reactos/system32/drivers NO_CAB FOR all)
|
109
reactos/drivers/usb/usbhub_new/dbg_uhub.h
Normal file
109
reactos/drivers/usb/usbhub_new/dbg_uhub.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
#ifndef DBG_UHUB_H__
|
||||
#define DBG_UHUB_H__
|
||||
|
||||
#if DBG
|
||||
|
||||
#ifndef NDEBUG_USBHUB_IOCTL
|
||||
|
||||
#define DPRINT_IOCTL(fmt, ...) do { \
|
||||
if (DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define DPRINT_IOCTL __noop
|
||||
#else
|
||||
#define DPRINT_IOCTL(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG_USBHUB_POWER
|
||||
|
||||
#define DPRINT_PWR(fmt, ...) do { \
|
||||
if (DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define DPRINT_PWR __noop
|
||||
#else
|
||||
#define DPRINT_PWR(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG_USBHUB_PNP
|
||||
|
||||
#define DPRINT_PNP(fmt, ...) do { \
|
||||
if (DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define DPRINT_PNP __noop
|
||||
#else
|
||||
#define DPRINT_PNP(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG_USBHUB_SCE
|
||||
|
||||
#define DPRINT_SCE(fmt, ...) do { \
|
||||
if (DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define DPRINT_SCE __noop
|
||||
#else
|
||||
#define DPRINT_SCE(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG_USBHUB_ENUM
|
||||
|
||||
#define DPRINT_ENUM(fmt, ...) do { \
|
||||
if (DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define DPRINT_ENUM __noop
|
||||
#else
|
||||
#define DPRINT_ENUM(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#else /* not DBG */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define DPRINT_IOCTL __noop
|
||||
#define DPRINT_PWR __noop
|
||||
#define DPRINT_PNP __noop
|
||||
#define DPRINT_SCE __noop
|
||||
#define DPRINT_ENUM __noop
|
||||
#else
|
||||
#define DPRINT_IOCTL(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#define DPRINT_PWR(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#define DPRINT_PNP(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#define DPRINT_SCE(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#define DPRINT_ENUM(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#endif /* not DBG */
|
||||
|
||||
#endif /* DBG_UHUB_H__ */
|
125
reactos/drivers/usb/usbhub_new/debug.c
Normal file
125
reactos/drivers/usb/usbhub_new/debug.c
Normal file
|
@ -0,0 +1,125 @@
|
|||
#include "usbhub.h"
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_DumpingDeviceDescriptor(IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
|
||||
{
|
||||
if (!DeviceDescriptor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DPRINT("Dumping Device Descriptor - %p\n", DeviceDescriptor);
|
||||
DPRINT("bLength - %x\n", DeviceDescriptor->bLength);
|
||||
DPRINT("bDescriptorType - %x\n", DeviceDescriptor->bDescriptorType);
|
||||
DPRINT("bcdUSB - %x\n", DeviceDescriptor->bcdUSB);
|
||||
DPRINT("bDeviceClass - %x\n", DeviceDescriptor->bDeviceClass);
|
||||
DPRINT("bDeviceSubClass - %x\n", DeviceDescriptor->bDeviceSubClass);
|
||||
DPRINT("bDeviceProtocol - %x\n", DeviceDescriptor->bDeviceProtocol);
|
||||
DPRINT("bMaxPacketSize0 - %x\n", DeviceDescriptor->bMaxPacketSize0);
|
||||
DPRINT("idVendor - %x\n", DeviceDescriptor->idVendor);
|
||||
DPRINT("idProduct - %x\n", DeviceDescriptor->idProduct);
|
||||
DPRINT("bcdDevice - %x\n", DeviceDescriptor->bcdDevice);
|
||||
DPRINT("iManufacturer - %x\n", DeviceDescriptor->iManufacturer);
|
||||
DPRINT("iProduct - %x\n", DeviceDescriptor->iProduct);
|
||||
DPRINT("iSerialNumber - %x\n", DeviceDescriptor->iSerialNumber);
|
||||
DPRINT("bNumConfigurations - %x\n", DeviceDescriptor->bNumConfigurations);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_DumpingConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
|
||||
{
|
||||
PUSB_COMMON_DESCRIPTOR Descriptor;
|
||||
PUSB_CONFIGURATION_DESCRIPTOR cDescriptor;
|
||||
PUSB_INTERFACE_DESCRIPTOR iDescriptor;
|
||||
PUSB_ENDPOINT_DESCRIPTOR eDescriptor;
|
||||
|
||||
if (!ConfigDescriptor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Descriptor = (PUSB_COMMON_DESCRIPTOR)ConfigDescriptor;
|
||||
|
||||
while ((ULONG_PTR)Descriptor <
|
||||
((ULONG_PTR)ConfigDescriptor + ConfigDescriptor->wTotalLength) &&
|
||||
Descriptor->bLength)
|
||||
{
|
||||
if (Descriptor->bDescriptorType == USB_CONFIGURATION_DESCRIPTOR_TYPE)
|
||||
{
|
||||
cDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR)Descriptor;
|
||||
|
||||
DPRINT("Dumping cDescriptor - %p\n", cDescriptor);
|
||||
DPRINT("bLength - %x\n", cDescriptor->bLength);
|
||||
DPRINT("bDescriptorType - %x\n", cDescriptor->bDescriptorType);
|
||||
DPRINT("wTotalLength - %x\n", cDescriptor->wTotalLength);
|
||||
DPRINT("bNumInterfaces - %x\n", cDescriptor->bNumInterfaces);
|
||||
DPRINT("bConfigurationValue - %x\n", cDescriptor->bConfigurationValue);
|
||||
DPRINT("iConfiguration - %x\n", cDescriptor->iConfiguration);
|
||||
DPRINT("bmAttributes - %x\n", cDescriptor->bmAttributes);
|
||||
DPRINT("MaxPower - %x\n", cDescriptor->MaxPower);
|
||||
}
|
||||
else if (Descriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE)
|
||||
{
|
||||
iDescriptor = (PUSB_INTERFACE_DESCRIPTOR)Descriptor;
|
||||
|
||||
DPRINT("Dumping iDescriptor - %p\n", iDescriptor);
|
||||
DPRINT("bLength - %x\n", iDescriptor->bLength);
|
||||
DPRINT("bDescriptorType - %x\n", iDescriptor->bDescriptorType);
|
||||
DPRINT("bInterfaceNumber - %x\n", iDescriptor->bInterfaceNumber);
|
||||
DPRINT("bAlternateSetting - %x\n", iDescriptor->bAlternateSetting);
|
||||
DPRINT("bNumEndpoints - %x\n", iDescriptor->bNumEndpoints);
|
||||
DPRINT("bInterfaceClass - %x\n", iDescriptor->bInterfaceClass);
|
||||
DPRINT("bInterfaceSubClass - %x\n", iDescriptor->bInterfaceSubClass);
|
||||
DPRINT("bInterfaceProtocol - %x\n", iDescriptor->bInterfaceProtocol);
|
||||
DPRINT("iInterface - %x\n", iDescriptor->iInterface);
|
||||
}
|
||||
else if (Descriptor->bDescriptorType == USB_ENDPOINT_DESCRIPTOR_TYPE)
|
||||
{
|
||||
eDescriptor = (PUSB_ENDPOINT_DESCRIPTOR)Descriptor;
|
||||
|
||||
DPRINT("Dumping Descriptor - %p\n", eDescriptor);
|
||||
DPRINT("bLength - %x\n", eDescriptor->bLength);
|
||||
DPRINT("bDescriptorType - %x\n", eDescriptor->bDescriptorType);
|
||||
DPRINT("bEndpointAddress - %x\n", eDescriptor->bEndpointAddress);
|
||||
DPRINT("bmAttributes - %x\n", eDescriptor->bmAttributes);
|
||||
DPRINT("wMaxPacketSize - %x\n", eDescriptor->wMaxPacketSize);
|
||||
DPRINT("bInterval - %x\n", eDescriptor->bInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("bDescriptorType - %x\n", Descriptor->bDescriptorType);
|
||||
}
|
||||
|
||||
Descriptor = (PUSB_COMMON_DESCRIPTOR)((ULONG_PTR)Descriptor +
|
||||
Descriptor->bLength);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_DumpingIDs(IN PVOID Id)
|
||||
{
|
||||
PWSTR Ptr;
|
||||
ULONG Length;
|
||||
ULONG TotalLength = 0;
|
||||
|
||||
Ptr = Id;
|
||||
DPRINT("USBHUB_DumpingIDs:\n");
|
||||
|
||||
while (*Ptr)
|
||||
{
|
||||
DPRINT(" %S\n", Ptr);
|
||||
Length = wcslen(Ptr) + 1;
|
||||
|
||||
Ptr += Length;
|
||||
TotalLength += Length;
|
||||
}
|
||||
|
||||
DPRINT("TotalLength: %hu\n", TotalLength);
|
||||
DPRINT("\n");
|
||||
}
|
11
reactos/drivers/usb/usbhub_new/guid.c
Normal file
11
reactos/drivers/usb/usbhub_new/guid.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* DO NOT USE THE PRECOMPILED HEADER FOR THIS FILE! */
|
||||
|
||||
#include <wdm.h>
|
||||
#include <initguid.h>
|
||||
#include <wdmguid.h>
|
||||
#include <usb.h>
|
||||
#include <usbiodef.h>
|
||||
#include <hubbusif.h>
|
||||
#include <usbbusif.h>
|
||||
|
||||
/* NO CODE HERE, THIS IS JUST REQUIRED FOR THE GUID DEFINITIONS */
|
1408
reactos/drivers/usb/usbhub_new/ioctl.c
Normal file
1408
reactos/drivers/usb/usbhub_new/ioctl.c
Normal file
File diff suppressed because it is too large
Load diff
2811
reactos/drivers/usb/usbhub_new/pnp.c
Normal file
2811
reactos/drivers/usb/usbhub_new/pnp.c
Normal file
File diff suppressed because it is too large
Load diff
794
reactos/drivers/usb/usbhub_new/power.c
Normal file
794
reactos/drivers/usb/usbhub_new/power.c
Normal file
|
@ -0,0 +1,794 @@
|
|||
#include "usbhub.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define NDEBUG_USBHUB_POWER
|
||||
#include "dbg_uhub.h"
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_CompletePowerIrp(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp,
|
||||
IN NTSTATUS NtStatus)
|
||||
{
|
||||
DPRINT("USBH_CompletePowerIrp: HubExtension - %p, Irp - %p, NtStatus - %lX\n",
|
||||
HubExtension,
|
||||
Irp,
|
||||
NtStatus);
|
||||
|
||||
Irp->IoStatus.Status = NtStatus;
|
||||
|
||||
PoStartNextPowerIrp(Irp);
|
||||
|
||||
if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
|
||||
{
|
||||
KeSetEvent(&HubExtension->PendingRequestEvent,
|
||||
EVENT_INCREMENT,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubCancelWakeIrp(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
DPRINT("USBH_HubCancelWakeIrp: HubExtension - %p, Irp - %p\n",
|
||||
HubExtension,
|
||||
Irp);
|
||||
|
||||
IoCancelIrp(Irp);
|
||||
|
||||
if (InterlockedExchange((PLONG)&HubExtension->FdoWaitWakeLock, 1))
|
||||
{
|
||||
PoStartNextPowerIrp(Irp);
|
||||
Irp->IoStatus.Status = STATUS_CANCELLED;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubESDRecoverySetD3Completion(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN UCHAR MinorFunction,
|
||||
IN POWER_STATE PowerState,
|
||||
IN PVOID Context,
|
||||
IN PIO_STATUS_BLOCK IoStatus)
|
||||
{
|
||||
DPRINT("USBH_HubESDRecoverySetD3Completion ... \n");
|
||||
|
||||
KeSetEvent((PRKEVENT)Context,
|
||||
EVENT_INCREMENT,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
|
||||
{
|
||||
PUSBHUB_FDO_EXTENSION RootHubDevExt;
|
||||
NTSTATUS Status;
|
||||
KEVENT Event;
|
||||
POWER_STATE PowerState;
|
||||
|
||||
DPRINT("USBH_HubSetD0: HubExtension - %p\n", HubExtension);
|
||||
|
||||
RootHubDevExt = USBH_GetRootHubExtension(HubExtension);
|
||||
|
||||
if (RootHubDevExt->SystemPowerState.SystemState != PowerSystemWorking)
|
||||
{
|
||||
Status = STATUS_INVALID_DEVICE_STATE;
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST)
|
||||
{
|
||||
DPRINT("USBH_HubSetD0: HubFlags - %lX\n", HubExtension->HubFlags);
|
||||
|
||||
KeWaitForSingleObject(&HubExtension->IdleEvent,
|
||||
Suspended,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
|
||||
PowerState.DeviceState = PowerDeviceD0;
|
||||
|
||||
Status = PoRequestPowerIrp(HubExtension->LowerPDO,
|
||||
IRP_MN_SET_POWER,
|
||||
PowerState,
|
||||
USBH_HubESDRecoverySetD3Completion,
|
||||
&Event,
|
||||
NULL);
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
Status = KeWaitForSingleObject(&Event,
|
||||
Suspended,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
while (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAKEUP_START)
|
||||
{
|
||||
USBH_Wait(10);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_IdleCancelPowerHubWorker(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PVOID Context)
|
||||
{
|
||||
PUSBHUB_IDLE_PORT_CANCEL_CONTEXT WorkItemIdlePower;
|
||||
PIRP Irp;
|
||||
|
||||
DPRINT("USBH_IdleCancelPowerHubWorker: ... \n");
|
||||
|
||||
WorkItemIdlePower = Context;
|
||||
|
||||
if (HubExtension &&
|
||||
HubExtension->CurrentPowerState.DeviceState != PowerDeviceD0 &&
|
||||
HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
|
||||
{
|
||||
USBH_HubSetD0(HubExtension);
|
||||
}
|
||||
|
||||
Irp = WorkItemIdlePower->Irp;
|
||||
Irp->IoStatus.Status = STATUS_CANCELLED;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubQueuePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PLIST_ENTRY ListIrps)
|
||||
{
|
||||
PDEVICE_OBJECT PortDevice;
|
||||
PUSBHUB_PORT_PDO_EXTENSION PortExtension;
|
||||
USHORT NumPorts;
|
||||
USHORT Port;
|
||||
PIRP WakeIrp;
|
||||
KIRQL OldIrql;
|
||||
|
||||
DPRINT("USBH_HubQueuePortWakeIrps ... \n");
|
||||
|
||||
NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
|
||||
|
||||
InitializeListHead(ListIrps);
|
||||
|
||||
IoAcquireCancelSpinLock(&OldIrql);
|
||||
|
||||
for (Port = 0; Port < NumPorts; ++Port)
|
||||
{
|
||||
PortDevice = HubExtension->PortData[Port].DeviceObject;
|
||||
|
||||
if (PortDevice)
|
||||
{
|
||||
PortExtension = PortDevice->DeviceExtension;
|
||||
|
||||
WakeIrp = PortExtension->PdoWaitWakeIrp;
|
||||
PortExtension->PdoWaitWakeIrp = NULL;
|
||||
|
||||
if (WakeIrp)
|
||||
{
|
||||
DPRINT1("USBH_HubQueuePortWakeIrps: UNIMPLEMENTED. FIXME\n");
|
||||
DbgBreakPoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IoReleaseCancelSpinLock(OldIrql);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubCompleteQueuedPortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PLIST_ENTRY ListIrps,
|
||||
IN NTSTATUS NtStatus)
|
||||
{
|
||||
DPRINT("USBH_HubCompleteQueuedPortWakeIrps ... \n");
|
||||
|
||||
while (!IsListEmpty(ListIrps))
|
||||
{
|
||||
DPRINT1("USBH_HubCompleteQueuedPortWakeIrps: UNIMPLEMENTED. FIXME\n");
|
||||
DbgBreakPoint();
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubCompletePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN NTSTATUS NtStatus)
|
||||
{
|
||||
LIST_ENTRY ListIrps;
|
||||
|
||||
DPRINT("USBH_HubCompletePortWakeIrps: NtStatus - %x\n", NtStatus);
|
||||
|
||||
if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
|
||||
{
|
||||
USBH_HubQueuePortWakeIrps(HubExtension, &ListIrps);
|
||||
|
||||
USBH_HubCompleteQueuedPortWakeIrps(HubExtension,
|
||||
&ListIrps,
|
||||
NtStatus);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_FdoPoRequestD0Completion(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN UCHAR MinorFunction,
|
||||
IN POWER_STATE PowerState,
|
||||
IN PVOID Context,
|
||||
IN PIO_STATUS_BLOCK IoStatus)
|
||||
{
|
||||
PUSBHUB_FDO_EXTENSION HubExtension;
|
||||
|
||||
DPRINT("USBH_FdoPoRequestD0Completion ... \n");
|
||||
|
||||
HubExtension = Context;
|
||||
|
||||
USBH_HubCompletePortWakeIrps(HubExtension, STATUS_SUCCESS);
|
||||
|
||||
HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_WAKEUP_START;
|
||||
|
||||
if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
|
||||
{
|
||||
KeSetEvent(&HubExtension->PendingRequestEvent,
|
||||
EVENT_INCREMENT,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_CompletePortWakeIrpsWorker(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PVOID Context)
|
||||
{
|
||||
DPRINT1("USBH_CompletePortWakeIrpsWorker: UNIMPLEMENTED. FIXME\n");
|
||||
DbgBreakPoint();
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_FdoWWIrpIoCompletion(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context)
|
||||
{
|
||||
PUSBHUB_FDO_EXTENSION HubExtension;
|
||||
NTSTATUS Status;
|
||||
KIRQL OldIrql;
|
||||
POWER_STATE PowerState;
|
||||
PIRP WakeIrp;
|
||||
|
||||
DPRINT("USBH_FdoWWIrpIoCompletion: DeviceObject - %p, Irp - %p\n",
|
||||
DeviceObject,
|
||||
Irp);
|
||||
|
||||
HubExtension = Context;
|
||||
|
||||
Status = Irp->IoStatus.Status;
|
||||
|
||||
IoAcquireCancelSpinLock(&OldIrql);
|
||||
|
||||
HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_PENDING_WAKE_IRP;
|
||||
|
||||
WakeIrp = InterlockedExchangePointer((PVOID *)&HubExtension->PendingWakeIrp,
|
||||
NULL);
|
||||
|
||||
if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
|
||||
{
|
||||
KeSetEvent(&HubExtension->PendingRequestEvent,
|
||||
EVENT_INCREMENT,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
IoReleaseCancelSpinLock(OldIrql);
|
||||
|
||||
DPRINT("USBH_FdoWWIrpIoCompletion: Status - %lX\n", Status);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("USBH_FdoWWIrpIoCompletion: DbgBreakPoint() \n");
|
||||
DbgBreakPoint();
|
||||
}
|
||||
else
|
||||
{
|
||||
PowerState.DeviceState = PowerDeviceD0;
|
||||
|
||||
HubExtension->HubFlags |= USBHUB_FDO_FLAG_WAKEUP_START;
|
||||
InterlockedIncrement(&HubExtension->PendingRequestCount);
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
PoRequestPowerIrp(HubExtension->LowerPDO,
|
||||
IRP_MN_SET_POWER,
|
||||
PowerState,
|
||||
USBH_FdoPoRequestD0Completion,
|
||||
(PVOID)HubExtension,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (!WakeIrp)
|
||||
{
|
||||
if (!InterlockedExchange(&HubExtension->FdoWaitWakeLock, 1))
|
||||
{
|
||||
Status = STATUS_MORE_PROCESSING_REQUIRED;
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT("USBH_FdoWWIrpIoCompletion: Status - %lX\n", Status);
|
||||
|
||||
if (Status != STATUS_MORE_PROCESSING_REQUIRED)
|
||||
{
|
||||
PoStartNextPowerIrp(Irp);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_PowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context)
|
||||
{
|
||||
PUSBHUB_FDO_EXTENSION HubExtension;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
DEVICE_POWER_STATE OldDeviceState;
|
||||
NTSTATUS Status;
|
||||
POWER_STATE PowerState;
|
||||
|
||||
DPRINT("USBH_PowerIrpCompletion: DeviceObject - %p, Irp - %p\n",
|
||||
DeviceObject,
|
||||
Irp);
|
||||
|
||||
HubExtension = Context;
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
PowerState = IoStack->Parameters.Power.State;
|
||||
|
||||
Status = Irp->IoStatus.Status;
|
||||
DPRINT("USBH_PowerIrpCompletion: Status - %lX\n", Status);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (PowerState.DeviceState == PowerDeviceD0)
|
||||
{
|
||||
PoStartNextPowerIrp(Irp);
|
||||
HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_SET_D0_STATE;
|
||||
}
|
||||
}
|
||||
else if (PowerState.DeviceState == PowerDeviceD0)
|
||||
{
|
||||
HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_SET_D0_STATE;
|
||||
|
||||
OldDeviceState = HubExtension->CurrentPowerState.DeviceState;
|
||||
HubExtension->CurrentPowerState.DeviceState = PowerDeviceD0;
|
||||
|
||||
DPRINT("USBH_PowerIrpCompletion: OldDeviceState - %x\n", OldDeviceState);
|
||||
|
||||
if (HubExtension->HubFlags & USBHUB_FDO_FLAG_HIBERNATE_STATE)
|
||||
{
|
||||
DPRINT1("USBH_PowerIrpCompletion: USBHUB_FDO_FLAG_HIBERNATE_STATE. FIXME\n");
|
||||
DbgBreakPoint();
|
||||
}
|
||||
|
||||
HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_HIBERNATE_STATE;
|
||||
|
||||
if (OldDeviceState == PowerDeviceD3)
|
||||
{
|
||||
DPRINT1("USBH_PowerIrpCompletion: PowerDeviceD3. FIXME\n");
|
||||
DbgBreakPoint();
|
||||
}
|
||||
|
||||
if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED) &&
|
||||
HubExtension->HubFlags & USBHUB_FDO_FLAG_DO_ENUMERATION)
|
||||
{
|
||||
USBH_SubmitStatusChangeTransfer(HubExtension);
|
||||
}
|
||||
|
||||
DPRINT("USBH_PowerIrpCompletion: Status - %lX\n", Status);
|
||||
|
||||
if (Status != STATUS_MORE_PROCESSING_REQUIRED)
|
||||
{
|
||||
PoStartNextPowerIrp(Irp);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_FdoDeferPoRequestCompletion(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN UCHAR MinorFunction,
|
||||
IN POWER_STATE PowerState,
|
||||
IN PVOID Context,
|
||||
IN PIO_STATUS_BLOCK IoStatus)
|
||||
{
|
||||
PUSBHUB_FDO_EXTENSION Extension;
|
||||
PUSBHUB_FDO_EXTENSION HubExtension = NULL;
|
||||
PIRP PowerIrp;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
|
||||
DPRINT("USBH_FdoDeferPoRequestCompletion ... \n");
|
||||
|
||||
Extension = Context;
|
||||
|
||||
PowerIrp = Extension->PowerIrp;
|
||||
|
||||
if (Extension->Common.ExtensionType == USBH_EXTENSION_TYPE_HUB)
|
||||
{
|
||||
HubExtension = Context;
|
||||
}
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(PowerIrp);
|
||||
|
||||
if (IoStack->Parameters.Power.State.SystemState == PowerSystemWorking &&
|
||||
HubExtension && HubExtension->LowerPDO == HubExtension->RootHubPdo)
|
||||
{
|
||||
HubExtension->SystemPowerState.SystemState = PowerSystemWorking;
|
||||
USBH_CheckIdleDeferred(HubExtension);
|
||||
}
|
||||
|
||||
IoCopyCurrentIrpStackLocationToNext(PowerIrp);
|
||||
PoStartNextPowerIrp(PowerIrp);
|
||||
PoCallDriver(Extension->LowerDevice, PowerIrp);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_FdoPower(IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp,
|
||||
IN UCHAR Minor)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
POWER_STATE PowerState;
|
||||
POWER_STATE DevicePwrState;
|
||||
BOOLEAN IsAllPortsD3;
|
||||
PUSBHUB_PORT_DATA PortData;
|
||||
PDEVICE_OBJECT PdoDevice;
|
||||
PUSBHUB_PORT_PDO_EXTENSION PortExtension;
|
||||
ULONG Port;
|
||||
|
||||
DPRINT_PWR("USBH_FdoPower: HubExtension - %p, Irp - %p, Minor - %X\n",
|
||||
HubExtension,
|
||||
Irp,
|
||||
Minor);
|
||||
|
||||
switch (Minor)
|
||||
{
|
||||
case IRP_MN_WAIT_WAKE:
|
||||
DPRINT_PWR("USBH_FdoPower: IRP_MN_WAIT_WAKE\n");
|
||||
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
USBH_FdoWWIrpIoCompletion,
|
||||
HubExtension,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
||||
PoStartNextPowerIrp(Irp);
|
||||
IoMarkIrpPending(Irp);
|
||||
PoCallDriver(HubExtension->LowerDevice, Irp);
|
||||
|
||||
return STATUS_PENDING;
|
||||
|
||||
case IRP_MN_POWER_SEQUENCE:
|
||||
DPRINT_PWR("USBH_FdoPower: IRP_MN_POWER_SEQUENCE\n");
|
||||
break;
|
||||
|
||||
case IRP_MN_SET_POWER:
|
||||
DPRINT_PWR("USBH_FdoPower: IRP_MN_SET_POWER\n");
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
DPRINT_PWR("USBH_FdoPower: IRP_MN_SET_POWER/DevicePowerState\n");
|
||||
PowerState = IoStack->Parameters.Power.State;
|
||||
|
||||
if (IoStack->Parameters.Power.Type == DevicePowerState)
|
||||
{
|
||||
DPRINT_PWR("USBH_FdoPower: PowerState - %x\n",
|
||||
PowerState.DeviceState);
|
||||
|
||||
if (HubExtension->CurrentPowerState.DeviceState == PowerState.DeviceState)
|
||||
{
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
PoStartNextPowerIrp(Irp);
|
||||
IoMarkIrpPending(Irp);
|
||||
PoCallDriver(HubExtension->LowerDevice, Irp);
|
||||
|
||||
return STATUS_PENDING;
|
||||
}
|
||||
|
||||
switch (PowerState.DeviceState)
|
||||
{
|
||||
case PowerDeviceD0:
|
||||
if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_SET_D0_STATE))
|
||||
{
|
||||
HubExtension->HubFlags &= ~(USBHUB_FDO_FLAG_NOT_D0_STATE |
|
||||
USBHUB_FDO_FLAG_DEVICE_STOPPING);
|
||||
|
||||
HubExtension->HubFlags |= USBHUB_FDO_FLAG_SET_D0_STATE;
|
||||
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
USBH_PowerIrpCompletion,
|
||||
HubExtension,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
PoStartNextPowerIrp(Irp);
|
||||
}
|
||||
|
||||
IoMarkIrpPending(Irp);
|
||||
PoCallDriver(HubExtension->LowerDevice, Irp);
|
||||
return STATUS_PENDING;
|
||||
|
||||
case PowerDeviceD1:
|
||||
case PowerDeviceD2:
|
||||
case PowerDeviceD3:
|
||||
if (HubExtension->ResetRequestCount)
|
||||
{
|
||||
IoCancelIrp(HubExtension->ResetPortIrp);
|
||||
|
||||
KeWaitForSingleObject(&HubExtension->ResetEvent,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
|
||||
{
|
||||
HubExtension->HubFlags |= (USBHUB_FDO_FLAG_NOT_D0_STATE |
|
||||
USBHUB_FDO_FLAG_DEVICE_STOPPING);
|
||||
|
||||
IoCancelIrp(HubExtension->SCEIrp);
|
||||
|
||||
KeWaitForSingleObject(&HubExtension->StatusChangeEvent,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
HubExtension->CurrentPowerState.DeviceState = PowerState.DeviceState;
|
||||
|
||||
if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DO_SUSPENSE &&
|
||||
USBH_CheckIdleAbort(HubExtension, TRUE, TRUE) == TRUE)
|
||||
{
|
||||
HubExtension->HubFlags &= ~(USBHUB_FDO_FLAG_NOT_D0_STATE |
|
||||
USBHUB_FDO_FLAG_DEVICE_STOPPING);
|
||||
|
||||
HubExtension->CurrentPowerState.DeviceState = PowerDeviceD0;
|
||||
|
||||
USBH_SubmitStatusChangeTransfer(HubExtension);
|
||||
|
||||
PoStartNextPowerIrp(Irp);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
|
||||
|
||||
KeReleaseSemaphore(&HubExtension->IdleSemaphore,
|
||||
LOW_REALTIME_PRIORITY,
|
||||
1,
|
||||
FALSE);
|
||||
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
USBH_PowerIrpCompletion,
|
||||
HubExtension,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
||||
PoStartNextPowerIrp(Irp);
|
||||
IoMarkIrpPending(Irp);
|
||||
PoCallDriver(HubExtension->LowerDevice, Irp);
|
||||
|
||||
if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DO_SUSPENSE)
|
||||
{
|
||||
HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
|
||||
|
||||
KeReleaseSemaphore(&HubExtension->IdleSemaphore,
|
||||
LOW_REALTIME_PRIORITY,
|
||||
1,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
return STATUS_PENDING;
|
||||
|
||||
default:
|
||||
DPRINT1("USBH_FdoPower: Unsupported PowerState.DeviceState\n");
|
||||
DbgBreakPoint();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PowerState.SystemState != PowerSystemWorking)
|
||||
{
|
||||
USBH_GetRootHubExtension(HubExtension)->SystemPowerState.SystemState =
|
||||
PowerState.SystemState;
|
||||
}
|
||||
|
||||
if (PowerState.SystemState == PowerSystemHibernate)
|
||||
{
|
||||
HubExtension->HubFlags |= USBHUB_FDO_FLAG_HIBERNATE_STATE;
|
||||
}
|
||||
|
||||
PortData = HubExtension->PortData;
|
||||
|
||||
IsAllPortsD3 = TRUE;
|
||||
|
||||
if (PortData && HubExtension->HubDescriptor)
|
||||
{
|
||||
for (Port = 0;
|
||||
Port < HubExtension->HubDescriptor->bNumberOfPorts;
|
||||
Port++)
|
||||
{
|
||||
PdoDevice = PortData[Port].DeviceObject;
|
||||
|
||||
if (PdoDevice)
|
||||
{
|
||||
PortExtension = PdoDevice->DeviceExtension;
|
||||
|
||||
if (PortExtension->CurrentPowerState.DeviceState != PowerDeviceD3)
|
||||
{
|
||||
IsAllPortsD3 = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PowerState.SystemState == PowerSystemWorking)
|
||||
{
|
||||
DevicePwrState.DeviceState = PowerDeviceD0;
|
||||
}
|
||||
else if (HubExtension->HubFlags & USBHUB_FDO_FLAG_PENDING_WAKE_IRP ||
|
||||
!IsAllPortsD3)
|
||||
{
|
||||
DevicePwrState.DeviceState = HubExtension->DeviceState[PowerState.SystemState];
|
||||
|
||||
if (DevicePwrState.DeviceState == PowerDeviceUnspecified)
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DevicePwrState.DeviceState = PowerDeviceD3;
|
||||
}
|
||||
|
||||
if (DevicePwrState.DeviceState != HubExtension->CurrentPowerState.DeviceState &&
|
||||
HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
|
||||
{
|
||||
HubExtension->PowerIrp = Irp;
|
||||
|
||||
IoMarkIrpPending(Irp);
|
||||
|
||||
if (PoRequestPowerIrp(HubExtension->LowerPDO,
|
||||
IRP_MN_SET_POWER,
|
||||
DevicePwrState,
|
||||
USBH_FdoDeferPoRequestCompletion,
|
||||
(PVOID)HubExtension,
|
||||
NULL) == STATUS_PENDING)
|
||||
{
|
||||
return STATUS_PENDING;
|
||||
}
|
||||
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
PoStartNextPowerIrp(Irp);
|
||||
PoCallDriver(HubExtension->LowerDevice, Irp);
|
||||
|
||||
return STATUS_PENDING;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
HubExtension->SystemPowerState.SystemState = PowerState.SystemState;
|
||||
|
||||
if (PowerState.SystemState == PowerSystemWorking)
|
||||
{
|
||||
USBH_CheckIdleDeferred(HubExtension);
|
||||
}
|
||||
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
PoStartNextPowerIrp(Irp);
|
||||
|
||||
return PoCallDriver(HubExtension->LowerDevice, Irp);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case IRP_MN_QUERY_POWER:
|
||||
DPRINT_PWR("USBH_FdoPower: IRP_MN_QUERY_POWER\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT1("USBH_FdoPower: unknown IRP_MN_POWER!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
PoStartNextPowerIrp(Irp);
|
||||
Status = PoCallDriver(HubExtension->LowerDevice, Irp);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_PdoPower(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension,
|
||||
IN PIRP Irp,
|
||||
IN UCHAR Minor)
|
||||
{
|
||||
NTSTATUS Status = Irp->IoStatus.Status;
|
||||
|
||||
DPRINT_PWR("USBH_FdoPower: PortExtension - %p, Irp - %p, Minor - %X\n",
|
||||
PortExtension,
|
||||
Irp,
|
||||
Minor);
|
||||
|
||||
switch (Minor)
|
||||
{
|
||||
case IRP_MN_WAIT_WAKE:
|
||||
DPRINT_PWR("USBHUB_PdoPower: IRP_MN_WAIT_WAKE\n");
|
||||
PoStartNextPowerIrp(Irp);
|
||||
break;
|
||||
|
||||
case IRP_MN_POWER_SEQUENCE:
|
||||
DPRINT_PWR("USBHUB_PdoPower: IRP_MN_POWER_SEQUENCE\n");
|
||||
PoStartNextPowerIrp(Irp);
|
||||
break;
|
||||
|
||||
case IRP_MN_SET_POWER:
|
||||
DPRINT_PWR("USBHUB_PdoPower: IRP_MN_SET_POWER\n");
|
||||
PoStartNextPowerIrp(Irp);
|
||||
break;
|
||||
|
||||
case IRP_MN_QUERY_POWER:
|
||||
DPRINT_PWR("USBHUB_PdoPower: IRP_MN_QUERY_POWER\n");
|
||||
PoStartNextPowerIrp(Irp);
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT1("USBHUB_PdoPower: unknown IRP_MN_POWER!\n");
|
||||
PoStartNextPowerIrp(Irp);
|
||||
break;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return Status;
|
||||
}
|
5047
reactos/drivers/usb/usbhub_new/usbhub.c
Normal file
5047
reactos/drivers/usb/usbhub_new/usbhub.c
Normal file
File diff suppressed because it is too large
Load diff
650
reactos/drivers/usb/usbhub_new/usbhub.h
Normal file
650
reactos/drivers/usb/usbhub_new/usbhub.h
Normal file
|
@ -0,0 +1,650 @@
|
|||
#ifndef _USBHUB_H_
|
||||
#define _USBHUB_H_
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <windef.h>
|
||||
#include <stdio.h>
|
||||
#include <wmistr.h>
|
||||
#include <wmilib.h>
|
||||
#include <wdmguid.h>
|
||||
#include <ntstrsafe.h>
|
||||
#include <usb.h>
|
||||
#include <usbioctl.h>
|
||||
#include <hubbusif.h>
|
||||
#include <usbbusif.h>
|
||||
#include <usbdlib.h>
|
||||
#include <ks.h>
|
||||
#include <drivers/usbport/usbmport.h>
|
||||
|
||||
#define USB_HUB_TAG 'BUHU'
|
||||
|
||||
#define USBH_EXTENSION_TYPE_HUB 0x01
|
||||
#define USBH_EXTENSION_TYPE_PORT 0x02
|
||||
#define USBH_EXTENSION_TYPE_PARENT 0x04
|
||||
#define USBH_EXTENSION_TYPE_FUNCTION 0x08
|
||||
|
||||
#define USBHUB_FDO_FLAG_DEVICE_STARTED (1 << 0)
|
||||
#define USBHUB_FDO_FLAG_DEVICE_STOPPING (1 << 2)
|
||||
#define USBHUB_FDO_FLAG_DEVICE_FAILED (1 << 3)
|
||||
#define USBHUB_FDO_FLAG_REMOTE_WAKEUP (1 << 4)
|
||||
#define USBHUB_FDO_FLAG_DEVICE_STOPPED (1 << 5)
|
||||
#define USBHUB_FDO_FLAG_HUB_BUSY (1 << 6)
|
||||
#define USBHUB_FDO_FLAG_PENDING_WAKE_IRP (1 << 7)
|
||||
#define USBHUB_FDO_FLAG_RESET_PORT_LOCK (1 << 8)
|
||||
#define USBHUB_FDO_FLAG_ESD_RECOVERING (1 << 9)
|
||||
#define USBHUB_FDO_FLAG_SET_D0_STATE (1 << 10)
|
||||
#define USBHUB_FDO_FLAG_NOT_D0_STATE (1 << 11)
|
||||
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST (1 << 12)
|
||||
#define USBHUB_FDO_FLAG_STATE_CHANGING (1 << 13)
|
||||
#define USBHUB_FDO_FLAG_DEVICE_REMOVED (1 << 14)
|
||||
#define USBHUB_FDO_FLAG_USB20_HUB (1 << 15)
|
||||
#define USBHUB_FDO_FLAG_DEFER_CHECK_IDLE (1 << 16)
|
||||
#define USBHUB_FDO_FLAG_WAKEUP_START (1 << 17)
|
||||
#define USBHUB_FDO_FLAG_MULTIPLE_TTS (1 << 18) // High-speed Operating Hub with Multiple TTs
|
||||
#define USBHUB_FDO_FLAG_ENUM_POST_RECOVER (1 << 19)
|
||||
#define USBHUB_FDO_FLAG_DO_ENUMERATION (1 << 20)
|
||||
#define USBHUB_FDO_FLAG_CHECK_IDLE_LOCK (1 << 21)
|
||||
#define USBHUB_FDO_FLAG_HIBERNATE_STATE (1 << 22)
|
||||
#define USBHUB_FDO_FLAG_NOT_ENUMERATED (1 << 23)
|
||||
#define USBHUB_FDO_FLAG_DO_SUSPENSE (1 << 24)
|
||||
#define USBHUB_FDO_FLAG_GOING_IDLE (1 << 25)
|
||||
#define USBHUB_FDO_FLAG_DEVICE_SUSPENDED (1 << 26)
|
||||
#define USBHUB_FDO_FLAG_WITEM_INIT (1 << 27)
|
||||
|
||||
#define USBHUB_PDO_FLAG_HUB_DEVICE (1 << 0)
|
||||
#define USBHUB_PDO_FLAG_MULTI_INTERFACE (1 << 1)
|
||||
#define USBHUB_PDO_FLAG_INIT_PORT_FAILED (1 << 2)
|
||||
#define USBHUB_PDO_FLAG_PORT_LOW_SPEED (1 << 3)
|
||||
#define USBHUB_PDO_FLAG_REMOTE_WAKEUP (1 << 4)
|
||||
#define USBHUB_PDO_FLAG_WAIT_WAKE (1 << 5)
|
||||
#define USBHUB_PDO_FLAG_NOT_CONNECTED (1 << 6)
|
||||
#define USBHUB_PDO_FLAG_DELETE_PENDING (1 << 7)
|
||||
#define USBHUB_PDO_FLAG_POWER_D3 (1 << 8)
|
||||
#define USBHUB_PDO_FLAG_DEVICE_STARTED (1 << 9)
|
||||
#define USBHUB_PDO_FLAG_HS_USB1_DUALMODE (1 << 10)
|
||||
#define USBHUB_PDO_FLAG_REG_DEV_INTERFACE (1 << 11) // SymbolicLink
|
||||
#define USBHUB_PDO_FLAG_PORT_RESTORE_FAIL (1 << 12)
|
||||
#define USBHUB_PDO_FLAG_POWER_D1_OR_D2 (1 << 13)
|
||||
#define USBHUB_PDO_FLAG_OVERCURRENT_PORT (1 << 14)
|
||||
#define USBHUB_PDO_FLAG_REMOVING_PORT_PDO (1 << 15)
|
||||
#define USBHUB_PDO_FLAG_INSUFFICIENT_PWR (1 << 16)
|
||||
#define USBHUB_PDO_FLAG_ALLOC_BNDW_FAILED (1 << 18)
|
||||
#define USBHUB_PDO_FLAG_PORT_RESSETING (1 << 19)
|
||||
#define USBHUB_PDO_FLAG_IDLE_NOTIFICATION (1 << 22)
|
||||
#define USBHUB_PDO_FLAG_PORT_HIGH_SPEED (1 << 23)
|
||||
#define USBHUB_PDO_FLAG_ENUMERATED (1 << 26)
|
||||
|
||||
#define USBHUB_ENUM_FLAG_DEVICE_PRESENT 0x01
|
||||
#define USBHUB_ENUM_FLAG_GHOST_DEVICE 0x02
|
||||
|
||||
/* Hub Class Feature Selectors */
|
||||
#define USBHUB_FEATURE_USBHUB_FEATURE_C_HUB_LOCAL_POWER 0
|
||||
#define USBHUB_FEATURE_C_HUB_OVER_CURRENT 1
|
||||
|
||||
#define USBHUB_FEATURE_PORT_CONNECTION 0
|
||||
#define USBHUB_FEATURE_PORT_ENABLE 1
|
||||
#define USBHUB_FEATURE_PORT_SUSPEND 2
|
||||
#define USBHUB_FEATURE_PORT_OVER_CURRENT 3
|
||||
#define USBHUB_FEATURE_PORT_RESET 4
|
||||
#define USBHUB_FEATURE_PORT_POWER 8
|
||||
#define USBHUB_FEATURE_PORT_LOW_SPEED 9
|
||||
#define USBHUB_FEATURE_C_PORT_CONNECTION 16
|
||||
#define USBHUB_FEATURE_C_PORT_ENABLE 17
|
||||
#define USBHUB_FEATURE_C_PORT_SUSPEND 18
|
||||
#define USBHUB_FEATURE_C_PORT_OVER_CURRENT 19
|
||||
#define USBHUB_FEATURE_C_PORT_RESET 20
|
||||
#define USBHUB_FEATURE_PORT_TEST 21
|
||||
#define USBHUB_FEATURE_PORT_INDICATOR 22
|
||||
|
||||
#define USBHUB_MAX_CASCADE_LEVELS 6
|
||||
#define USBHUB_RESET_PORT_MAX_RETRY 3
|
||||
#define USBHUB_MAX_REQUEST_ERRORS 3
|
||||
|
||||
|
||||
#define USBHUB_FAIL_NO_FAIL 5
|
||||
#define USBHUB_FAIL_NESTED_TOO_DEEPLY 6
|
||||
#define USBHUB_FAIL_OVERCURRENT 7
|
||||
|
||||
extern PWSTR GenericUSBDeviceString;
|
||||
|
||||
typedef struct _USBHUB_PORT_DATA {
|
||||
USBHUB_PORT_STATUS PortStatus;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
USB_CONNECTION_STATUS ConnectionStatus;
|
||||
ULONG PortAttributes;
|
||||
} USBHUB_PORT_DATA, *PUSBHUB_PORT_DATA;
|
||||
|
||||
typedef struct _USBHUB_FDO_EXTENSION *PUSBHUB_FDO_EXTENSION;
|
||||
|
||||
typedef VOID
|
||||
(NTAPI * PUSBHUB_WORKER_ROUTINE)(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PVOID Context);
|
||||
|
||||
typedef struct _USBHUB_IO_WORK_ITEM {
|
||||
ULONG Reserved;
|
||||
LIST_ENTRY HubWorkItemLink;
|
||||
LONG HubWorkerQueued;
|
||||
PIO_WORKITEM HubWorkItem;
|
||||
WORK_QUEUE_TYPE HubWorkItemType;
|
||||
PUSBHUB_FDO_EXTENSION HubExtension;
|
||||
PUSBHUB_WORKER_ROUTINE HubWorkerRoutine;
|
||||
PVOID HubWorkItemBuffer;
|
||||
} USBHUB_IO_WORK_ITEM, *PUSBHUB_IO_WORK_ITEM;
|
||||
|
||||
typedef struct _COMMON_DEVICE_EXTENSION {
|
||||
ULONG ExtensionType;
|
||||
PDEVICE_OBJECT SelfDevice;
|
||||
} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
|
||||
|
||||
typedef struct _USBHUB_FDO_EXTENSION {
|
||||
COMMON_DEVICE_EXTENSION Common;
|
||||
PDEVICE_OBJECT LowerPDO;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
PDEVICE_OBJECT RootHubPdo;
|
||||
PDEVICE_OBJECT RootHubPdo2;
|
||||
KEVENT LowerDeviceEvent;
|
||||
ULONG HubFlags;
|
||||
USB_BUS_INTERFACE_HUB_V5 BusInterface;
|
||||
USB_BUS_INTERFACE_USBDI_V2 BusInterfaceUSBDI;
|
||||
DEVICE_POWER_STATE DeviceState[POWER_SYSTEM_MAXIMUM];
|
||||
SYSTEM_POWER_STATE SystemWake;
|
||||
DEVICE_POWER_STATE DeviceWake;
|
||||
POWER_STATE CurrentPowerState;
|
||||
POWER_STATE SystemPowerState;
|
||||
ULONG MaxPowerPerPort;
|
||||
USB_DEVICE_DESCRIPTOR HubDeviceDescriptor;
|
||||
USHORT Port;
|
||||
PUSB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor;
|
||||
PUSB_HUB_DESCRIPTOR HubDescriptor;
|
||||
PUSBHUB_PORT_DATA PortData;
|
||||
USBD_CONFIGURATION_HANDLE ConfigHandle;
|
||||
USBD_PIPE_INFORMATION PipeInfo;
|
||||
PIRP SCEIrp;
|
||||
PIRP ResetPortIrp;
|
||||
PVOID SCEBitmap; // 11.12.4 Hub and Port Status Change Bitmap (USB 2.0 Specification)
|
||||
ULONG SCEBitmapLength;
|
||||
KEVENT RootHubNotificationEvent;
|
||||
struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST SCEWorkerUrb;
|
||||
KEVENT StatusChangeEvent;
|
||||
KSEMAPHORE IdleSemaphore;
|
||||
KSPIN_LOCK RelationsWorkerSpinLock;
|
||||
LIST_ENTRY PdoList;
|
||||
LONG PendingRequestCount;
|
||||
KEVENT PendingRequestEvent;
|
||||
KSEMAPHORE ResetDeviceSemaphore;
|
||||
PRKEVENT pResetPortEvent;
|
||||
KSEMAPHORE HubPortSemaphore;
|
||||
LONG ResetRequestCount;
|
||||
KEVENT ResetEvent;
|
||||
PIRP PendingIdleIrp;
|
||||
PIRP PendingWakeIrp;
|
||||
LONG FdoWaitWakeLock;
|
||||
LIST_ENTRY WorkItemList;
|
||||
KSPIN_LOCK WorkItemSpinLock;
|
||||
KSPIN_LOCK CheckIdleSpinLock;
|
||||
KEVENT IdleEvent;
|
||||
LONG IdleRequestLock;
|
||||
ULONG RequestErrors;
|
||||
KSEMAPHORE HubSemaphore;
|
||||
PUSBHUB_IO_WORK_ITEM WorkItemToQueue;
|
||||
USB_IDLE_CALLBACK_INFO IdleCallbackInfo;
|
||||
USBHUB_PORT_STATUS PortStatus;
|
||||
PIRP PowerIrp;
|
||||
} USBHUB_FDO_EXTENSION, *PUSBHUB_FDO_EXTENSION;
|
||||
|
||||
typedef struct _USBHUB_PORT_PDO_EXTENSION {
|
||||
COMMON_DEVICE_EXTENSION Common;
|
||||
ULONG PortPdoFlags;
|
||||
ULONG EnumFlags;
|
||||
UNICODE_STRING SymbolicLinkName;
|
||||
WCHAR InstanceID[4];
|
||||
PUSBHUB_FDO_EXTENSION HubExtension;
|
||||
PUSBHUB_FDO_EXTENSION RootHubExtension;
|
||||
PUSB_DEVICE_HANDLE DeviceHandle;
|
||||
USHORT PortNumber;
|
||||
USHORT SN_DescriptorLength;
|
||||
BOOL IgnoringHwSerial;
|
||||
LPWSTR SerialNumber; // serial number string
|
||||
USB_DEVICE_DESCRIPTOR DeviceDescriptor;
|
||||
USB_DEVICE_DESCRIPTOR OldDeviceDescriptor;
|
||||
USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor;
|
||||
USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
|
||||
USHORT Reserved1;
|
||||
PIRP IdleNotificationIrp;
|
||||
POWER_STATE CurrentPowerState;
|
||||
DEVICE_CAPABILITIES Capabilities;
|
||||
ULONG MaxPower;
|
||||
PVOID BndwTimeoutContext;
|
||||
KSPIN_LOCK PortTimeoutSpinLock;
|
||||
LIST_ENTRY PortLink;
|
||||
LONG PoRequestCounter;
|
||||
LONG PendingSystemPoRequest;
|
||||
LONG PendingDevicePoRequest;
|
||||
LONG StateBehindD2;
|
||||
PIRP PdoWaitWakeIrp;
|
||||
LIST_ENTRY PortPowerList;
|
||||
KSPIN_LOCK PortPowerListSpinLock;
|
||||
} USBHUB_PORT_PDO_EXTENSION, *PUSBHUB_PORT_PDO_EXTENSION;
|
||||
|
||||
typedef struct _USBHUB_URB_TIMEOUT_CONTEXT {
|
||||
PIRP Irp;
|
||||
KEVENT UrbTimeoutEvent;
|
||||
KDPC UrbTimeoutDPC;
|
||||
KTIMER UrbTimeoutTimer;
|
||||
KSPIN_LOCK UrbTimeoutSpinLock;
|
||||
BOOL IsNormalCompleted;
|
||||
} USBHUB_URB_TIMEOUT_CONTEXT, *PUSBHUB_URB_TIMEOUT_CONTEXT;
|
||||
|
||||
typedef struct _USBHUB_STATUS_CHANGE_CONTEXT {
|
||||
ULONG Reserved;
|
||||
BOOL IsRequestErrors;
|
||||
PUSBHUB_FDO_EXTENSION HubExtension;
|
||||
} USBHUB_STATUS_CHANGE_CONTEXT, *PUSBHUB_STATUS_CHANGE_CONTEXT;
|
||||
|
||||
typedef struct _USBHUB_IDLE_HUB_CONTEXT {
|
||||
ULONG Reserved;
|
||||
NTSTATUS Status;
|
||||
} USBHUB_IDLE_HUB_CONTEXT, *PUSBHUB_IDLE_HUB_CONTEXT;
|
||||
|
||||
typedef struct _USBHUB_IDLE_PORT_CONTEXT {
|
||||
ULONG Reserved;
|
||||
LIST_ENTRY PwrList;
|
||||
NTSTATUS Status;
|
||||
} USBHUB_IDLE_PORT_CONTEXT, *PUSBHUB_IDLE_PORT_CONTEXT;
|
||||
|
||||
typedef struct _USBHUB_IDLE_PORT_CANCEL_CONTEXT {
|
||||
ULONG Reserved;
|
||||
PIRP Irp;
|
||||
} USBHUB_IDLE_PORT_CANCEL_CONTEXT, *PUSBHUB_IDLE_PORT_CANCEL_CONTEXT;
|
||||
|
||||
typedef struct _USBHUB_RESET_PORT_CONTEXT {
|
||||
ULONG Reserved;
|
||||
PUSBHUB_PORT_PDO_EXTENSION PortExtension;
|
||||
PIRP Irp;
|
||||
} USBHUB_RESET_PORT_CONTEXT, *PUSBHUB_RESET_PORT_CONTEXT;
|
||||
|
||||
/* debug.c */
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_DumpingDeviceDescriptor(
|
||||
IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_DumpingConfiguration(
|
||||
IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_DumpingIDs(
|
||||
IN PVOID Id);
|
||||
|
||||
/* ioctl.c */
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_DeviceControl(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_PdoInternalControl(
|
||||
IN PUSBHUB_PORT_PDO_EXTENSION PortExtension,
|
||||
IN PIRP Irp);
|
||||
|
||||
/* pnp.c */
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_PdoRemoveDevice(
|
||||
IN PUSBHUB_PORT_PDO_EXTENSION PortExtension,
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_FdoPnP(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp,
|
||||
IN UCHAR Minor);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_PdoPnP(
|
||||
IN PUSBHUB_PORT_PDO_EXTENSION PortExtension,
|
||||
IN PIRP Irp,
|
||||
IN UCHAR Minor,
|
||||
OUT BOOLEAN * IsCompleteIrp);
|
||||
|
||||
/* power.c */
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_CompletePowerIrp(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp,
|
||||
IN NTSTATUS NtStatus);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_HubSetD0(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_FdoPower(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp,
|
||||
IN UCHAR Minor);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_PdoPower(
|
||||
IN PUSBHUB_PORT_PDO_EXTENSION PortExtension,
|
||||
IN PIRP Irp,
|
||||
IN UCHAR Minor);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubCompletePortWakeIrps(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN NTSTATUS NtStatus);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubCancelWakeIrp(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP Irp);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_IdleCancelPowerHubWorker(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PVOID Context);
|
||||
|
||||
/* usbhub.c */
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_Wait(
|
||||
IN ULONG Milliseconds);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_CompleteIrp(
|
||||
IN PIRP Irp,
|
||||
IN NTSTATUS CompleteStatus);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_PassIrp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
PUSBHUB_PORT_PDO_EXTENSION
|
||||
NTAPI
|
||||
PdoExt(
|
||||
IN PDEVICE_OBJECT DeviceObject);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_WriteFailReasonID(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN ULONG Data);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SetPdoRegistryParameter(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PCWSTR SourceString,
|
||||
IN PVOID Data,
|
||||
IN ULONG DataSize,
|
||||
IN ULONG Type,
|
||||
IN ULONG DevInstKeyType);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncSubmitUrb(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PURB Urb);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_FdoSyncSubmitUrb(
|
||||
IN PDEVICE_OBJECT FdoDevice,
|
||||
IN PURB Urb);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncResetPort(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN USHORT Port);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_GetDeviceType(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PUSB_DEVICE_HANDLE DeviceHandle,
|
||||
OUT USB_DEVICE_TYPE * OutDeviceType);
|
||||
|
||||
PUSBHUB_FDO_EXTENSION
|
||||
NTAPI
|
||||
USBH_GetRootHubExtension(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncGetRootHubPdo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PDEVICE_OBJECT * OutPdo1,
|
||||
IN OUT PDEVICE_OBJECT * OutPdo2);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncGetHubCount(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PULONG OutHubCount);
|
||||
|
||||
PUSB_DEVICE_HANDLE
|
||||
NTAPI
|
||||
USBH_SyncGetDeviceHandle(
|
||||
IN PDEVICE_OBJECT DeviceObject);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_GetDeviceDescriptor(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PUSB_DEVICE_DESCRIPTOR HubDeviceDescriptor);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_GetConfigurationDescriptor(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PUSB_CONFIGURATION_DESCRIPTOR * pConfigurationDescriptor);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncGetHubDescriptor(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncGetStringDescriptor(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN UCHAR Index,
|
||||
IN USHORT LanguageId,
|
||||
IN PUSB_STRING_DESCRIPTOR Descriptor,
|
||||
IN ULONG NumberOfBytes,
|
||||
IN PULONG OutLength,
|
||||
IN BOOLEAN IsValidateLength);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncGetPortStatus(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN USHORT Port,
|
||||
IN PUSBHUB_PORT_STATUS PortStatus,
|
||||
IN ULONG Length);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncClearPortStatus(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN USHORT Port,
|
||||
IN USHORT RequestValue);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncPowerOnPorts(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SyncDisablePort(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN USHORT Port);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
USBH_HubIsBusPowered(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PUSB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_SubmitStatusChangeTransfer(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBD_CreateDeviceEx(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PUSB_DEVICE_HANDLE * OutDeviceHandle,
|
||||
IN USB_PORT_STATUS UsbPortStatus,
|
||||
IN USHORT Port);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBD_RemoveDeviceEx(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PUSB_DEVICE_HANDLE DeviceHandle,
|
||||
IN ULONG Flags);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBD_InitializeDeviceEx(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PUSB_DEVICE_HANDLE DeviceHandle,
|
||||
IN PUCHAR DeviceDescriptorBuffer,
|
||||
IN ULONG DeviceDescriptorBufferLength,
|
||||
IN PUCHAR ConfigDescriptorBuffer,
|
||||
IN ULONG ConfigDescriptorBufferLength);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_SetDeviceHandleData(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PDEVICE_OBJECT UsbDevicePdo,
|
||||
IN PVOID DeviceHandle);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBHUB_FlushAllTransfers(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBD_GetDeviceInformationEx(
|
||||
IN PUSBHUB_PORT_PDO_EXTENSION PortExtension,
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PUSB_NODE_CONNECTION_INFORMATION_EX Info,
|
||||
IN ULONG Length,
|
||||
IN PUSB_DEVICE_HANDLE DeviceHandle);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBD_RestoreDeviceEx(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN OUT PUSB_DEVICE_HANDLE OldDeviceHandle,
|
||||
IN OUT PUSB_DEVICE_HANDLE NewDeviceHandle);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_AllocateWorkItem(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
OUT PUSBHUB_IO_WORK_ITEM * OutHubIoWorkItem,
|
||||
IN PUSBHUB_WORKER_ROUTINE WorkerRoutine,
|
||||
IN SIZE_T BufferLength,
|
||||
OUT PVOID * OutHubWorkItemBuffer,
|
||||
IN WORK_QUEUE_TYPE Type);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_QueueWorkItem(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PUSBHUB_IO_WORK_ITEM HubIoWorkItem);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_FreeWorkItem(
|
||||
IN PUSBHUB_IO_WORK_ITEM HubIoWorkItem);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBD_RegisterRootHubCallBack(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBD_UnRegisterRootHubCallBack(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_HubCancelIdleIrp(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN PIRP IdleIrp);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
USBH_CheckIdleAbort(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN BOOLEAN IsWait,
|
||||
IN BOOLEAN IsExtCheck);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_CheckHubIdle(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
USBH_CheckIdleDeferred(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_CheckDeviceLanguage(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN USHORT LanguageId);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_CreateDevice(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN USHORT Port,
|
||||
IN USB_PORT_STATUS UsbPortStatus,
|
||||
IN ULONG IsWait);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBH_ResetDevice(
|
||||
IN PUSBHUB_FDO_EXTENSION HubExtension,
|
||||
IN USHORT Port,
|
||||
IN BOOLEAN IsKeepDeviceData,
|
||||
IN BOOLEAN IsWait);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
DriverEntry(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath);
|
||||
|
||||
#endif /* _USBHUB_H_ */
|
5
reactos/drivers/usb/usbhub_new/usbhub.rc
Normal file
5
reactos/drivers/usb/usbhub_new/usbhub.rc
Normal file
|
@ -0,0 +1,5 @@
|
|||
#define REACTOS_VERSION_DLL
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Hub Driver for USB"
|
||||
#define REACTOS_STR_INTERNAL_NAME "usbhub"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "usbhub.sys"
|
||||
#include <reactos/version.rc>
|
Loading…
Reference in a new issue