[USBEHCI_NEW]

- Add interface function GetHubControllerSymbolicLink
- Implement IOCTL_USB_GET_ROOT_HUB_NAME for usbview

svn path=/branches/usb-bringup/; revision=51387
This commit is contained in:
Johannes Anderwald 2011-04-17 22:38:32 +00:00
parent bbad937d99
commit a2b99febfa
3 changed files with 141 additions and 48 deletions

View file

@ -230,18 +230,16 @@ CHCDController::HandleDeviceControl(
// //
DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension; DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
//
// sanity check
//
PC_ASSERT(DeviceExtension->IsFDO);
DPRINT1("HandleDeviceControl>Type: FDO %u IoCtl %x InputBufferLength %lu OutputBufferLength %lu\n", DPRINT1("HandleDeviceControl>Type: IoCtl %x InputBufferLength %lu OutputBufferLength %lu\n",
DeviceExtension->IsFDO,
IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.IoControlCode,
IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.InputBufferLength,
IoStack->Parameters.DeviceIoControl.OutputBufferLength); IoStack->Parameters.DeviceIoControl.OutputBufferLength);
//
// get device type
//
if (DeviceExtension->IsFDO)
{
// //
// perform ioctl for FDO // perform ioctl for FDO
// //
@ -257,6 +255,9 @@ CHCDController::HandleDeviceControl(
// //
Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, 0, NULL, &ResultLength); Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, 0, NULL, &ResultLength);
//
// get input buffer
//
DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer; DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer;
// //
@ -302,15 +303,50 @@ CHCDController::HandleDeviceControl(
} }
else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_USB_GET_ROOT_HUB_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"); //
// 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 else
{ {
// //
// the PDO does not support any device IOCTLs // buffer is certainly too small
// //
Status = STATUS_SUCCESS; Status = STATUS_BUFFER_OVERFLOW;
Irp->IoStatus.Information = sizeof(USB_HCD_DRIVERKEY_NAME);
}
} }
// //

View file

@ -36,6 +36,8 @@ public:
// IHubController interface functions // IHubController interface functions
virtual NTSTATUS Initialize(IN PDRIVER_OBJECT DriverObject, IN PHCDCONTROLLER Controller, IN PUSBHARDWAREDEVICE Device, IN BOOLEAN IsRootHubDevice, IN ULONG DeviceAddress); 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 // IDispatchIrp interface functions
virtual NTSTATUS HandlePnp(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp); virtual NTSTATUS HandlePnp(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp);
@ -46,7 +48,6 @@ public:
NTSTATUS HandleQueryInterface(PIO_STACK_LOCATION IoStack); NTSTATUS HandleQueryInterface(PIO_STACK_LOCATION IoStack);
NTSTATUS SetDeviceInterface(BOOLEAN bEnable); NTSTATUS SetDeviceInterface(BOOLEAN bEnable);
NTSTATUS CreatePDO(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * OutDeviceObject); NTSTATUS CreatePDO(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * OutDeviceObject);
NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject);
PUSBHARDWAREDEVICE GetUsbHardware(); PUSBHARDWAREDEVICE GetUsbHardware();
ULONG AcquireDeviceAddress(); ULONG AcquireDeviceAddress();
VOID ReleaseDeviceAddress(ULONG DeviceAddress); VOID ReleaseDeviceAddress(ULONG DeviceAddress);
@ -71,8 +72,10 @@ protected:
PUSBHARDWAREDEVICE m_Hardware; PUSBHARDWAREDEVICE m_Hardware;
BOOLEAN m_IsRootHubDevice; BOOLEAN m_IsRootHubDevice;
ULONG m_DeviceAddress; ULONG m_DeviceAddress;
BOOLEAN m_InterfaceEnabled; BOOLEAN m_InterfaceEnabled;
UNICODE_STRING m_HubDeviceInterfaceString; UNICODE_STRING m_HubDeviceInterfaceString;
PDEVICE_OBJECT m_HubControllerDeviceObject; PDEVICE_OBJECT m_HubControllerDeviceObject;
PDRIVER_OBJECT m_DriverObject; PDRIVER_OBJECT m_DriverObject;
@ -267,6 +270,51 @@ CHubController::GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject)
return STATUS_SUCCESS; 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 NTSTATUS
CHubController::HandlePnp( CHubController::HandlePnp(

View file

@ -444,6 +444,15 @@ DECLARE_INTERFACE_(IHubController, IUnknown)
virtual NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject) = 0; 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; typedef IHubController *PHUBCONTROLLER;