mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[USBOHCI] [USBEHCI] [USBUHCI]
- Don't assume iConfiguration value of configuration descriptor is zero based aligned - Fixes bugcheck in VmWare svn path=/trunk/; revision=55811
This commit is contained in:
parent
4877f634cc
commit
eb1402eb83
4 changed files with 135 additions and 61 deletions
|
@ -4,3 +4,4 @@ add_subdirectory(usbehci)
|
||||||
add_subdirectory(usbhub)
|
add_subdirectory(usbhub)
|
||||||
add_subdirectory(usbohci)
|
add_subdirectory(usbohci)
|
||||||
add_subdirectory(usbstor)
|
add_subdirectory(usbstor)
|
||||||
|
add_subdirectory(usbuhci)
|
|
@ -1044,30 +1044,67 @@ CUSBDevice::SelectConfiguration(
|
||||||
ULONG InterfaceIndex, PipeIndex;
|
ULONG InterfaceIndex, PipeIndex;
|
||||||
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
UCHAR bConfigurationValue = 0;
|
||||||
|
ULONG ConfigurationIndex = 0, Index;
|
||||||
|
UCHAR Found = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
if (ConfigurationDescriptor)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// sanity checks
|
// find configuration index
|
||||||
//
|
//
|
||||||
ASSERT(ConfigurationDescriptor->iConfiguration < m_DeviceDescriptor.bNumConfigurations);
|
for(Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
|
||||||
ASSERT(ConfigurationDescriptor->iConfiguration == m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->iConfiguration);
|
{
|
||||||
|
if (m_ConfigurationDescriptors[Index].ConfigurationDescriptor->iConfiguration == ConfigurationDescriptor->iConfiguration)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// found configuration index
|
||||||
|
//
|
||||||
|
ConfigurationIndex = Index;
|
||||||
|
Found = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Found)
|
||||||
|
{
|
||||||
|
DPRINT1("[USBUHCI] invalid configuration index %lu\n", ConfigurationDescriptor->iConfiguration);
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// sanity check
|
// sanity check
|
||||||
//
|
//
|
||||||
ASSERT(ConfigurationDescriptor->bNumInterfaces <= m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->bNumInterfaces);
|
ASSERT(ConfigurationDescriptor->bNumInterfaces <= m_ConfigurationDescriptors[ConfigurationIndex].ConfigurationDescriptor->bNumInterfaces);
|
||||||
|
|
||||||
|
//
|
||||||
|
// get configuration value
|
||||||
|
//
|
||||||
|
bConfigurationValue = ConfigurationDescriptor->bConfigurationValue;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// now build setup packet
|
// now build setup packet
|
||||||
//
|
//
|
||||||
RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
|
RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
|
||||||
CtrlSetup.bRequest = USB_REQUEST_SET_CONFIGURATION;
|
CtrlSetup.bRequest = USB_REQUEST_SET_CONFIGURATION;
|
||||||
CtrlSetup.wValue.W = ConfigurationDescriptor->bConfigurationValue;
|
CtrlSetup.wValue.W = bConfigurationValue;
|
||||||
|
|
||||||
//
|
//
|
||||||
// select configuration
|
// select configuration
|
||||||
//
|
//
|
||||||
Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
|
Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
|
||||||
|
|
||||||
|
if (!ConfigurationDescriptor)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// unconfigure request
|
||||||
|
//
|
||||||
|
DPRINT1("CUsbDevice::SelectConfiguration Unconfigure Request Status %x\n", Status);
|
||||||
|
m_ConfigurationIndex = 0;
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// informal debug print
|
// informal debug print
|
||||||
//
|
//
|
||||||
|
@ -1081,14 +1118,14 @@ CUSBDevice::SelectConfiguration(
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// store configuration device index
|
// store new configuration device index
|
||||||
//
|
//
|
||||||
m_ConfigurationIndex = ConfigurationDescriptor->iConfiguration;
|
m_ConfigurationIndex = ConfigurationIndex;
|
||||||
|
|
||||||
//
|
//
|
||||||
// store configuration handle
|
// store configuration handle
|
||||||
//
|
//
|
||||||
*ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration];
|
*ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationIndex];
|
||||||
|
|
||||||
//
|
//
|
||||||
// copy interface info and pipe info
|
// copy interface info and pipe info
|
||||||
|
@ -1098,7 +1135,7 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// sanity check: is the info pre-layed out
|
// sanity check: is the info pre-layed out
|
||||||
//
|
//
|
||||||
PC_ASSERT(InterfaceInfo->NumberOfPipes == m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints);
|
PC_ASSERT(InterfaceInfo->NumberOfPipes == m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints);
|
||||||
PC_ASSERT(InterfaceInfo->Length != 0);
|
PC_ASSERT(InterfaceInfo->Length != 0);
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes[InterfaceInfo->NumberOfPipes]));
|
PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes[InterfaceInfo->NumberOfPipes]));
|
||||||
|
@ -1107,10 +1144,10 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// copy interface info
|
// copy interface info
|
||||||
//
|
//
|
||||||
InterfaceInfo->InterfaceHandle = (USBD_INTERFACE_HANDLE)&m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex];
|
InterfaceInfo->InterfaceHandle = (USBD_INTERFACE_HANDLE)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex];
|
||||||
InterfaceInfo->Class = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceClass;
|
InterfaceInfo->Class = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceClass;
|
||||||
InterfaceInfo->SubClass = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceSubClass;
|
InterfaceInfo->SubClass = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceSubClass;
|
||||||
InterfaceInfo->Protocol = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceProtocol;
|
InterfaceInfo->Protocol = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceProtocol;
|
||||||
InterfaceInfo->Reserved = 0;
|
InterfaceInfo->Reserved = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1121,16 +1158,16 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// copy pipe info
|
// copy pipe info
|
||||||
//
|
//
|
||||||
InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.wMaxPacketSize;
|
InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.wMaxPacketSize;
|
||||||
InterfaceInfo->Pipes[PipeIndex].EndpointAddress = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress;
|
InterfaceInfo->Pipes[PipeIndex].EndpointAddress = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress;
|
||||||
InterfaceInfo->Pipes[PipeIndex].Interval = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bInterval;
|
InterfaceInfo->Pipes[PipeIndex].Interval = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bInterval;
|
||||||
InterfaceInfo->Pipes[PipeIndex].PipeType = (USBD_PIPE_TYPE)m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes;
|
InterfaceInfo->Pipes[PipeIndex].PipeType = (USBD_PIPE_TYPE)m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes;
|
||||||
InterfaceInfo->Pipes[PipeIndex].PipeHandle = (PVOID)&m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor;
|
InterfaceInfo->Pipes[PipeIndex].PipeHandle = (PVOID)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor;
|
||||||
|
|
||||||
//
|
//
|
||||||
// data toggle is reset on configuration requests
|
// data toggle is reset on configuration requests
|
||||||
//
|
//
|
||||||
m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].DataToggle = FALSE;
|
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].DataToggle = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1104,19 +1104,37 @@ CUSBDevice::SelectConfiguration(
|
||||||
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
UCHAR bConfigurationValue = 0;
|
UCHAR bConfigurationValue = 0;
|
||||||
|
ULONG ConfigurationIndex = 0, Index;
|
||||||
|
UCHAR Found = FALSE;
|
||||||
|
|
||||||
|
|
||||||
if (ConfigurationDescriptor)
|
if (ConfigurationDescriptor)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// sanity checks
|
// find configuration index
|
||||||
//
|
//
|
||||||
ASSERT(ConfigurationDescriptor->iConfiguration < m_DeviceDescriptor.bNumConfigurations);
|
for(Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
|
||||||
ASSERT(ConfigurationDescriptor->iConfiguration == m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->iConfiguration);
|
{
|
||||||
|
if (m_ConfigurationDescriptors[Index].ConfigurationDescriptor->iConfiguration == ConfigurationDescriptor->iConfiguration)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// found configuration index
|
||||||
|
//
|
||||||
|
ConfigurationIndex = Index;
|
||||||
|
Found = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Found)
|
||||||
|
{
|
||||||
|
DPRINT1("[USBUHCI] invalid configuration index %lu\n", ConfigurationDescriptor->iConfiguration);
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// sanity check
|
// sanity check
|
||||||
//
|
//
|
||||||
ASSERT(ConfigurationDescriptor->bNumInterfaces <= m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->bNumInterfaces);
|
ASSERT(ConfigurationDescriptor->bNumInterfaces <= m_ConfigurationDescriptors[ConfigurationIndex].ConfigurationDescriptor->bNumInterfaces);
|
||||||
|
|
||||||
//
|
//
|
||||||
// get configuration value
|
// get configuration value
|
||||||
|
@ -1159,14 +1177,14 @@ CUSBDevice::SelectConfiguration(
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// store configuration device index
|
// store new configuration device index
|
||||||
//
|
//
|
||||||
m_ConfigurationIndex = ConfigurationDescriptor->iConfiguration;
|
m_ConfigurationIndex = ConfigurationIndex;
|
||||||
|
|
||||||
//
|
//
|
||||||
// store configuration handle
|
// store configuration handle
|
||||||
//
|
//
|
||||||
*ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration];
|
*ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationIndex];
|
||||||
|
|
||||||
//
|
//
|
||||||
// copy interface info and pipe info
|
// copy interface info and pipe info
|
||||||
|
@ -1176,7 +1194,7 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// sanity check: is the info pre-layed out
|
// sanity check: is the info pre-layed out
|
||||||
//
|
//
|
||||||
PC_ASSERT(InterfaceInfo->NumberOfPipes == m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints);
|
PC_ASSERT(InterfaceInfo->NumberOfPipes == m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints);
|
||||||
PC_ASSERT(InterfaceInfo->Length != 0);
|
PC_ASSERT(InterfaceInfo->Length != 0);
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes[InterfaceInfo->NumberOfPipes]));
|
PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes[InterfaceInfo->NumberOfPipes]));
|
||||||
|
@ -1185,10 +1203,10 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// copy interface info
|
// copy interface info
|
||||||
//
|
//
|
||||||
InterfaceInfo->InterfaceHandle = (USBD_INTERFACE_HANDLE)&m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex];
|
InterfaceInfo->InterfaceHandle = (USBD_INTERFACE_HANDLE)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex];
|
||||||
InterfaceInfo->Class = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceClass;
|
InterfaceInfo->Class = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceClass;
|
||||||
InterfaceInfo->SubClass = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceSubClass;
|
InterfaceInfo->SubClass = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceSubClass;
|
||||||
InterfaceInfo->Protocol = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceProtocol;
|
InterfaceInfo->Protocol = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceProtocol;
|
||||||
InterfaceInfo->Reserved = 0;
|
InterfaceInfo->Reserved = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1199,16 +1217,16 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// copy pipe info
|
// copy pipe info
|
||||||
//
|
//
|
||||||
InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.wMaxPacketSize;
|
InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.wMaxPacketSize;
|
||||||
InterfaceInfo->Pipes[PipeIndex].EndpointAddress = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress;
|
InterfaceInfo->Pipes[PipeIndex].EndpointAddress = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress;
|
||||||
InterfaceInfo->Pipes[PipeIndex].Interval = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bInterval;
|
InterfaceInfo->Pipes[PipeIndex].Interval = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bInterval;
|
||||||
InterfaceInfo->Pipes[PipeIndex].PipeType = (USBD_PIPE_TYPE)m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes;
|
InterfaceInfo->Pipes[PipeIndex].PipeType = (USBD_PIPE_TYPE)m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes;
|
||||||
InterfaceInfo->Pipes[PipeIndex].PipeHandle = (PVOID)&m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor;
|
InterfaceInfo->Pipes[PipeIndex].PipeHandle = (PVOID)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor;
|
||||||
|
|
||||||
//
|
//
|
||||||
// data toggle is reset on configuration requests
|
// data toggle is reset on configuration requests
|
||||||
//
|
//
|
||||||
m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].DataToggle = FALSE;
|
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].DataToggle = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1144,19 +1144,37 @@ CUSBDevice::SelectConfiguration(
|
||||||
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
UCHAR bConfigurationValue = 0;
|
UCHAR bConfigurationValue = 0;
|
||||||
|
ULONG ConfigurationIndex = 0, Index;
|
||||||
|
UCHAR Found = FALSE;
|
||||||
|
|
||||||
|
|
||||||
if (ConfigurationDescriptor)
|
if (ConfigurationDescriptor)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// sanity checks
|
// find configuration index
|
||||||
//
|
//
|
||||||
ASSERT(ConfigurationDescriptor->iConfiguration < m_DeviceDescriptor.bNumConfigurations);
|
for(Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
|
||||||
ASSERT(ConfigurationDescriptor->iConfiguration == m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->iConfiguration);
|
{
|
||||||
|
if (m_ConfigurationDescriptors[Index].ConfigurationDescriptor->iConfiguration == ConfigurationDescriptor->iConfiguration)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// found configuration index
|
||||||
|
//
|
||||||
|
ConfigurationIndex = Index;
|
||||||
|
Found = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Found)
|
||||||
|
{
|
||||||
|
DPRINT1("[USBUHCI] invalid configuration index %lu\n", ConfigurationDescriptor->iConfiguration);
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// sanity check
|
// sanity check
|
||||||
//
|
//
|
||||||
ASSERT(ConfigurationDescriptor->bNumInterfaces <= m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->bNumInterfaces);
|
ASSERT(ConfigurationDescriptor->bNumInterfaces <= m_ConfigurationDescriptors[ConfigurationIndex].ConfigurationDescriptor->bNumInterfaces);
|
||||||
|
|
||||||
//
|
//
|
||||||
// get configuration value
|
// get configuration value
|
||||||
|
@ -1199,14 +1217,14 @@ CUSBDevice::SelectConfiguration(
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// store configuration device index
|
// store new configuration device index
|
||||||
//
|
//
|
||||||
m_ConfigurationIndex = ConfigurationDescriptor->iConfiguration;
|
m_ConfigurationIndex = ConfigurationIndex;
|
||||||
|
|
||||||
//
|
//
|
||||||
// store configuration handle
|
// store configuration handle
|
||||||
//
|
//
|
||||||
*ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration];
|
*ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationIndex];
|
||||||
|
|
||||||
//
|
//
|
||||||
// copy interface info and pipe info
|
// copy interface info and pipe info
|
||||||
|
@ -1216,7 +1234,7 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// sanity check: is the info pre-layed out
|
// sanity check: is the info pre-layed out
|
||||||
//
|
//
|
||||||
PC_ASSERT(InterfaceInfo->NumberOfPipes == m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints);
|
PC_ASSERT(InterfaceInfo->NumberOfPipes == m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints);
|
||||||
PC_ASSERT(InterfaceInfo->Length != 0);
|
PC_ASSERT(InterfaceInfo->Length != 0);
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes[InterfaceInfo->NumberOfPipes]));
|
PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes[InterfaceInfo->NumberOfPipes]));
|
||||||
|
@ -1225,10 +1243,10 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// copy interface info
|
// copy interface info
|
||||||
//
|
//
|
||||||
InterfaceInfo->InterfaceHandle = (USBD_INTERFACE_HANDLE)&m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex];
|
InterfaceInfo->InterfaceHandle = (USBD_INTERFACE_HANDLE)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex];
|
||||||
InterfaceInfo->Class = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceClass;
|
InterfaceInfo->Class = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceClass;
|
||||||
InterfaceInfo->SubClass = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceSubClass;
|
InterfaceInfo->SubClass = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceSubClass;
|
||||||
InterfaceInfo->Protocol = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceProtocol;
|
InterfaceInfo->Protocol = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceProtocol;
|
||||||
InterfaceInfo->Reserved = 0;
|
InterfaceInfo->Reserved = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1239,16 +1257,16 @@ CUSBDevice::SelectConfiguration(
|
||||||
//
|
//
|
||||||
// copy pipe info
|
// copy pipe info
|
||||||
//
|
//
|
||||||
InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.wMaxPacketSize;
|
InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.wMaxPacketSize;
|
||||||
InterfaceInfo->Pipes[PipeIndex].EndpointAddress = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress;
|
InterfaceInfo->Pipes[PipeIndex].EndpointAddress = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress;
|
||||||
InterfaceInfo->Pipes[PipeIndex].Interval = m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bInterval;
|
InterfaceInfo->Pipes[PipeIndex].Interval = m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bInterval;
|
||||||
InterfaceInfo->Pipes[PipeIndex].PipeType = (USBD_PIPE_TYPE)m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes;
|
InterfaceInfo->Pipes[PipeIndex].PipeType = (USBD_PIPE_TYPE)m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes;
|
||||||
InterfaceInfo->Pipes[PipeIndex].PipeHandle = (PVOID)&m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor;
|
InterfaceInfo->Pipes[PipeIndex].PipeHandle = (PVOID)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor;
|
||||||
|
|
||||||
//
|
//
|
||||||
// data toggle is reset on configuration requests
|
// data toggle is reset on configuration requests
|
||||||
//
|
//
|
||||||
m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].Interfaces[InterfaceIndex].EndPoints[PipeIndex].DataToggle = FALSE;
|
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].DataToggle = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue