//
// initialize request
//
- Stack=IoGetNextIrpStackLocation(Irp);
+ Stack = IoGetNextIrpStackLocation(Irp);
Stack->MajorFunction = IRP_MJ_PNP;
Stack->MinorFunction = IRP_MN_QUERY_INTERFACE;
Stack->Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);
//
// call driver
//
- Status= IoCallDriver(DeviceObject, Irp);
+ Status = IoCallDriver(DeviceObject, Irp);
//
// did operation complete
//
// invoke callback
//
- Status = FDODeviceExtension->BusInterface.StartDeviceCallback(FDODeviceExtension->DeviceDescriptor,
- FDODeviceExtension->ConfigurationDescriptor,
+ Status = FDODeviceExtension->BusInterface.StartDeviceCallback(FDODeviceExtension->DeviceDescriptor,
+ FDODeviceExtension->ConfigurationDescriptor,
&FunctionDescriptorBuffer,
&FunctionDescriptorBufferLength,
DeviceObject,
FDODeviceExtension->PhysicalDeviceObject);
- DPRINT("USBCCGP_CustomEnumWithInterface Status %x\n", Status);
+ DPRINT("USBCCGP_CustomEnumWithInterface Status %lx\n", Status);
if (!NT_SUCCESS(Status))
{
//
Offset = (PUCHAR)ConfigurationDescriptor + ConfigurationDescriptor->bLength;
End = (PUCHAR)ConfigurationDescriptor + ConfigurationDescriptor->wTotalLength;
- while(Offset < End)
+ while (Offset < End)
{
//
// get association descriptor
Offset = (PUCHAR)ConfigurationDescriptor + ConfigurationDescriptor->bLength;
End = (PUCHAR)ConfigurationDescriptor + ConfigurationDescriptor->wTotalLength;
- while(Offset < End)
+ while (Offset < End)
{
//
// get association descriptor
Offset = (PUCHAR)AssociationDescriptor + AssociationDescriptor->bLength;
End = (PUCHAR)ConfigurationDescriptor + ConfigurationDescriptor->wTotalLength;
- while(Offset < End)
+ while (Offset < End)
{
//
// get association descriptor
// get interface description
//
Status = USBCCGP_GetStringDescriptor(FDODeviceExtension->NextDeviceObject,
- 100 * sizeof(WCHAR),
- Descriptor->iFunction,
+ 100 * sizeof(WCHAR),
+ Descriptor->iFunction,
0x0409, //FIXME
(PVOID*)&DescriptionBuffer);
if (!NT_SUCCESS(Status))
FunctionDescriptor->HardwareId.Length = Index * sizeof(WCHAR);
FunctionDescriptor->HardwareId.MaximumLength = (Index + 1) * sizeof(WCHAR);
-
//
// now init the compatible id
//
return STATUS_INSUFFICIENT_RESOURCES;
}
- for(Index = 0; Index < DescriptorCount; Index++)
+ for (Index = 0; Index < DescriptorCount; Index++)
{
//
// init function descriptors
FDODeviceExtension->DeviceDescriptor->bcdDevice,
FunctionIndex) + 1;
Index += swprintf(&Buffer[Index], L"USB\\VID_%04x&PID_%04x&MI_%02x", FDODeviceExtension->DeviceDescriptor->idVendor,
- FDODeviceExtension->DeviceDescriptor->idProduct,
- FunctionIndex) + 1;
+ FDODeviceExtension->DeviceDescriptor->idProduct,
+ FunctionIndex) + 1;
// allocate result buffer
DescriptionBuffer = AllocateItem(NonPagedPool, (Index + 1) * sizeof(WCHAR));
//
// init function descriptors
//
- for(Index = 0; Index < FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
+ for (Index = 0; Index < FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
{
// get interface descriptor
InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(FDODeviceExtension->ConfigurationDescriptor, FDODeviceExtension->ConfigurationDescriptor, Index, 0, -1, -1, -1);
//
// failed to init ids
//
- DPRINT1("[USBCCGP] Failed to init ids with %x\n", Status);
+ DPRINT1("[USBCCGP] Failed to init ids with %lx\n", Status);
return Status;
}
//
// first check if all interfaces belong to the same audio class
//
- for(Index = 0; Index < FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
+ for (Index = 0; Index < FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
{
//
// get interface descriptor
//
// failed to allocate descriptor array
//
- DPRINT1("[USBCCGP] Failed to allocate descriptor array %x\n", Status);
+ DPRINT1("[USBCCGP] Failed to allocate descriptor array %lx\n", Status);
return Status;
}
//
// failed to init ids
//
- DPRINT1("[USBCCGP] Failed to init ids with %x\n", Status);
+ DPRINT1("[USBCCGP] Failed to init ids with %lx\n", Status);
return Status;
}
NTAPI
USBSTOR_SyncForwardIrpCompletionRoutine(
PDEVICE_OBJECT DeviceObject,
- PIRP Irp,
+ PIRP Irp,
PVOID Context)
{
if (Irp->PendingReturned)
DPRINT1("FunctionCount %lu\n", FunctionDescriptorCount);
- for(Index = 0; Index < FunctionDescriptorCount; Index++)
+ for (Index = 0; Index < FunctionDescriptorCount; Index++)
{
DPRINT1("Function %lu\n", Index);
DPRINT1("FunctionNumber %lu\n", FunctionDescriptor[Index].FunctionNumber);
// count length of string
//
String = DeviceId;
- while(*String)
+ while (*String)
{
StringLength = wcslen(String) + 1;
Length += StringLength;
//
*OutString = String;
- while(*DeviceId)
+ while (*DeviceId)
{
StringLength = swprintf(String, L"%s&MI_%02x", DeviceId, InterfaceNumber) + 1;
Length = wcslen(DeviceId) + 1;
DPRINT("BusQueryDeviceID %S\n", Buffer);
ExFreePool((PVOID)Irp->IoStatus.Information);
- Irp->IoStatus .Information = (ULONG_PTR)Buffer;
+ Irp->IoStatus.Information = (ULONG_PTR)Buffer;
}
else
{
switch(IoStack->MinorFunction)
{
- case IRP_MN_QUERY_DEVICE_RELATIONS:
- {
- //
- // handle device relations
- //
- Status = USBCCGP_PdoHandleDeviceRelations(DeviceObject, Irp);
- break;
- }
- case IRP_MN_QUERY_DEVICE_TEXT:
- {
- //
- // handle query device text
- //
- Status = USBCCGP_PdoHandleQueryDeviceText(DeviceObject, Irp);
- break;
- }
- case IRP_MN_QUERY_ID:
- {
- //
- // handle request
- //
- Status = USBCCGP_PdoHandleQueryId(DeviceObject, Irp);
- break;
- }
- case IRP_MN_REMOVE_DEVICE:
- {
- //
- // remove us from the fdo's pdo list
- //
- bFound = FALSE;
- for(Index = 0; Index < PDODeviceExtension->FDODeviceExtension->FunctionDescriptorCount; Index++)
- {
- if (PDODeviceExtension->FDODeviceExtension->ChildPDO[Index] == DeviceObject)
- {
- //
- // remove us
- //
- PDODeviceExtension->FDODeviceExtension->ChildPDO[Index] = NULL;
- bFound = TRUE;
- break;
- }
- }
-
- //
- // Complete the IRP
- //
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- if (bFound)
- {
- //
- // Delete the device object
- //
- IoDeleteDevice(DeviceObject);
- }
- return STATUS_SUCCESS;
- }
- case IRP_MN_QUERY_CAPABILITIES:
- {
- //
- // copy device capabilities
- //
- RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities, &PDODeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));
-
- /* Complete the IRP */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
- }
+ case IRP_MN_QUERY_DEVICE_RELATIONS:
+ {
+ //
+ // handle device relations
+ //
+ Status = USBCCGP_PdoHandleDeviceRelations(DeviceObject, Irp);
+ break;
+ }
+ case IRP_MN_QUERY_DEVICE_TEXT:
+ {
+ //
+ // handle query device text
+ //
+ Status = USBCCGP_PdoHandleQueryDeviceText(DeviceObject, Irp);
+ break;
+ }
+ case IRP_MN_QUERY_ID:
+ {
+ //
+ // handle request
+ //
+ Status = USBCCGP_PdoHandleQueryId(DeviceObject, Irp);
+ break;
+ }
+ case IRP_MN_REMOVE_DEVICE:
+ {
+ //
+ // remove us from the fdo's pdo list
+ //
+ bFound = FALSE;
+ for(Index = 0; Index < PDODeviceExtension->FDODeviceExtension->FunctionDescriptorCount; Index++)
+ {
+ if (PDODeviceExtension->FDODeviceExtension->ChildPDO[Index] == DeviceObject)
+ {
+ //
+ // remove us
+ //
+ PDODeviceExtension->FDODeviceExtension->ChildPDO[Index] = NULL;
+ bFound = TRUE;
+ break;
+ }
+ }
+
+ //
+ // Complete the IRP
+ //
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ if (bFound)
+ {
+ //
+ // Delete the device object
+ //
+ IoDeleteDevice(DeviceObject);
+ }
+ return STATUS_SUCCESS;
+ }
+ case IRP_MN_QUERY_CAPABILITIES:
+ {
+ //
+ // copy device capabilities
+ //
+ RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities, &PDODeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));
+
+ /* Complete the IRP */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+ }
case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_QUERY_STOP_DEVICE:
{
Status = STATUS_SUCCESS;
break;
}
- case IRP_MN_START_DEVICE:
- {
- //
- // no-op for PDO
- //
- DPRINT("[USBCCGP] PDO IRP_MN_START\n");
- Status = STATUS_SUCCESS;
- break;
- }
- case IRP_MN_QUERY_INTERFACE:
- {
- //
- // forward to lower device object
- //
- IoSkipCurrentIrpStackLocation(Irp);
- return IoCallDriver(PDODeviceExtension->NextDeviceObject, Irp);
- }
- default:
+ case IRP_MN_START_DEVICE:
+ {
+ //
+ // no-op for PDO
+ //
+ DPRINT("[USBCCGP] PDO IRP_MN_START\n");
+ Status = STATUS_SUCCESS;
+ break;
+ }
+ case IRP_MN_QUERY_INTERFACE:
+ {
+ //
+ // forward to lower device object
+ //
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(PDODeviceExtension->NextDeviceObject, Irp);
+ }
+ default:
{
//
// do nothing
NTSTATUS
USBCCGP_BuildConfigurationDescriptor(
- PDEVICE_OBJECT DeviceObject,
+ PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
//
TotalSize = sizeof(USB_CONFIGURATION_DESCRIPTOR);
- for(Index = 0; Index < PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; Index++)
+ for (Index = 0; Index < PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; Index++)
{
//
// get current interface descriptor
// move to next descriptor
//
InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)((ULONG_PTR)InterfaceDescriptor + InterfaceDescriptor->bLength);
- }while(TRUE);
+ } while(TRUE);
}
//
RtlCopyMemory(Buffer, ConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
BufferPtr = (PUCHAR)((ULONG_PTR)Buffer + ConfigurationDescriptor->bLength);
- for(Index = 0; Index < PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; Index++)
+ for (Index = 0; Index < PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; Index++)
{
//
// get current interface descriptor
// move to next descriptor
//
InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)((ULONG_PTR)InterfaceDescriptor + InterfaceDescriptor->bLength);
- }while(TRUE);
+ } while(TRUE);
}
//
NTSTATUS
USBCCGP_PDOSelectConfiguration(
- PDEVICE_OBJECT DeviceObject,
+ PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
// search for the interface in the local interface list
//
FoundInterface = FALSE;
- for(InterfaceIndex = 0; InterfaceIndex < PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; InterfaceIndex++)
+ for (InterfaceIndex = 0; InterfaceIndex < PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; InterfaceIndex++)
{
if (PDODeviceExtension->FunctionDescriptor->InterfaceDescriptorList[InterfaceIndex]->bInterfaceNumber == InterfaceInformation->InterfaceNumber)
{
// now query the total interface list
//
Entry = NULL;
- for(InterfaceIndex = 0; InterfaceIndex < PDODeviceExtension->InterfaceListCount; InterfaceIndex++)
+ for (InterfaceIndex = 0; InterfaceIndex < PDODeviceExtension->InterfaceListCount; InterfaceIndex++)
{
if (PDODeviceExtension->InterfaceList[InterfaceIndex].Interface->InterfaceNumber == InterfaceInformation->InterfaceNumber)
{
NeedSelect = FALSE;
if (Entry->InterfaceDescriptor->bAlternateSetting == InterfaceInformation->AlternateSetting)
{
-
for(InterfaceIndex = 0; InterfaceIndex < InterfaceInformation->NumberOfPipes; InterfaceIndex++)
{
if (InterfaceInformation->Pipes[InterfaceIndex].MaximumTransferSize != Entry->Interface->Pipes[InterfaceIndex].MaximumTransferSize)
FreeItem(NewUrb);
}
- }while(Length);
+ } while(Length);
//
// store configuration handle
NTSTATUS
PDO_HandleInternalDeviceControl(
- PDEVICE_OBJECT DeviceObject,
+ PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
}
else if (Urb->UrbHeader.Function == URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE)
{
- if(Urb->UrbControlDescriptorRequest.DescriptorType == USB_DEVICE_DESCRIPTOR_TYPE)
+ if (Urb->UrbControlDescriptorRequest.DescriptorType == USB_DEVICE_DESCRIPTOR_TYPE)
{
//
// is the buffer big enough
return Status;
}
-
-
DPRINT1("IOCTL %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode);
DPRINT1("InputBufferLength %lu\n", IoStack->Parameters.DeviceIoControl.InputBufferLength);
DPRINT1("OutputBufferLength %lu\n", IoStack->Parameters.DeviceIoControl.OutputBufferLength);
NTSTATUS
PDO_Dispatch(
- PDEVICE_OBJECT DeviceObject,
+ PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
-
}
Status = m_Hardware->ClearPortStatus(PortId, C_PORT_CONNECTION);
break;
case C_PORT_RESET:
- Status= m_Hardware->ClearPortStatus(PortId, C_PORT_RESET);
+ Status = m_Hardware->ClearPortStatus(PortId, C_PORT_RESET);
break;
default:
DPRINT("[USBLIB] Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
- //
- // generate setup packet
- //
- CtrlSetup.bRequest = USB_REQUEST_GET_STATUS;
- CtrlSetup.wValue.LowByte = 0;
- CtrlSetup.wValue.HiByte = 0;
- CtrlSetup.wIndex.W = Urb->UrbControlGetStatusRequest.Index;
- CtrlSetup.wLength = (USHORT)Urb->UrbControlGetStatusRequest.TransferBufferLength;
- CtrlSetup.bmRequestType.B = 0x80;
-
-
- if (Urb->UrbHeader.Function == URB_FUNCTION_GET_STATUS_FROM_INTERFACE)
- {
- //
- // add interface type
- //
- CtrlSetup.bmRequestType.B |= 0x01;
- }
- else if (Urb->UrbHeader.Function == URB_FUNCTION_GET_STATUS_FROM_ENDPOINT)
- {
- //
- // add interface type
- //
- CtrlSetup.bmRequestType.B |= 0x02;
- }
+ //
+ // generate setup packet
+ //
+ CtrlSetup.bRequest = USB_REQUEST_GET_STATUS;
+ CtrlSetup.wValue.LowByte = 0;
+ CtrlSetup.wValue.HiByte = 0;
+ CtrlSetup.wIndex.W = Urb->UrbControlGetStatusRequest.Index;
+ CtrlSetup.wLength = (USHORT)Urb->UrbControlGetStatusRequest.TransferBufferLength;
+ CtrlSetup.bmRequestType.B = 0x80;
+
+ if (Urb->UrbHeader.Function == URB_FUNCTION_GET_STATUS_FROM_INTERFACE)
+ {
+ //
+ // add interface type
+ //
+ CtrlSetup.bmRequestType.B |= 0x01;
+ }
+ else if (Urb->UrbHeader.Function == URB_FUNCTION_GET_STATUS_FROM_ENDPOINT)
+ {
+ //
+ // add interface type
+ //
+ CtrlSetup.bmRequestType.B |= 0x02;
+ }
//
// submit setup packet
RtlZeroMemory(m_ConfigurationDescriptors, sizeof(USB_CONFIGURATION) * m_DeviceDescriptor.bNumConfigurations);
// retrieve the configuration descriptors
- for(Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
+ for (Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
{
// retrieve configuration descriptors from device
Status = CreateConfigurationDescriptor(Index);
if (ConfigurationDescriptor)
{
// find configuration index
- for(Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
+ for (Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
{
if (m_ConfigurationDescriptors[Index].ConfigurationDescriptor->bConfigurationValue == ConfigurationDescriptor->bConfigurationValue)
{
if (!Found)
{
- DPRINT1("[USBLIB] invalid configuration value %lu\n", ConfigurationDescriptor->bConfigurationValue);
+ DPRINT1("[USBLIB] invalid configuration value %u\n", ConfigurationDescriptor->bConfigurationValue);
return STATUS_INVALID_PARAMETER;
}
if (!ConfigurationDescriptor)
{
// unconfigure request
- DPRINT1("CUSBDevice::SelectConfiguration Unconfigure Request Status %x\n", Status);
+ DPRINT1("CUSBDevice::SelectConfiguration Unconfigure Request Status %lx\n", Status);
m_ConfigurationIndex = 0;
return Status;
}
// informal debug print
- DPRINT1("CUSBDevice::SelectConfiguration New Configuration %x Old Configuration %x Result %x\n", ConfigurationIndex, m_ConfigurationIndex, Status);
+ DPRINT1("CUSBDevice::SelectConfiguration New Configuration %x Old Configuration %x Result %lx\n", ConfigurationIndex, m_ConfigurationIndex, Status);
if (!NT_SUCCESS(Status))
{
//
}
// destroy old interface info
- while(!IsListEmpty(&m_ConfigurationDescriptors[m_ConfigurationIndex].InterfaceList))
+ while (!IsListEmpty(&m_ConfigurationDescriptors[m_ConfigurationIndex].InterfaceList))
{
// remove entry
Entry = RemoveHeadList(&m_ConfigurationDescriptors[m_ConfigurationIndex].InterfaceList);
Status = CommitSetupPacket(&CtrlSetup, NULL, 0, NULL);
// 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 %lx\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber, Status);
#if 0
- if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
// failed to select interface
return Status;
Status = STATUS_SUCCESS;
-
// find interface
Found = FALSE;
Entry = m_ConfigurationDescriptors[ConfigurationIndex].InterfaceList.Flink;
- while(Entry != &m_ConfigurationDescriptors[ConfigurationIndex].InterfaceList)
+ while (Entry != &m_ConfigurationDescriptors[ConfigurationIndex].InterfaceList)
{
// grab interface descriptor
UsbInterface = (PUSB_INTERFACE)CONTAINING_RECORD(Entry, USB_INTERFACE, ListEntry);
InterfaceInfo->NumberOfPipes = UsbInterface->InterfaceDescriptor->bNumEndpoints;
// copy pipe handles
- for(PipeIndex = 0; PipeIndex < UsbInterface->InterfaceDescriptor->bNumEndpoints; PipeIndex++)
+ for (PipeIndex = 0; PipeIndex < UsbInterface->InterfaceDescriptor->bNumEndpoints; PipeIndex++)
{
// copy pipe handle
DPRINT1("PipeIndex %lu\n", PipeIndex);
DPRINT1("MaximumPacketSize %d\n", InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize);
DPRINT1("MaximumTransferSize %d\n", InterfaceInfo->Pipes[PipeIndex].MaximumTransferSize);
DPRINT1("PipeFlags %d\n", InterfaceInfo->Pipes[PipeIndex].PipeFlags);
- DPRINT1("PipeType %dd\n", InterfaceInfo->Pipes[PipeIndex].PipeType);
+ DPRINT1("PipeType %d\n", InterfaceInfo->Pipes[PipeIndex].PipeType);
DPRINT1("UsbEndPoint %x\n", InterfaceInfo->Pipes[PipeIndex].EndpointAddress);
// sanity checks
UsbInterface->EndPoints[PipeIndex].DataToggle = FALSE;
}
-
//
// done
//