Author: janderwald Date: Sun Apr 17 22:38:32 2011 New Revision: 51387
URL: http://svn.reactos.org/svn/reactos?rev=51387&view=rev Log: [USBEHCI_NEW] - Add interface function GetHubControllerSymbolicLink - Implement IOCTL_USB_GET_ROOT_HUB_NAME for usbview
Modified: branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h
Modified: branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci_... ============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp [iso-8859-1] Sun Apr 17 22:38:32 2011 @@ -230,87 +230,123 @@ // DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- - DPRINT1("HandleDeviceControl>Type: FDO %u IoCtl %x InputBufferLength %lu OutputBufferLength %lu\n", - DeviceExtension->IsFDO, + // + // sanity check + // + PC_ASSERT(DeviceExtension->IsFDO); + + DPRINT1("HandleDeviceControl>Type: IoCtl %x InputBufferLength %lu OutputBufferLength %lu\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength);
// - // get device type - // - if (DeviceExtension->IsFDO) - { - // - // perform ioctl for FDO - // - if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_GET_HCD_DRIVERKEY_NAME) - { - // - // check if sizee is at least >= USB_HCD_DRIVERKEY_NAME - // - if(IoStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(USB_HCD_DRIVERKEY_NAME)) - { - // - // get device property size - // - Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, 0, NULL, &ResultLength); - - DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer; - - // - // check result - // - if (Status == STATUS_BUFFER_TOO_SMALL) + // perform ioctl for FDO + // + if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_GET_HCD_DRIVERKEY_NAME) + { + // + // check if sizee is at least >= USB_HCD_DRIVERKEY_NAME + // + if(IoStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(USB_HCD_DRIVERKEY_NAME)) + { + // + // get device property size + // + Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, 0, NULL, &ResultLength); + + // + // get input buffer + // + DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer; + + // + // check result + // + if (Status == STATUS_BUFFER_TOO_SMALL) + { + // + // does the caller provide enough buffer space + // + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength >= ResultLength) { // - // does the caller provide enough buffer space - // - if (IoStack->Parameters.DeviceIoControl.OutputBufferLength >= ResultLength) + // it does + // + Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, IoStack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(ULONG), DriverKey->DriverKeyName, &ResultLength); + + if (NT_SUCCESS(Status)) { // - // it does + // informal debug print // - Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, IoStack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(ULONG), DriverKey->DriverKeyName, &ResultLength); - - if (NT_SUCCESS(Status)) - { - // - // informal debug print - // - DPRINT1("Result %S\n", DriverKey->DriverKeyName); - } + DPRINT1("Result %S\n", DriverKey->DriverKeyName); } - - // - // store result - // - DriverKey->ActualLength = ResultLength + FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + sizeof(WCHAR); - Irp->IoStatus.Information = IoStack->Parameters.DeviceIoControl.OutputBufferLength; - Status = STATUS_SUCCESS; } - } - else - { - // - // buffer is certainly too small - // - Status = STATUS_BUFFER_OVERFLOW; - Irp->IoStatus.Information = sizeof(USB_HCD_DRIVERKEY_NAME); - } - } - else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_USB_GET_ROOT_HUB_NAME) - { - DPRINT1("IOCTL_USB_GET_ROOT_HUB_NAME is not implemented yet\n"); - } - } - else - { - // - // the PDO does not support any device IOCTLs - // - Status = STATUS_SUCCESS; + + // + // store result + // + DriverKey->ActualLength = ResultLength + FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + sizeof(WCHAR); + Irp->IoStatus.Information = IoStack->Parameters.DeviceIoControl.OutputBufferLength; + Status = STATUS_SUCCESS; + } + } + else + { + // + // buffer is certainly too small + // + Status = STATUS_BUFFER_OVERFLOW; + Irp->IoStatus.Information = sizeof(USB_HCD_DRIVERKEY_NAME); + } + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_USB_GET_ROOT_HUB_NAME) + { + // + // check if sizee is at least >= USB_HCD_DRIVERKEY_NAME + // + if(IoStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(USB_HCD_DRIVERKEY_NAME)) + { + // + // sanity check + // + PC_ASSERT(m_HubController); + + // + // get input buffer + // + DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer; + + // + // get symbolic link + // + Status = m_HubController->GetHubControllerSymbolicLink(IoStack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(ULONG), DriverKey->DriverKeyName, &ResultLength); + + + if (NT_SUCCESS(Status)) + { + // + // informal debug print + // + DPRINT1("Result %S\n", DriverKey->DriverKeyName); + } + + // + // store result + // + DriverKey->ActualLength = ResultLength + FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + sizeof(WCHAR); + Irp->IoStatus.Information = IoStack->Parameters.DeviceIoControl.OutputBufferLength; + Status = STATUS_SUCCESS; + } + else + { + // + // buffer is certainly too small + // + Status = STATUS_BUFFER_OVERFLOW; + Irp->IoStatus.Information = sizeof(USB_HCD_DRIVERKEY_NAME); + } }
//
Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci_... ============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] Sun Apr 17 22:38:32 2011 @@ -36,6 +36,8 @@
// IHubController interface functions virtual NTSTATUS Initialize(IN PDRIVER_OBJECT DriverObject, IN PHCDCONTROLLER Controller, IN PUSBHARDWAREDEVICE Device, IN BOOLEAN IsRootHubDevice, IN ULONG DeviceAddress); + virtual NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject); + virtual NTSTATUS GetHubControllerSymbolicLink(ULONG BufferLength, PVOID Buffer, PULONG RequiredLength);
// IDispatchIrp interface functions virtual NTSTATUS HandlePnp(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp); @@ -46,7 +48,6 @@ NTSTATUS HandleQueryInterface(PIO_STACK_LOCATION IoStack); NTSTATUS SetDeviceInterface(BOOLEAN bEnable); NTSTATUS CreatePDO(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * OutDeviceObject); - NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject); PUSBHARDWAREDEVICE GetUsbHardware(); ULONG AcquireDeviceAddress(); VOID ReleaseDeviceAddress(ULONG DeviceAddress); @@ -71,8 +72,10 @@ PUSBHARDWAREDEVICE m_Hardware; BOOLEAN m_IsRootHubDevice; ULONG m_DeviceAddress; + BOOLEAN m_InterfaceEnabled; UNICODE_STRING m_HubDeviceInterfaceString; + PDEVICE_OBJECT m_HubControllerDeviceObject; PDRIVER_OBJECT m_DriverObject;
@@ -267,6 +270,51 @@
return STATUS_SUCCESS; } +//----------------------------------------------------------------------------------------- +NTSTATUS +CHubController::GetHubControllerSymbolicLink( + ULONG BufferLength, + PVOID Buffer, + PULONG RequiredLength) +{ + if (!m_InterfaceEnabled) + { + // + // device interface not yet enabled + // + return STATUS_UNSUCCESSFUL; + } + + if (BufferLength < m_HubDeviceInterfaceString.Length - 8) + { + // + // buffer too small + // length is without '??' + // + *RequiredLength = m_HubDeviceInterfaceString.Length- 8; + + // + // done + // + return STATUS_BUFFER_OVERFLOW; + } + + // + // copy symbolic link + // + RtlCopyMemory(Buffer, &m_HubDeviceInterfaceString.Buffer[4], m_HubDeviceInterfaceString.Length - 8); + + // + // store length, length is without '??' + // + *RequiredLength = m_HubDeviceInterfaceString.Length - 8; + + // + // done + // + return STATUS_SUCCESS; +} + //----------------------------------------------------------------------------------------- NTSTATUS CHubController::HandlePnp(
Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci_... ============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] Sun Apr 17 22:38:32 2011 @@ -444,6 +444,15 @@
virtual NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject) = 0;
+//---------------------------------------------------------------------------------------- +// +// GetHubControllerSymbolicLink +// +// Description: Returns the symbolic link of the root hub + + virtual NTSTATUS GetHubControllerSymbolicLink(ULONG BufferLength, PVOID Buffer, PULONG RequiredLength) = 0; + + };
typedef IHubController *PHUBCONTROLLER;