mirror of
https://github.com/reactos/reactos.git
synced 2024-09-12 13:54:41 +00:00
![Cameron Gutman](/assets/img/avatar_default.png)
- Missed a fix from last commit - Wait for the device status change work item to complete - The USB stack is now properly constructed for USB booting svn path=/branches/usb-bringup-trunk/; revision=55339
173 lines
4.2 KiB
C
173 lines
4.2 KiB
C
#pragma once
|
|
|
|
#define NDEBUG
|
|
#include <ntifs.h>
|
|
#include <ntddk.h>
|
|
#include <wdmguid.h>
|
|
#include <hubbusif.h>
|
|
#include <usbbusif.h>
|
|
#include <usbioctl.h>
|
|
#include <usb.h>
|
|
#include <stdio.h>
|
|
#include <usbdlib.h>
|
|
#include <debug.h>
|
|
//BROKEN: #include <usbprotocoldefs.h>
|
|
#include <pseh/pseh2.h>
|
|
|
|
#define USB_HUB_TAG 'hbsu'
|
|
#define USB_MAXCHILDREN 127
|
|
|
|
// Lifted from broken header above
|
|
#define C_HUB_LOCAL_POWER 0
|
|
#define C_HUB_OVER_CURRENT 1
|
|
#define PORT_CONNECTION 0
|
|
#define PORT_ENABLE 1
|
|
#define PORT_SUSPEND 2
|
|
#define PORT_OVER_CURRENT 3
|
|
#define PORT_RESET 4
|
|
#define PORT_POWER 8
|
|
#define PORT_LOW_SPEED 9
|
|
#define C_PORT_CONNECTION 16
|
|
#define C_PORT_ENABLE 17
|
|
#define C_PORT_SUSPEND 18
|
|
#define C_PORT_OVER_CURRENT 19
|
|
#define C_PORT_RESET 20
|
|
#define PORT_TEST 21
|
|
#define PORT_INDICATOR 22
|
|
|
|
typedef struct _PORT_STATUS_CHANGE
|
|
{
|
|
USHORT Status;
|
|
USHORT Change;
|
|
} PORT_STATUS_CHANGE, *PPORT_STATUS_CHANGE;
|
|
|
|
typedef struct _WORK_ITEM_DATA
|
|
{
|
|
WORK_QUEUE_ITEM WorkItem;
|
|
KEVENT Event;
|
|
PVOID Context;
|
|
} WORK_ITEM_DATA, *PWORK_ITEM_DATA;
|
|
|
|
typedef struct
|
|
{
|
|
BOOLEAN IsFDO;
|
|
} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
|
|
|
|
typedef struct _HUB_CHILDDEVICE_EXTENSION
|
|
{
|
|
COMMON_DEVICE_EXTENSION Common;
|
|
PDEVICE_OBJECT ParentDeviceObject;
|
|
PUSB_DEVICE_HANDLE UsbDeviceHandle;
|
|
ULONG PortNumber;
|
|
UNICODE_STRING usDeviceId;
|
|
UNICODE_STRING usInstanceId;
|
|
UNICODE_STRING usHardwareIds;
|
|
UNICODE_STRING usCompatibleIds;
|
|
UNICODE_STRING usTextDescription;
|
|
UNICODE_STRING usLocationInformation;
|
|
USB_DEVICE_DESCRIPTOR DeviceDesc;
|
|
PUSB_CONFIGURATION_DESCRIPTOR FullConfigDesc;
|
|
UNICODE_STRING SymbolicLinkName;
|
|
} HUB_CHILDDEVICE_EXTENSION, *PHUB_CHILDDEVICE_EXTENSION;
|
|
|
|
typedef struct _HUB_DEVICE_EXTENSION
|
|
{
|
|
COMMON_DEVICE_EXTENSION Common;
|
|
PDEVICE_OBJECT LowerDeviceObject;
|
|
ULONG ChildCount;
|
|
PDEVICE_OBJECT ChildDeviceObject[USB_MAXCHILDREN];
|
|
PDEVICE_OBJECT RootHubPhysicalDeviceObject;
|
|
PDEVICE_OBJECT RootHubFunctionalDeviceObject;
|
|
|
|
ULONG NumberOfHubs;
|
|
|
|
PORT_STATUS_CHANGE *PortStatusChange;
|
|
URB PendingSCEUrb;
|
|
PIRP PendingSCEIrp;
|
|
|
|
USB_BUS_INTERFACE_HUB_V5 HubInterface;
|
|
USB_BUS_INTERFACE_USBDI_V2 UsbDInterface;
|
|
|
|
USB_HUB_DESCRIPTOR HubDescriptor;
|
|
USB_DEVICE_DESCRIPTOR HubDeviceDescriptor;
|
|
USB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor;
|
|
USB_INTERFACE_DESCRIPTOR HubInterfaceDescriptor;
|
|
USB_ENDPOINT_DESCRIPTOR HubEndPointDescriptor;
|
|
|
|
USB_EXTHUB_INFORMATION_0 UsbExtHubInfo;
|
|
USB_DEVICE_INFORMATION_0 DeviceInformation;
|
|
|
|
USBD_CONFIGURATION_HANDLE ConfigurationHandle;
|
|
USBD_PIPE_HANDLE PipeHandle;
|
|
PVOID RootHubHandle;
|
|
|
|
UNICODE_STRING SymbolicLinkName;
|
|
} HUB_DEVICE_EXTENSION, *PHUB_DEVICE_EXTENSION;
|
|
|
|
// createclose.c
|
|
NTSTATUS NTAPI
|
|
USBHUB_Create(
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp);
|
|
|
|
NTSTATUS NTAPI
|
|
USBHUB_Close(
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp);
|
|
|
|
NTSTATUS NTAPI
|
|
USBHUB_Cleanup(
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp);
|
|
|
|
// fdo.c
|
|
NTSTATUS
|
|
USBHUB_FdoHandleDeviceControl(
|
|
PDEVICE_OBJECT DeviceObject,
|
|
PIRP Irp);
|
|
|
|
NTSTATUS
|
|
USBHUB_FdoHandlePnp(
|
|
PDEVICE_OBJECT DeviceObject,
|
|
PIRP Irp);
|
|
|
|
// misc.c
|
|
NTSTATUS
|
|
ForwardIrpAndWait(
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp);
|
|
|
|
NTSTATUS
|
|
ForwardIrpAndForget(
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp);
|
|
|
|
// pdo.c
|
|
NTSTATUS
|
|
USBHUB_PdoHandlePnp(
|
|
PDEVICE_OBJECT DeviceObject,
|
|
PIRP Irp);
|
|
|
|
NTSTATUS
|
|
USBHUB_PdoHandleInternalDeviceControl(
|
|
PDEVICE_OBJECT DeviceObject,
|
|
PIRP Irp);
|
|
|
|
VOID
|
|
DumpDeviceDescriptor(
|
|
PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
|
|
|
|
VOID
|
|
DumpConfigurationDescriptor(
|
|
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
|
|
|
|
VOID
|
|
DumpFullConfigurationDescriptor(
|
|
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
|
|
|
|
NTSTATUS
|
|
GetPortStatusAndChange(
|
|
IN PDEVICE_OBJECT RootHubDeviceObject,
|
|
IN ULONG PortId,
|
|
OUT PPORT_STATUS_CHANGE StatusChange);
|