mirror of
https://github.com/reactos/reactos.git
synced 2025-08-01 21:03:14 +00:00
[LIBUSB][USBCCGP][USBEHCI]
- Return the actual number of bytes copied for configuration descriptor requests - Fix MSVC warnings and NULL vs 0 vs FALSE issues svn path=/trunk/; revision=56667
This commit is contained in:
parent
5536a02214
commit
a426102b3a
4 changed files with 22 additions and 18 deletions
|
@ -473,6 +473,7 @@ USBCCGP_BuildConfigurationDescriptor(
|
||||||
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
|
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
|
||||||
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
|
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
|
||||||
ULONG TotalSize, Index;
|
ULONG TotalSize, Index;
|
||||||
|
ULONG Size;
|
||||||
PURB Urb;
|
PURB Urb;
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
PUCHAR BufferPtr;
|
PUCHAR BufferPtr;
|
||||||
|
@ -640,7 +641,7 @@ USBCCGP_BuildConfigurationDescriptor(
|
||||||
// modify configuration descriptor
|
// modify configuration descriptor
|
||||||
//
|
//
|
||||||
ConfigurationDescriptor = Buffer;
|
ConfigurationDescriptor = Buffer;
|
||||||
ConfigurationDescriptor->wTotalLength = TotalSize;
|
ConfigurationDescriptor->wTotalLength = (USHORT)TotalSize;
|
||||||
ConfigurationDescriptor->bNumInterfaces = PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces;
|
ConfigurationDescriptor->bNumInterfaces = PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -652,12 +653,13 @@ USBCCGP_BuildConfigurationDescriptor(
|
||||||
//
|
//
|
||||||
// copy descriptor
|
// copy descriptor
|
||||||
//
|
//
|
||||||
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Buffer, min(TotalSize, Urb->UrbControlDescriptorRequest.TransferBufferLength));
|
Size = min(TotalSize, Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||||
|
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Buffer, Size);
|
||||||
|
|
||||||
//
|
//
|
||||||
// store final size
|
// store final size
|
||||||
//
|
//
|
||||||
Urb->UrbControlDescriptorRequest.TransferBufferLength = TotalSize;
|
Urb->UrbControlDescriptorRequest.TransferBufferLength = Size;
|
||||||
|
|
||||||
//
|
//
|
||||||
// free buffer
|
// free buffer
|
||||||
|
@ -846,7 +848,7 @@ USBCCGP_PDOSelectConfiguration(
|
||||||
//
|
//
|
||||||
// now prepare interface urb
|
// now prepare interface urb
|
||||||
//
|
//
|
||||||
UsbBuildSelectInterfaceRequest(NewUrb, GET_SELECT_INTERFACE_REQUEST_SIZE(InterfaceInformation->NumberOfPipes), PDODeviceExtension->ConfigurationHandle, InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting);
|
UsbBuildSelectInterfaceRequest(NewUrb, (USHORT)GET_SELECT_INTERFACE_REQUEST_SIZE(InterfaceInformation->NumberOfPipes), PDODeviceExtension->ConfigurationHandle, InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting);
|
||||||
|
|
||||||
//
|
//
|
||||||
// now select the interface
|
// now select the interface
|
||||||
|
|
|
@ -538,7 +538,7 @@ CUSBRequest::InternalGetTransferType()
|
||||||
// initialized with setup packet, must be a control transfer
|
// initialized with setup packet, must be a control transfer
|
||||||
//
|
//
|
||||||
TransferType = USB_ENDPOINT_TYPE_CONTROL;
|
TransferType = USB_ENDPOINT_TYPE_CONTROL;
|
||||||
ASSERT(m_EndpointDescriptor == FALSE);
|
ASSERT(m_EndpointDescriptor == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1293,7 +1293,6 @@ CHubController::HandleClassDevice(
|
||||||
// generate setup packet
|
// generate setup packet
|
||||||
//
|
//
|
||||||
CtrlSetup.bRequest = USB_REQUEST_GET_STATUS;
|
CtrlSetup.bRequest = USB_REQUEST_GET_STATUS;
|
||||||
CtrlSetup.wValue.LowByte = Urb->UrbControlVendorClassRequest.Index;
|
|
||||||
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
||||||
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
||||||
CtrlSetup.wLength = (USHORT)Urb->UrbControlGetStatusRequest.TransferBufferLength;
|
CtrlSetup.wLength = (USHORT)Urb->UrbControlGetStatusRequest.TransferBufferLength;
|
||||||
|
@ -1410,7 +1409,7 @@ CHubController::HandleClassDevice(
|
||||||
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
||||||
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
||||||
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
||||||
CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
||||||
|
|
||||||
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
||||||
{
|
{
|
||||||
|
@ -1758,7 +1757,7 @@ CHubController::HandleClassEndpoint(
|
||||||
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
||||||
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
||||||
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
||||||
CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
||||||
|
|
||||||
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
||||||
{
|
{
|
||||||
|
@ -1830,7 +1829,7 @@ CHubController::HandleVendorDevice(
|
||||||
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
||||||
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
||||||
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
||||||
CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
||||||
|
|
||||||
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
||||||
{
|
{
|
||||||
|
@ -2096,7 +2095,7 @@ CHubController::HandleClassInterface(
|
||||||
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
|
||||||
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
|
||||||
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
|
||||||
CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
CtrlSetup.wLength = (USHORT)Urb->UrbControlVendorClassRequest.TransferBufferLength;
|
||||||
|
|
||||||
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
|
||||||
{
|
{
|
||||||
|
|
|
@ -323,7 +323,7 @@ CUSBDevice::SetDeviceAddress(
|
||||||
CtrlSetup->wValue.W = DeviceAddress;
|
CtrlSetup->wValue.W = DeviceAddress;
|
||||||
|
|
||||||
// set device address
|
// set device address
|
||||||
Status = CommitSetupPacket(CtrlSetup, 0, 0, 0);
|
Status = CommitSetupPacket(CtrlSetup, NULL, 0, NULL);
|
||||||
|
|
||||||
// free setup packet
|
// free setup packet
|
||||||
ExFreePoolWithTag(CtrlSetup, TAG_USBLIB);
|
ExFreePoolWithTag(CtrlSetup, TAG_USBLIB);
|
||||||
|
@ -640,7 +640,7 @@ CUSBDevice::CreateDeviceDescriptor()
|
||||||
//
|
//
|
||||||
// commit setup packet
|
// commit setup packet
|
||||||
//
|
//
|
||||||
Status = CommitSetupPacket(&CtrlSetup, 0, sizeof(USB_DEVICE_DESCRIPTOR), Mdl);
|
Status = CommitSetupPacket(&CtrlSetup, NULL, sizeof(USB_DEVICE_DESCRIPTOR), Mdl);
|
||||||
|
|
||||||
//
|
//
|
||||||
// now free the mdl
|
// now free the mdl
|
||||||
|
@ -713,7 +713,7 @@ CUSBDevice::GetConfigurationDescriptor(
|
||||||
//
|
//
|
||||||
// commit packet
|
// commit packet
|
||||||
//
|
//
|
||||||
Status = CommitSetupPacket(&CtrlSetup, 0, BufferSize, Mdl);
|
Status = CommitSetupPacket(&CtrlSetup, NULL, BufferSize, Mdl);
|
||||||
|
|
||||||
//
|
//
|
||||||
// free mdl
|
// free mdl
|
||||||
|
@ -809,6 +809,8 @@ CUSBDevice::GetConfigurationDescriptors(
|
||||||
IN ULONG BufferLength,
|
IN ULONG BufferLength,
|
||||||
OUT PULONG OutBufferLength)
|
OUT PULONG OutBufferLength)
|
||||||
{
|
{
|
||||||
|
ULONG Length;
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
ASSERT(BufferLength >= sizeof(USB_CONFIGURATION_DESCRIPTOR));
|
ASSERT(BufferLength >= sizeof(USB_CONFIGURATION_DESCRIPTOR));
|
||||||
ASSERT(ConfigDescriptorBuffer);
|
ASSERT(ConfigDescriptorBuffer);
|
||||||
|
@ -821,8 +823,9 @@ CUSBDevice::GetConfigurationDescriptors(
|
||||||
PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
|
PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
|
||||||
|
|
||||||
// copy configuration descriptor
|
// copy configuration descriptor
|
||||||
RtlCopyMemory(ConfigDescriptorBuffer, m_ConfigurationDescriptors[0].ConfigurationDescriptor, min(m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength, BufferLength));
|
Length = min(m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength, BufferLength);
|
||||||
*OutBufferLength = m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength;
|
RtlCopyMemory(ConfigDescriptorBuffer, m_ConfigurationDescriptors[0].ConfigurationDescriptor, Length);
|
||||||
|
*OutBufferLength = Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
|
@ -904,7 +907,7 @@ CUSBDevice::SubmitSetupPacket(
|
||||||
//
|
//
|
||||||
// commit setup packet
|
// commit setup packet
|
||||||
//
|
//
|
||||||
Status = CommitSetupPacket(SetupPacket, 0, BufferLength, Mdl);
|
Status = CommitSetupPacket(SetupPacket, NULL, BufferLength, Mdl);
|
||||||
|
|
||||||
if (Mdl != NULL)
|
if (Mdl != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1055,7 +1058,7 @@ CUSBDevice::SelectConfiguration(
|
||||||
CtrlSetup.wValue.W = bConfigurationValue;
|
CtrlSetup.wValue.W = bConfigurationValue;
|
||||||
|
|
||||||
// select configuration
|
// select configuration
|
||||||
Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
|
Status = CommitSetupPacket(&CtrlSetup, NULL, 0, NULL);
|
||||||
|
|
||||||
if (!ConfigurationDescriptor)
|
if (!ConfigurationDescriptor)
|
||||||
{
|
{
|
||||||
|
@ -1174,7 +1177,7 @@ CUSBDevice::SelectInterface(
|
||||||
CtrlSetup.bmRequestType.B = 0x01;
|
CtrlSetup.bmRequestType.B = 0x01;
|
||||||
|
|
||||||
// issue request
|
// issue request
|
||||||
Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
|
Status = CommitSetupPacket(&CtrlSetup, NULL, 0, NULL);
|
||||||
|
|
||||||
// informal debug print
|
// informal debug print
|
||||||
DPRINT1("CUSBDevice::SelectInterface AlternateSetting %x InterfaceNumber %x Status %x\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber, Status);
|
DPRINT1("CUSBDevice::SelectInterface AlternateSetting %x InterfaceNumber %x Status %x\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber, Status);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue