[usb/usbehci]:

- Remove all hardware related structs from usbehci.h as they are now in hardware.h.
- Add debugging routines for usb descriptors, queue heads and transfer descriptors.
- This will break building usbehci, but not a problem as it is not included in the default build. Will be fixed with later commit.

svn path=/trunk/; revision=50231
This commit is contained in:
Michael Martin 2010-12-31 12:26:12 +00:00
parent 61f99c89a6
commit 0d6bdbec51
2 changed files with 137 additions and 271 deletions

View file

@ -2,7 +2,7 @@
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbehci/common.c
* PURPOSE: Common operations in FDO/PDO.
* PURPOSE: Common operations.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
*/
@ -12,7 +12,109 @@
#include <wdmguid.h>
#include <stdio.h>
/* PUBLIC AND PRIVATE FUNCTIONS ***********************************************/
VOID
DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
{
DPRINT1("Dumping Device Descriptor %x\n", DeviceDescriptor);
DPRINT1("bLength %x\n", DeviceDescriptor->bLength);
DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor);
DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct);
DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct);
DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
DPRINT1("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
}
VOID
DumpFullConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
{
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
LONG i, j;
DPRINT1("Dumping ConfigurationDescriptor %x\n", ConfigurationDescriptor);
DPRINT1("bLength %x\n", ConfigurationDescriptor->bLength);
DPRINT1("bDescriptorType %x\n", ConfigurationDescriptor->bDescriptorType);
DPRINT1("wTotalLength %x\n", ConfigurationDescriptor->wTotalLength);
DPRINT1("bNumInterfaces %x\n", ConfigurationDescriptor->bNumInterfaces);
DPRINT1("bConfigurationValue %x\n", ConfigurationDescriptor->bConfigurationValue);
DPRINT1("iConfiguration %x\n", ConfigurationDescriptor->iConfiguration);
DPRINT1("bmAttributes %x\n", ConfigurationDescriptor->bmAttributes);
DPRINT1("MaxPower %x\n", ConfigurationDescriptor->MaxPower);
InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR) ((ULONG_PTR)ConfigurationDescriptor + sizeof(USB_CONFIGURATION_DESCRIPTOR));
for (i=0; i < ConfigurationDescriptor->bNumInterfaces; i++)
{
DPRINT1("- Dumping InterfaceDescriptor %x\n", InterfaceDescriptor);
DPRINT1(" bLength %x\n", InterfaceDescriptor->bLength);
DPRINT1(" bDescriptorType %x\n", InterfaceDescriptor->bDescriptorType);
DPRINT1(" bInterfaceNumber %x\n", InterfaceDescriptor->bInterfaceNumber);
DPRINT1(" bAlternateSetting %x\n", InterfaceDescriptor->bAlternateSetting);
DPRINT1(" bNumEndpoints %x\n", InterfaceDescriptor->bNumEndpoints);
DPRINT1(" bInterfaceClass %x\n", InterfaceDescriptor->bInterfaceClass);
DPRINT1(" bInterfaceSubClass %x\n", InterfaceDescriptor->bInterfaceSubClass);
DPRINT1(" bInterfaceProtocol %x\n", InterfaceDescriptor->bInterfaceProtocol);
DPRINT1(" iInterface %x\n", InterfaceDescriptor->iInterface);
EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)InterfaceDescriptor + sizeof(USB_INTERFACE_DESCRIPTOR));
for (j=0; j < InterfaceDescriptor->bNumEndpoints; j++)
{
DPRINT1(" bLength %x\n", EndpointDescriptor->bLength);
DPRINT1(" bDescriptorType %x\n", EndpointDescriptor->bDescriptorType);
DPRINT1(" bEndpointAddress %x\n", EndpointDescriptor->bEndpointAddress);
DPRINT1(" bmAttributes %x\n", EndpointDescriptor->bmAttributes);
DPRINT1(" wMaxPacketSize %x\n", EndpointDescriptor->wMaxPacketSize);
DPRINT1(" bInterval %x\n", EndpointDescriptor->bInterval);
EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)EndpointDescriptor + sizeof(USB_ENDPOINT_DESCRIPTOR));
}
InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)(ULONG_PTR)EndpointDescriptor;
}
}
VOID
DumpQueueHead(PQUEUE_HEAD QueueHead)
{
DPRINT1("Dumping QueueHead %x\n", QueueHead);
DPRINT1(" CurrentLinkPointer %x\n", QueueHead->CurrentLinkPointer);
DPRINT1(" NextPointer %x\n", QueueHead->NextPointer);
DPRINT1(" AlternateNextPointer %x\n", QueueHead->AlternateNextPointer);
DPRINT1(" HorizontalLinkPointer %x\n", QueueHead->HorizontalLinkPointer);
DPRINT1(" Active %x\n", QueueHead->Token.Bits.Active);
DPRINT1(" Halted %x\n", QueueHead->Token.Bits.Halted);
DPRINT1(" DataBufferError %x\n", QueueHead->Token.Bits.DataBufferError);
DPRINT1(" BabbleDetected %x\n", QueueHead->Token.Bits.BabbleDetected);
DPRINT1(" TransactionError %x\n", QueueHead->Token.Bits.TransactionError);
DPRINT1(" MissedMicroFrame %x\n", QueueHead->Token.Bits.MissedMicroFrame);
DPRINT1(" PingState %x\n", QueueHead->Token.Bits.PingState);
DPRINT1(" SplitTransactionState %x\n", QueueHead->Token.Bits.SplitTransactionState);
DPRINT1(" ErrorCounter %x\n", QueueHead->Token.Bits.ErrorCounter);
DPRINT1(" First TransferDescriptor %x\n", QueueHead->TransferDescriptor);
}
VOID
DumpTransferDescriptor(PQUEUE_TRANSFER_DESCRIPTOR TransferDescriptor)
{
DPRINT1("Dumping Descriptor %x\n", TransferDescriptor);
DPRINT1(" Active %x\n", TransferDescriptor->Token.Bits.Active);
DPRINT1(" Halted %x\n", TransferDescriptor->Token.Bits.Halted);
DPRINT1(" DataBufferError %x\n", TransferDescriptor->Token.Bits.DataBufferError);
DPRINT1(" BabbleDetected %x\n", TransferDescriptor->Token.Bits.BabbleDetected);
DPRINT1(" TransactionError %x\n", TransferDescriptor->Token.Bits.TransactionError);
DPRINT1(" MissedMicroFrame %x\n", TransferDescriptor->Token.Bits.MissedMicroFrame);
DPRINT1(" PingState %x\n", TransferDescriptor->Token.Bits.PingState);
DPRINT1(" SplitTransactionState %x\n", TransferDescriptor->Token.Bits.SplitTransactionState);
DPRINT1(" ErrorCounter %x\n", TransferDescriptor->Token.Bits.ErrorCounter);
}
NTSTATUS NTAPI
GetBusInterface(PDEVICE_OBJECT DeviceObject, PBUS_INTERFACE_STANDARD busInterface)

