mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[USBPORT] Type-safe function signature (PVOID -> PUSBPORT_xxx).
This commit is contained in:
parent
a913501626
commit
73bfc3c897
5 changed files with 89 additions and 84 deletions
|
@ -1524,7 +1524,7 @@ USBPORT_RestoreDevice(IN PDEVICE_OBJECT FdoDevice,
|
|||
PUSBPORT_DEVICE_EXTENSION FdoExtension;
|
||||
PLIST_ENTRY iHandleList;
|
||||
PUSBPORT_ENDPOINT Endpoint;
|
||||
ULONG EndpointRequirements[2] = {0};
|
||||
USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
|
||||
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
USBD_STATUS USBDStatus;
|
||||
|
@ -1707,7 +1707,7 @@ USBPORT_RestoreDevice(IN PDEVICE_OBJECT FdoDevice,
|
|||
|
||||
Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
|
||||
&Endpoint->EndpointProperties,
|
||||
EndpointRequirements);
|
||||
&EndpointRequirements);
|
||||
|
||||
KeReleaseSpinLock(&FdoExtension->MiniportSpinLock,
|
||||
OldIrql);
|
||||
|
|
|
@ -620,7 +620,7 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
|
|||
UCHAR Direction;
|
||||
UCHAR Interval;
|
||||
UCHAR Period;
|
||||
ULONG TransferParams[2] = {0};
|
||||
USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
|
||||
PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
|
||||
MPSTATUS MpStatus;
|
||||
USBD_STATUS USBDStatus;
|
||||
|
@ -832,27 +832,27 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
|
|||
|
||||
Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
|
||||
&Endpoint->EndpointProperties,
|
||||
TransferParams);
|
||||
&EndpointRequirements);
|
||||
|
||||
KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
|
||||
|
||||
if ((EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_BULK) ||
|
||||
(EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT))
|
||||
{
|
||||
EndpointProperties->MaxTransferSize = TransferParams[1];
|
||||
EndpointProperties->MaxTransferSize = EndpointRequirements.MaxTransferSize;
|
||||
}
|
||||
|
||||
if (TransferParams[0])
|
||||
if (EndpointRequirements.HeaderBufferSize)
|
||||
{
|
||||
HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
|
||||
TransferParams[0]);
|
||||
EndpointRequirements.HeaderBufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
HeaderBuffer = NULL;
|
||||
}
|
||||
|
||||
if (HeaderBuffer || (TransferParams[0] == 0))
|
||||
if (HeaderBuffer || (EndpointRequirements.HeaderBufferSize == 0))
|
||||
{
|
||||
Endpoint->HeaderBuffer = HeaderBuffer;
|
||||
|
||||
|
@ -969,7 +969,7 @@ USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice,
|
|||
{
|
||||
PUSBPORT_DEVICE_EXTENSION FdoExtension;
|
||||
PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
|
||||
ULONG EndpointRequirements[2] = {0};
|
||||
USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
|
||||
PUSBPORT_REGISTRATION_PACKET Packet;
|
||||
KIRQL MiniportOldIrql;
|
||||
NTSTATUS Status;
|
||||
|
@ -1013,21 +1013,21 @@ USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice,
|
|||
|
||||
Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
|
||||
&Endpoint->EndpointProperties,
|
||||
EndpointRequirements);
|
||||
&EndpointRequirements);
|
||||
|
||||
KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, MiniportOldIrql);
|
||||
|
||||
if (EndpointRequirements[0])
|
||||
if (EndpointRequirements.HeaderBufferSize)
|
||||
{
|
||||
HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
|
||||
EndpointRequirements[0]);
|
||||
EndpointRequirements.HeaderBufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
HeaderBuffer = NULL;
|
||||
}
|
||||
|
||||
if (HeaderBuffer || EndpointRequirements[0] == 0)
|
||||
if (HeaderBuffer || EndpointRequirements.HeaderBufferSize == 0)
|
||||
{
|
||||
Endpoint->HeaderBuffer = HeaderBuffer;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
|
|
@ -170,7 +170,7 @@ USBPORT_RootHubClassCommand(IN PDEVICE_OBJECT FdoDevice,
|
|||
case USB_REQUEST_CLEAR_FEATURE:
|
||||
Feature = SetupPacket->wValue.W;
|
||||
|
||||
if ((SetupPacket->bmRequestType.Recipient) != USBPORT_RECIPIENT_ROOT_PORT)
|
||||
if ((SetupPacket->bmRequestType.Recipient) != USBPORT_RECIPIENT_PORT)
|
||||
{
|
||||
if (Feature == FEATURE_C_HUB_LOCAL_POWER)
|
||||
{
|
||||
|
@ -242,7 +242,7 @@ USBPORT_RootHubClassCommand(IN PDEVICE_OBJECT FdoDevice,
|
|||
break;
|
||||
|
||||
case USB_REQUEST_SET_FEATURE:
|
||||
if (SetupPacket->bmRequestType.Recipient != USBPORT_RECIPIENT_ROOT_PORT)
|
||||
if (SetupPacket->bmRequestType.Recipient != USBPORT_RECIPIENT_PORT)
|
||||
{
|
||||
return RHStatus;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#define USBD_TRANSFER_DIRECTION 0x00000001
|
||||
#endif
|
||||
|
||||
#define USBPORT_RECIPIENT_ROOT_HUB BMREQUEST_TO_DEVICE
|
||||
#define USBPORT_RECIPIENT_ROOT_PORT BMREQUEST_TO_OTHER
|
||||
#define USBPORT_RECIPIENT_HUB BMREQUEST_TO_DEVICE
|
||||
#define USBPORT_RECIPIENT_PORT BMREQUEST_TO_OTHER
|
||||
|
||||
#define INVALIDATE_ENDPOINT_ONLY 0
|
||||
#define INVALIDATE_ENDPOINT_WORKER_THREAD 1
|
||||
|
|
|
@ -64,6 +64,70 @@ typedef struct _USBPORT_RESOURCES {
|
|||
|
||||
C_ASSERT(sizeof(USBPORT_RESOURCES) == 24 + 7 * sizeof(PVOID));
|
||||
|
||||
typedef struct _USBPORT_ENDPOINT_PROPERTIES {
|
||||
USHORT DeviceAddress;
|
||||
USHORT EndpointAddress;
|
||||
USHORT TotalMaxPacketSize; // TransactionPerMicroframe * MaxPacketSize
|
||||
UCHAR Period;
|
||||
UCHAR Reserved1;
|
||||
USB_DEVICE_SPEED DeviceSpeed;
|
||||
ULONG UsbBandwidth;
|
||||
ULONG ScheduleOffset;
|
||||
ULONG TransferType;
|
||||
ULONG Direction;
|
||||
ULONG_PTR BufferVA;
|
||||
ULONG_PTR BufferPA;
|
||||
ULONG BufferLength;
|
||||
ULONG Reserved3;
|
||||
ULONG MaxTransferSize;
|
||||
USHORT HubAddr;
|
||||
USHORT PortNumber;
|
||||
UCHAR InterruptScheduleMask;
|
||||
UCHAR SplitCompletionMask;
|
||||
UCHAR TransactionPerMicroframe; // 1 + additional transactions. Total: from 1 to 3)
|
||||
UCHAR Reserved4;
|
||||
ULONG MaxPacketSize;
|
||||
ULONG Reserved6;
|
||||
} USBPORT_ENDPOINT_PROPERTIES, *PUSBPORT_ENDPOINT_PROPERTIES;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_ENDPOINT_PROPERTIES) == 48 + 4 * sizeof(PVOID));
|
||||
|
||||
typedef struct _USBPORT_TRANSFER_PARAMETERS {
|
||||
ULONG TransferFlags;
|
||||
ULONG TransferBufferLength;
|
||||
ULONG TransferCounter;
|
||||
BOOL IsTransferSplited;
|
||||
ULONG Reserved2;
|
||||
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
|
||||
} USBPORT_TRANSFER_PARAMETERS, *PUSBPORT_TRANSFER_PARAMETERS;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28);
|
||||
|
||||
typedef struct _USBPORT_SCATTER_GATHER_ELEMENT {
|
||||
PHYSICAL_ADDRESS SgPhysicalAddress;
|
||||
ULONG Reserved1;
|
||||
ULONG SgTransferLength;
|
||||
ULONG SgOffset;
|
||||
ULONG Reserved2;
|
||||
} USBPORT_SCATTER_GATHER_ELEMENT, *PUSBPORT_SCATTER_GATHER_ELEMENT;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_ELEMENT) == 24);
|
||||
|
||||
typedef struct _USBPORT_SCATTER_GATHER_LIST {
|
||||
ULONG Flags;
|
||||
ULONG_PTR CurrentVa;
|
||||
PVOID MappedSystemVa;
|
||||
ULONG SgElementCount;
|
||||
USBPORT_SCATTER_GATHER_ELEMENT SgElement[2];
|
||||
} USBPORT_SCATTER_GATHER_LIST, *PUSBPORT_SCATTER_GATHER_LIST;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_LIST) == 48 + 4 * sizeof(PVOID));
|
||||
|
||||
typedef struct _USBPORT_ENDPOINT_REQUIREMENTS {
|
||||
ULONG HeaderBufferSize;
|
||||
ULONG MaxTransferSize;
|
||||
} USBPORT_ENDPOINT_REQUIREMENTS, *PUSBPORT_ENDPOINT_REQUIREMENTS;
|
||||
|
||||
typedef ULONG MPSTATUS; // Miniport status
|
||||
typedef ULONG RHSTATUS; // Roothub status
|
||||
|
||||
|
@ -88,20 +152,20 @@ typedef ULONG RHSTATUS; // Roothub status
|
|||
typedef MPSTATUS
|
||||
(NTAPI *PHCI_OPEN_ENDPOINT)(
|
||||
PVOID,
|
||||
PVOID,
|
||||
PUSBPORT_ENDPOINT_PROPERTIES,
|
||||
PVOID);
|
||||
|
||||
typedef MPSTATUS
|
||||
(NTAPI *PHCI_REOPEN_ENDPOINT)(
|
||||
PVOID,
|
||||
PVOID,
|
||||
PUSBPORT_ENDPOINT_PROPERTIES,
|
||||
PVOID);
|
||||
|
||||
typedef VOID
|
||||
(NTAPI *PHCI_QUERY_ENDPOINT_REQUIREMENTS)(
|
||||
PVOID,
|
||||
PVOID,
|
||||
PULONG);
|
||||
PUSBPORT_ENDPOINT_PROPERTIES,
|
||||
PUSBPORT_ENDPOINT_REQUIREMENTS);
|
||||
|
||||
typedef VOID
|
||||
(NTAPI *PHCI_CLOSE_ENDPOINT)(
|
||||
|
@ -137,15 +201,15 @@ typedef MPSTATUS
|
|||
(NTAPI *PHCI_SUBMIT_TRANSFER)(
|
||||
PVOID,
|
||||
PVOID,
|
||||
PUSBPORT_TRANSFER_PARAMETERS,
|
||||
PVOID,
|
||||
PVOID,
|
||||
PVOID);
|
||||
PUSBPORT_SCATTER_GATHER_LIST);
|
||||
|
||||
typedef MPSTATUS
|
||||
(NTAPI *PHCI_SUBMIT_ISO_TRANSFER)(
|
||||
PVOID,
|
||||
PVOID,
|
||||
PVOID,
|
||||
PUSBPORT_TRANSFER_PARAMETERS,
|
||||
PVOID,
|
||||
PVOID);
|
||||
|
||||
|
@ -443,7 +507,7 @@ typedef ULONG
|
|||
typedef VOID
|
||||
(NTAPI *PHCI_REBALANCE_ENDPOINT)(
|
||||
PVOID,
|
||||
PVOID,
|
||||
PUSBPORT_ENDPOINT_PROPERTIES,
|
||||
PVOID);
|
||||
|
||||
typedef VOID
|
||||
|
@ -583,65 +647,6 @@ C_ASSERT(sizeof(USBPORT_MINIPORT_INTERFACE) == 32 + 76 * sizeof(PVOID));
|
|||
#define USBPORT_TRANSFER_DIRECTION_OUT 1 // From host to device
|
||||
#define USBPORT_MAX_DEVICE_ADDRESS 127
|
||||
|
||||
typedef struct _USBPORT_ENDPOINT_PROPERTIES {
|
||||
USHORT DeviceAddress;
|
||||
USHORT EndpointAddress;
|
||||
USHORT TotalMaxPacketSize; // TransactionPerMicroframe * MaxPacketSize
|
||||
UCHAR Period;
|
||||
UCHAR Reserved1;
|
||||
USB_DEVICE_SPEED DeviceSpeed;
|
||||
ULONG UsbBandwidth;
|
||||
ULONG ScheduleOffset;
|
||||
ULONG TransferType;
|
||||
ULONG Direction;
|
||||
ULONG_PTR BufferVA;
|
||||
ULONG_PTR BufferPA;
|
||||
ULONG BufferLength;
|
||||
ULONG Reserved3;
|
||||
ULONG MaxTransferSize;
|
||||
USHORT HubAddr;
|
||||
USHORT PortNumber;
|
||||
UCHAR InterruptScheduleMask;
|
||||
UCHAR SplitCompletionMask;
|
||||
UCHAR TransactionPerMicroframe; // 1 + additional transactions. Total: from 1 to 3)
|
||||
UCHAR Reserved4;
|
||||
ULONG MaxPacketSize;
|
||||
ULONG Reserved6;
|
||||
} USBPORT_ENDPOINT_PROPERTIES, *PUSBPORT_ENDPOINT_PROPERTIES;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_ENDPOINT_PROPERTIES) == 48 + 4 * sizeof(PVOID));
|
||||
|
||||
typedef struct _USBPORT_SCATTER_GATHER_ELEMENT {
|
||||
PHYSICAL_ADDRESS SgPhysicalAddress;
|
||||
ULONG Reserved1;
|
||||
ULONG SgTransferLength;
|
||||
ULONG SgOffset;
|
||||
ULONG Reserved2;
|
||||
} USBPORT_SCATTER_GATHER_ELEMENT, *PUSBPORT_SCATTER_GATHER_ELEMENT;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_ELEMENT) == 24);
|
||||
|
||||
typedef struct _USBPORT_SCATTER_GATHER_LIST {
|
||||
ULONG Flags;
|
||||
ULONG_PTR CurrentVa;
|
||||
PVOID MappedSystemVa;
|
||||
ULONG SgElementCount;
|
||||
USBPORT_SCATTER_GATHER_ELEMENT SgElement[2];
|
||||
} USBPORT_SCATTER_GATHER_LIST, *PUSBPORT_SCATTER_GATHER_LIST;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_LIST) == 48 + 4 * sizeof(PVOID));
|
||||
|
||||
typedef struct _USBPORT_TRANSFER_PARAMETERS {
|
||||
ULONG TransferFlags;
|
||||
ULONG TransferBufferLength;
|
||||
ULONG TransferCounter;
|
||||
BOOL IsTransferSplited;
|
||||
ULONG Reserved2;
|
||||
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
|
||||
} USBPORT_TRANSFER_PARAMETERS, *PUSBPORT_TRANSFER_PARAMETERS;
|
||||
|
||||
C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28);
|
||||
|
||||
/* For USB1.1 or USB3 Hub Descriptors */
|
||||
typedef union _USBPORT_HUB_11_CHARACTERISTICS {
|
||||
struct {
|
||||
|
|
Loading…
Reference in a new issue