[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [win-pv-devel] [PATCH 1/6] Cleanup fdo dispatch entry points



> -----Original Message-----
> From: win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx [mailto:win-pv-devel-
> bounces@xxxxxxxxxxxxxxxxxxxx] On Behalf Of Owen Smith
> Sent: 29 October 2015 14:50
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith
> Subject: [win-pv-devel] [PATCH 1/6] Cleanup fdo dispatch entry points
> 
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

Acked-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> ---
>  src/xeniface/fdo.c | 98 
> ++++++++++++++++--------------------------------------
>  src/xeniface/wmi.c | 82 +++++++++++++++------------------------------
>  src/xeniface/wmi.h | 13 +++-----
>  3 files changed, 59 insertions(+), 134 deletions(-)
> 
> diff --git a/src/xeniface/fdo.c b/src/xeniface/fdo.c
> index d6b006e..f7aa542 100644
> --- a/src/xeniface/fdo.c
> +++ b/src/xeniface/fdo.c
> @@ -1234,7 +1234,7 @@ done:
> 
>  static DECLSPEC_NOINLINE NTSTATUS
>  FdoDispatchPnp(
> -    IN  PXENIFACE_FDO     Fdo,
> +    IN  PXENIFACE_FDO   Fdo,
>      IN  PIRP            Irp
>      )
>  {
> @@ -1945,7 +1945,7 @@ FdoSystemPower(
> 
>  static DECLSPEC_NOINLINE NTSTATUS
>  FdoDispatchPower(
> -    IN  PXENIFACE_FDO     Fdo,
> +    IN  PXENIFACE_FDO   Fdo,
>      IN  PIRP            Irp
>      )
>  {
> @@ -2013,7 +2013,7 @@ done:
> 
>  static DECLSPEC_NOINLINE NTSTATUS
>  FdoDispatchDefault(
> -    IN  PXENIFACE_FDO     Fdo,
> +    IN  PXENIFACE_FDO   Fdo,
>      IN  PIRP            Irp
>      )
>  {
> @@ -2025,80 +2025,44 @@ FdoDispatchDefault(
>      return status;
>  }
> 
> -NTSTATUS
> -FdoCreateFile (
> -    __in PXENIFACE_FDO  Fdo,
> -    __inout PIRP        Irp
> +static DECLSPEC_NOINLINE NTSTATUS
> +FdoDispatchComplete(
> +    IN  PXENIFACE_FDO   Fdo,
> +    IN  PIRP            Irp
>      )
>  {
> -    PIO_STACK_LOCATION  Stack = IoGetCurrentIrpStackLocation(Irp);
> -    NTSTATUS            status;
> -
> -    XenIfaceDebugPrint(TRACE, "FO %p, Process %p\n", Stack->FileObject,
> PsGetCurrentProcess());
> +    UNREFERENCED_PARAMETER(Fdo);
> 
> -    if (Deleted == Fdo->Dx->DevicePnpState) {
> -        Irp->IoStatus.Status = STATUS_NO_SUCH_DEVICE;
> -        IoCompleteRequest(Irp, IO_NO_INCREMENT);
> -        return STATUS_NO_SUCH_DEVICE;
> -    }
> -
> -    status = STATUS_SUCCESS;
>      Irp->IoStatus.Information = 0;
> -    Irp->IoStatus.Status = status;
> -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
> +    Irp->IoStatus.Status = STATUS_SUCCESS;
> +    IoCompleteRequest (Irp, IO_NO_INCREMENT);
> 
> -    return status;
> +    return STATUS_SUCCESS;
>  }
> 
> -
> -NTSTATUS
> -FdoClose (
> -    __in PXENIFACE_FDO  Fdo,
> -    __inout PIRP        Irp
> +static DECLSPEC_NOINLINE NTSTATUS
> +FdoDispatchSystemControl(
> +    IN  PXENIFACE_FDO   Fdo,
> +    IN  PIRP            Irp
>      )
> -
>  {
> -    PIO_STACK_LOCATION  Stack = IoGetCurrentIrpStackLocation(Irp);
>      NTSTATUS            status;
> 
> -    XenIfaceDebugPrint(TRACE, "FO %p, Process %p\n", Stack->FileObject,
> PsGetCurrentProcess());
> -
> -    XenIfaceCleanup(Fdo, Stack->FileObject);
> -
> -    status = STATUS_SUCCESS;
> -    Irp->IoStatus.Information = 0;
> -    Irp->IoStatus.Status = status;
> -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
> -
> -    return status;
> -}
> -
> -
> -NTSTATUS
> -FdoReadWrite (
> -    __in PXENIFACE_FDO fdoData,
> -    __inout PIRP Irp
> -    )
> -
> -{
> -
> -    NTSTATUS     status;
> -
> -    XenIfaceDebugPrint(TRACE, "ReadWrite called\n");
> -
> -    status = STATUS_SUCCESS;
> -    Irp->IoStatus.Information = 0;
> -    Irp->IoStatus.Status = status;
> -    IoCompleteRequest (Irp, IO_NO_INCREMENT);
> +    status = WmiProcessMinorFunction(Fdo, Irp);
> +    if (status == STATUS_NOT_SUPPORTED) {
> +        IoSkipCurrentIrpStackLocation(Irp);
> +        status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
> +    } else {
> +        Irp->IoStatus.Status = status;
> +        IoCompleteRequest(Irp, IO_NO_INCREMENT);
> +    }
> 
>      return status;
>  }
> 
> -
> -
>  NTSTATUS
>  FdoDispatch(
> -    IN  PXENIFACE_FDO     Fdo,
> +    IN  PXENIFACE_FDO   Fdo,
>      IN  PIRP            Irp
>      )
>  {
> @@ -2121,20 +2085,14 @@ FdoDispatch(
>          break;
> 
>      case IRP_MJ_SYSTEM_CONTROL:
> -        status = XenIfaceSystemControl(Fdo, Irp);
> -        break;
> -
> -    case IRP_MJ_READ:
> -    case IRP_MJ_WRITE:
> -        status = FdoReadWrite(Fdo, Irp);
> +        status = FdoDispatchSystemControl(Fdo, Irp);
>          break;
> 
>      case IRP_MJ_CREATE:
> -        status = FdoCreateFile(Fdo, Irp);
> -        break;
> -
>      case IRP_MJ_CLOSE:
> -        status = FdoClose(Fdo, Irp);
> +    case IRP_MJ_READ:
> +    case IRP_MJ_WRITE:
> +        status = FdoDispatchComplete(Fdo, Irp);
>          break;
> 
>      default:
> diff --git a/src/xeniface/wmi.c b/src/xeniface/wmi.c
> index 82592e3..0b14e9b 100644
> --- a/src/xeniface/wmi.c
> +++ b/src/xeniface/wmi.c
> @@ -2995,85 +2995,57 @@ WmiRegInfoEx(
>      return WmiRegInfo(fdoData, stack, byteswritten);
>  }
> 
> -
> -
>  NTSTATUS
>  WmiProcessMinorFunction(
> -    IN PXENIFACE_FDO fdoData,
> -    IN PIRP Irp
> -)
> +    IN  PXENIFACE_FDO   Fdo,
> +    IN  PIRP            Irp
> +    )
>  {
> -    PIO_STACK_LOCATION stack;
> -    UCHAR MinorFunction;
> -
> -
> +    PIO_STACK_LOCATION  Stack;
> 
> -    stack = IoGetCurrentIrpStackLocation(Irp);
> +    Stack = IoGetCurrentIrpStackLocation(Irp);
> 
> -    if (stack->Parameters.WMI.ProviderId != (ULONG_PTR)fdoData->Dx-
> >DeviceObject) {
> -        XenIfaceDebugPrint(TRACE,"ProviderID %p %p", stack-
> >Parameters.WMI.ProviderId, fdoData->PhysicalDeviceObject);
> +    if (Stack->Parameters.WMI.ProviderId != (ULONG_PTR)Fdo->Dx-
> >DeviceObject) {
> +        XenIfaceDebugPrint(TRACE,
> +                           "ProviderID %p %p",
> +                           Stack->Parameters.WMI.ProviderId,
> +                           Fdo->PhysicalDeviceObject);
>          return STATUS_NOT_SUPPORTED;
> +    } else {
> +        XenIfaceDebugPrint(TRACE,
> +                           "ProviderID Match %p %p",
> +                           Stack->Parameters.WMI.ProviderId,
> +                           Fdo->PhysicalDeviceObject);
>      }
> -    else {
> -        XenIfaceDebugPrint(TRACE,"ProviderID Match %p %p", stack-
> >Parameters.WMI.ProviderId, fdoData->PhysicalDeviceObject);
> -    }
> -    MinorFunction = stack->MinorFunction;
> 
> -    switch (MinorFunction)
> -    {
> +    switch (Stack->MinorFunction) {
>      case IRP_MN_CHANGE_SINGLE_INSTANCE:
> -        return WmiChangeSingleInstance(fdoData, stack);
> +        return WmiChangeSingleInstance(Fdo, Stack);
>      case IRP_MN_CHANGE_SINGLE_ITEM:
> -        return WmiChangeSingleItem(fdoData, stack);
> +        return WmiChangeSingleItem(Fdo, Stack);
>      case IRP_MN_DISABLE_COLLECTION:
> -        return WmiDisableCollection(fdoData, stack);
> +        return WmiDisableCollection(Fdo, Stack);
>      case IRP_MN_DISABLE_EVENTS:
> -        return WmiDisableEvents(fdoData, stack);
> +        return WmiDisableEvents(Fdo, Stack);
>      case IRP_MN_ENABLE_COLLECTION:
> -        return WmiEnableCollection(fdoData, stack);
> +        return WmiEnableCollection(Fdo, Stack);
>      case IRP_MN_ENABLE_EVENTS:
> -        return WmiEnableEvents(fdoData, stack);
> +        return WmiEnableEvents(Fdo, Stack);
>      case IRP_MN_EXECUTE_METHOD:
> -        return WmiExecuteMethod(fdoData, stack,  &Irp-
> >IoStatus.Information);
> +        return WmiExecuteMethod(Fdo, Stack,  &Irp->IoStatus.Information);
>      case IRP_MN_QUERY_ALL_DATA:
> -        return WmiQueryAllData(fdoData, stack, &Irp->IoStatus.Information);
> +        return WmiQueryAllData(Fdo, Stack, &Irp->IoStatus.Information);
>      case IRP_MN_QUERY_SINGLE_INSTANCE:
> -        return WmiQuerySingleInstance(fdoData, stack, &Irp-
> >IoStatus.Information);
> +        return WmiQuerySingleInstance(Fdo, Stack, &Irp-
> >IoStatus.Information);
>      case IRP_MN_REGINFO:
> -        return WmiRegInfo(fdoData, stack, &Irp->IoStatus.Information);
> +        return WmiRegInfo(Fdo, Stack, &Irp->IoStatus.Information);
>      case IRP_MN_REGINFO_EX:
> -        return WmiRegInfoEx(fdoData, stack, &Irp->IoStatus.Information);
> +        return WmiRegInfoEx(Fdo, Stack, &Irp->IoStatus.Information);
>      default:
>          return STATUS_NOT_SUPPORTED;
>      }
>  }
> 
> -NTSTATUS XenIfaceSystemControl(
> -    __in PXENIFACE_FDO               fdoData,
> -    __inout PIRP Irp
> -    )
> -{
> -    NTSTATUS            status;
> -
> -
> -
> -    status = WmiProcessMinorFunction(fdoData, Irp);
> -
> -    if (status != STATUS_NOT_SUPPORTED) {
> -        Irp->IoStatus.Status = status;
> -        IoCompleteRequest(Irp, IO_NO_INCREMENT);
> -
> -    }
> -    else {
> -        IoSkipCurrentIrpStackLocation(Irp);
> -        status = IoCallDriver(fdoData->LowerDeviceObject, Irp);
> -    }
> -
> -    return(status);
> -
> -}
> -
> -
>  PCHAR
>  WMIMinorFunctionString (
>      __in UCHAR MinorFunction
> diff --git a/src/xeniface/wmi.h b/src/xeniface/wmi.h
> index a49f1b3..f677ee3 100644
> --- a/src/xeniface/wmi.h
> +++ b/src/xeniface/wmi.h
> @@ -37,11 +37,11 @@
>  #include "driver.h"
>  #include "wmi_generated.h"
> 
> -NTSTATUS
> +extern NTSTATUS
>  WmiProcessMinorFunction(
> -    IN PXENIFACE_FDO Fdo,
> -    IN PIRP Irp
> -);
> +    IN  PXENIFACE_FDO   Fdo,
> +    IN  PIRP            Irp
> +    );
> 
>  NTSTATUS
>  WmiInit(
> @@ -54,11 +54,6 @@ WmiFinalise(
>      PXENIFACE_FDO FdoData
>  );
> 
> -NTSTATUS XenIfaceSystemControl(
> -    __in PXENIFACE_FDO               fdoData,
> -    __inout PIRP Irp
> -    );
> -
>  void FireSuspendEvent(
>      IN OUT PXENIFACE_FDO fdoData
>      );
> --
> 1.9.4.msysgit.1
> 
> 
> _______________________________________________
> win-pv-devel mailing list
> win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.