View file

@ -1,5 +1,6 @@
#pragma once
#include "hardware.h"
#include <ntifs.h>
#include <ntddk.h>
#include <stdio.h>
@ -15,68 +16,12 @@
#define DEVICESTARTED 0x02
#define DEVICEBUSY 0x04
#define DEVICESTOPPED 0x08
#define DEVICESTALLED 0x10
#define MAX_USB_DEVICES 127
#define EHCI_MAX_SIZE_TRANSFER 0x100000
/* USB Command Register */
#define EHCI_USBCMD 0x00
#define EHCI_USBSTS 0x04
#define EHCI_USBINTR 0x08
#define EHCI_FRINDEX 0x0C
#define EHCI_CTRLDSSEGMENT 0x10
#define EHCI_PERIODICLISTBASE 0x14
#define EHCI_ASYNCLISTBASE 0x18
#define EHCI_CONFIGFLAG 0x40
#define EHCI_PORTSC 0x44
/* USB Interrupt Register Flags 32 Bits */
#define EHCI_USBINTR_INTE 0x01
#define EHCI_USBINTR_ERR 0x02
#define EHCI_USBINTR_PC 0x04
#define EHCI_USBINTR_FLROVR 0x08
#define EHCI_USBINTR_HSERR 0x10
#define EHCI_USBINTR_ASYNC 0x20
/* Bits 6:31 Reserved */
/* Status Register Flags 32 Bits */
#define EHCI_STS_INT 0x01
#define EHCI_STS_ERR 0x02
#define EHCI_STS_PCD 0x04
#define EHCI_STS_FLR 0x08
#define EHCI_STS_FATAL 0x10
#define EHCI_STS_IAA 0x20
/* Bits 11:6 Reserved */
#define EHCI_STS_HALT 0x1000
#define EHCI_STS_RECL 0x2000
#define EHCI_STS_PSS 0x4000
#define EHCI_STS_ASS 0x8000
#define EHCI_ERROR_INT ( EHCI_STS_FATAL | EHCI_STS_ERR )
/* Last bit in QUEUE ELEMENT TRANSFER DESCRIPTOR Next Pointer */
/* Used for Queue Element Transfer Descriptor Pointers
and Queue Head Horizontal Link Pointers */
#define TERMINATE_POINTER 0x01
/* QUEUE ELEMENT TRANSFER DESCRIPTOR, Token defines and structs */
/* PIDCodes for QETD_TOKEN
OR with QUEUE_TRANSFER_DESCRIPTOR Token.PIDCode*/
#define PID_CODE_OUT_TOKEN 0x00
#define PID_CODE_IN_TOKEN 0x01
#define PID_CODE_SETUP_TOKEN 0x02
/* Split Transaction States
OR with QUEUE_TRANSFER_DESCRIPTOR Token.SplitTransactionState */
#define DO_START_SPLIT 0x00
#define DO_COMPLETE_SPLIT 0x01
/* Ping States, OR with QUEUE_TRANSFER_DESCRIPTOR Token. */
#define PING_STATE_DO_OUT 0x00
#define PING_STATE_DO_PING 0x01
#define C_HUB_LOCAL_POWER 0
#define C_HUB_OVER_CURRENT 1
#define PORT_CONNECTION 0
@ -96,113 +41,6 @@ OR with QUEUE_TRANSFER_DESCRIPTOR Token.SplitTransactionState */
#define PORT_INDICATOR 22
#define USB_PORT_STATUS_CHANGE 0x4000
/* QUEUE ELEMENT TRANSFER DESCRIPTOR TOKEN */
typedef struct _QETD_TOKEN_BITS
{
ULONG PingState:1;
ULONG SplitTransactionState:1;
ULONG MissedMicroFrame:1;
ULONG TransactionError:1;
ULONG BabbelDetected:1;
ULONG DataBufferError:1;
ULONG Halted:1;
ULONG Active:1;
ULONG PIDCode:2;
ULONG ErrorCounter:2;
ULONG CurrentPage:3;
ULONG InterruptOnComplete:1;
ULONG TotalBytesToTransfer:15;
ULONG DataToggle:1;
} QETD_TOKEN_BITS, *PQETD_TOKEN_BITS;
/* QUEUE ELEMENT TRANSFER DESCRIPTOR */
typedef struct _QUEUE_TRANSFER_DESCRIPTOR
{
ULONG NextPointer;
ULONG AlternateNextPointer;
union
{
QETD_TOKEN_BITS Bits;
ULONG DWord;
} Token;
ULONG BufferPointer[5];
} QUEUE_TRANSFER_DESCRIPTOR, *PQUEUE_TRANSFER_DESCRIPTOR;
/* EndPointSpeeds of END_POINT_CAPABILITIES */
#define QH_ENDPOINT_FULLSPEED 0x00
#define QH_ENDPOINT_LOWSPEED 0x01
#define QH_ENDPOINT_HIGHSPEED 0x02
typedef struct _END_POINT_CAPABILITIES1
{
ULONG DeviceAddress:7;
ULONG InactiveOnNextTransaction:1;
ULONG EndPointNumber:4;
ULONG EndPointSpeed:2;
ULONG QEDTDataToggleControl:1;
ULONG HeadOfReclamation:1;
ULONG MaximumPacketLength:11;
ULONG ControlEndPointFlag:1;
ULONG NakCountReload:4;
} END_POINT_CAPABILITIES1, *PEND_POINT_CAPABILITIES1;
typedef struct _END_POINT_CAPABILITIES2
{
ULONG InterruptScheduleMask:8;
ULONG SplitCompletionMask:8;
ULONG HubAddr:6;
ULONG PortNumber:6;
/* Multi */
ULONG NumberOfTransactionPerFrame:2;
} END_POINT_CAPABILITIES2, *PEND_POINT_CAPABILITIES2;
/* QUEUE HEAD defines and structs */
/* QUEUE HEAD Select Types, OR with QUEUE_HEAD HorizontalLinkPointer */
#define QH_TYPE_IDT 0x00
#define QH_TYPE_QH 0x02
#define QH_TYPE_SITD 0x04
#define QH_TYPE_FSTN 0x06
/* QUEUE HEAD */
typedef struct _QUEUE_HEAD
{
ULONG HorizontalLinkPointer;
END_POINT_CAPABILITIES1 EndPointCapabilities1;
END_POINT_CAPABILITIES2 EndPointCapabilities2;
/* TERMINATE_POINTER not valid for this member */
ULONG CurrentLinkPointer;
/* TERMINATE_POINTER valid */
ULONG QETDPointer;
/* TERMINATE_POINTER valid, bits 1:4 is NAK_COUNTER */
ULONG AlternateNextPointer;
/* Only DataToggle, InterruptOnComplete, ErrorCounter, PingState valid */
union
{
QETD_TOKEN_BITS Bits;
ULONG DWord;
} Token;
ULONG BufferPointer[5];
} QUEUE_HEAD, *PQUEUE_HEAD;
typedef struct _EHCI_SETUP_FORMAT
{
UCHAR bmRequestType;
UCHAR bRequest;
USHORT wValue;
USHORT wIndex;
USHORT wLength;
} EHCI_SETUP_FORMAT, *PEHCI_SETUP_FORMAT;
typedef struct _STRING_DESCRIPTOR
{
UCHAR bLength; /* Size of this descriptor in bytes */
UCHAR bDescriptorType; /* STRING Descriptor Type */
UCHAR bString[0]; /* UNICODE encoded string */
} STRING_DESCRIPTOR, *PSTRING_DESCRIPTOR;
typedef struct _USB_ENDPOINT
{
ULONG Flags;
@ -234,102 +72,16 @@ typedef struct _USB_DEVICE
USB_DEVICE_SPEED DeviceSpeed;
USB_DEVICE_TYPE DeviceType;
USB_DEVICE_DESCRIPTOR DeviceDescriptor;
UNICODE_STRING LanguageIDs;
UNICODE_STRING iManufacturer;
UNICODE_STRING iProduct;
UNICODE_STRING iSerialNumber;
USB_CONFIGURATION *ActiveConfig;
USB_INTERFACE *ActiveInterface;
USB_CONFIGURATION **Configs;
} USB_DEVICE, *PUSB_DEVICE;
/* USBCMD register 32 bits */
typedef struct _EHCI_USBCMD_CONTENT
{
ULONG Run : 1;
ULONG HCReset : 1;
ULONG FrameListSize : 2;
ULONG PeriodicEnable : 1;
ULONG AsyncEnable : 1;
ULONG DoorBell : 1;
ULONG LightReset : 1;
ULONG AsyncParkCount : 2;
ULONG Reserved : 1;
ULONG AsyncParkEnable : 1;
ULONG Reserved1 : 4;
ULONG IntThreshold : 8;
ULONG Reserved2 : 8;
} EHCI_USBCMD_CONTENT, *PEHCI_USBCMD_CONTENT;
typedef struct _EHCI_USBSTS_CONTENT
{
ULONG USBInterrupt:1;
ULONG ErrorInterrupt:1;
ULONG DetectChangeInterrupt:1;
ULONG FrameListRolloverInterrupt:1;
ULONG HostSystemErrorInterrupt:1;
ULONG AsyncAdvanceInterrupt:1;
ULONG Reserved:6;
ULONG HCHalted:1;
ULONG Reclamation:1;
ULONG PeriodicScheduleStatus:1;
ULONG AsynchronousScheduleStatus:1;
} EHCI_USBSTS_CONTEXT, *PEHCI_USBSTS_CONTEXT;
typedef struct _EHCI_USBPORTSC_CONTENT
{
ULONG CurrentConnectStatus:1;
ULONG ConnectStatusChange:1;
ULONG PortEnabled:1;
ULONG PortEnableChanged:1;
ULONG OverCurrentActive:1;
ULONG OverCurrentChange:1;
ULONG ForcePortResume:1;
ULONG Suspend:1;
ULONG PortReset:1;
ULONG Reserved:1;
ULONG LineStatus:2;
ULONG PortPower:1;
ULONG PortOwner:1;
} EHCI_USBPORTSC_CONTENT, *PEHCI_USBPORTSC_CONTENT;
typedef struct _EHCI_HCS_CONTENT
{
ULONG PortCount : 4;
ULONG PortPowerControl: 1;
ULONG Reserved : 2;
ULONG PortRouteRules : 1;
ULONG PortPerCHC : 4;
ULONG CHCCount : 4;
ULONG PortIndicator : 1;
ULONG Reserved2 : 3;
ULONG DbgPortNum : 4;
ULONG Reserved3 : 8;
} EHCI_HCS_CONTENT, *PEHCI_HCS_CONTENT;
typedef struct _EHCI_HCC_CONTENT
{
ULONG CurAddrBits : 1;
ULONG VarFrameList : 1;
ULONG ParkMode : 1;
ULONG Reserved : 1;
ULONG IsoSchedThreshold : 4;
ULONG EECPCapable : 8;
ULONG Reserved2 : 16;
} EHCI_HCC_CONTENT, *PEHCI_HCC_CONTENT;
typedef struct _EHCI_CAPS {
UCHAR Length;
UCHAR Reserved;
USHORT HCIVersion;
union
{
EHCI_HCS_CONTENT HCSParams;
ULONG HCSParamsLong;
};
ULONG HCCParams;
UCHAR PortRoute [8];
} EHCI_CAPS, *PEHCI_CAPS;
typedef struct _COMMON_DEVICE_EXTENSION
{
@ -380,26 +132,21 @@ typedef struct _FDO_DEVICE_EXTENSION
BUS_INTERFACE_STANDARD BusInterface;
EHCI_CAPS ECHICaps;
union
{
PULONG ResourcePort;
PULONG ResourceMemory;
ULONG ResourcePort;
ULONG ResourceMemory;
};
PULONG PeriodicFramList;
PULONG AsyncListQueueHeadPtr;
PHYSICAL_ADDRESS PeriodicFramListPhysAddr;
PHYSICAL_ADDRESS AsyncListQueueHeadPtrPhysAddr;
FAST_MUTEX AsyncListMutex;
EHCI_HOST_CONTROLLER hcd;
PERIODICFRAMELIST PeriodicFrameList;
FAST_MUTEX FrameListMutex;
BOOLEAN AsyncComplete;
PULONG ResourceBase;
ULONG Size;
//PULONG ResourceBase;
//ULONG Size;
} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
typedef struct _PDO_DEVICE_EXTENSION
@ -425,6 +172,12 @@ typedef struct _PDO_DEVICE_EXTENSION
FAST_MUTEX ListLock;
} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
typedef struct _WORKITEMDATA
{
WORK_QUEUE_ITEM WorkItem;
PVOID Context;
} WORKITEMDATA, *PWORKITEMDATA;
VOID NTAPI
UrbWorkerThread(PVOID Context);
@ -464,7 +217,7 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS NTAPI
FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
BOOLEAN
USBD_STATUS
ExecuteControlRequest(PFDO_DEVICE_EXTENSION DeviceExtension, PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, UCHAR Address, ULONG Port, PVOID Buffer, ULONG BufferLength);
VOID
@ -485,5 +238,16 @@ HandleUrbRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp);
PUSB_DEVICE
DeviceHandleToUsbDevice(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PUSB_DEVICE_HANDLE DeviceHandle);
BOOLEAN
ResetPort(PFDO_DEVICE_EXTENSION FdoDeviceExtension, UCHAR Port);
VOID
DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
VOID
DumpFullConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
VOID
DumpTransferDescriptor(PQUEUE_TRANSFER_DESCRIPTOR TransferDescriptor);
VOID
DumpQueueHead(PQUEUE_HEAD QueueHead);