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

[win-pv-devel] [PATCH 1/9] Move __FdoNotifyInstaller to DriverNotifyInstaller



__FdoNotifyInstaller does not use the Fdo, so refactoring allows the removal
of extern from DriverStatusKey 

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/driver.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++------
 src/xenvbd/driver.h |  8 +++++---
 src/xenvbd/fdo.c    | 51 ++-----------------------------------------------
 3 files changed, 56 insertions(+), 58 deletions(-)

diff --git a/src/xenvbd/driver.c b/src/xenvbd/driver.c
index 2fcb2d1..eb17475 100644
--- a/src/xenvbd/driver.c
+++ b/src/xenvbd/driver.c
@@ -322,9 +322,52 @@ done:
     return Status;
 }
 
-//=============================================================================
-// Global Functions
-#define FORMAT_POOL_TAG     'tmFX'
+VOID
+DriverNotifyInstaller(
+    VOID
+    )
+{
+    UNICODE_STRING                  Unicode;
+    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
+    NTSTATUS                        status;
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    Partial = __AllocateNonPagedPoolWithTag(__FUNCTION__,
+                                            __LINE__,
+                                            
FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
+                                            sizeof (ULONG),
+                                            XENVBD_POOL_TAG);
+    status = STATUS_NO_MEMORY;
+    if (Partial == NULL)
+        goto fail1;
+
+    Partial->TitleIndex = 0;
+    Partial->Type = REG_DWORD;
+    Partial->DataLength = sizeof (ULONG);
+    *(PULONG)Partial->Data = 1;
+
+    RtlInitUnicodeString(&Unicode, L"NeedReboot");
+
+    status = ZwSetValueKey(DriverStatusKey,
+                           &Unicode,
+                           Partial->TitleIndex,
+                           Partial->Type,
+                           Partial->Data,
+                           Partial->DataLength);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    __FreePoolWithTag(Partial, XENVBD_POOL_TAG);
+
+    return;
+
+fail2:
+    Error("fail2\n");
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+}
 
 __checkReturn
 __drv_allocatesMem(mem)
@@ -340,7 +383,7 @@ __DriverFormatV(
     ULONG       Size = 32;
 
     for (;;) {
-        Str = (PCHAR)__AllocateNonPagedPoolWithTag(__FUNCTION__, __LINE__, 
Size, FORMAT_POOL_TAG);
+        Str = (PCHAR)__AllocateNonPagedPoolWithTag(__FUNCTION__, __LINE__, 
Size, XENVBD_POOL_TAG);
         if (!Str) {
             return NULL;
         }
@@ -352,7 +395,7 @@ __DriverFormatV(
             return Str;
         } 
         
-        __FreePoolWithTag(Str, FORMAT_POOL_TAG);
+        __FreePoolWithTag(Str, XENVBD_POOL_TAG);
         if (Status == STATUS_BUFFER_OVERFLOW) {
             Size *= 2;
         } else {
@@ -385,7 +428,7 @@ DriverFormatFree(
     )
 {
     if (Buffer)
-        __FreePoolWithTag(Buffer, FORMAT_POOL_TAG);
+        __FreePoolWithTag(Buffer, XENVBD_POOL_TAG);
 }
 
 //=============================================================================
diff --git a/src/xenvbd/driver.h b/src/xenvbd/driver.h
index 560dd4e..79260cd 100644
--- a/src/xenvbd/driver.h
+++ b/src/xenvbd/driver.h
@@ -57,8 +57,6 @@ typedef struct _XENVBD_PARAMETERS {
 
 extern XENVBD_PARAMETERS    DriverParameters;
 
-extern HANDLE               DriverStatusKey;
-
 extern NTSTATUS
 DriverDispatchPnp(
     IN  PDEVICE_OBJECT  DeviceObject,
@@ -82,7 +80,11 @@ DriverUnlinkFdo(
     __in PXENVBD_FDO             Fdo
     );
 
-// Global Functions
+extern VOID
+DriverNotifyInstaller(
+    VOID
+    );
+
 __checkReturn
 __drv_allocatesMem(mem)
 extern PCHAR
diff --git a/src/xenvbd/fdo.c b/src/xenvbd/fdo.c
index cf05483..406e49c 100644
--- a/src/xenvbd/fdo.c
+++ b/src/xenvbd/fdo.c
@@ -555,54 +555,7 @@ __FdoIsPdoUnplugged(
         return TRUE;
     }
 }
-static VOID
-__FdoNotifyInstaller(
-    __in PXENVBD_FDO                Fdo
-    )
-{
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    NTSTATUS                        status;
-
-    UNREFERENCED_PARAMETER(Fdo);
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    Partial = __AllocateNonPagedPoolWithTag(__FUNCTION__,
-                                            __LINE__,
-                                            
FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
-                                            sizeof (ULONG),
-                                            FDO_SIGNATURE);
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail1;
-
-    Partial->TitleIndex = 0;
-    Partial->Type = REG_DWORD;
-    Partial->DataLength = sizeof (ULONG);
-    *(PULONG)Partial->Data = 1;            
-
-    RtlInitUnicodeString(&Unicode, L"NeedReboot");
 
-    status = ZwSetValueKey(DriverStatusKey,
-                           &Unicode,
-                           Partial->TitleIndex,
-                           Partial->Type,
-                           Partial->Data,
-                           Partial->DataLength);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    __FreePoolWithTag(Partial, FDO_SIGNATURE);
-
-    return;
-
-fail2:
-    Error("fail2\n");
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-}
 static FORCEINLINE VOID
 __FdoEnumerate(
     __in    PXENVBD_FDO Fdo,
@@ -761,7 +714,7 @@ FdoScan(
         }
 
         if (NeedReboot)
-            __FdoNotifyInstaller(Fdo);
+            DriverNotifyInstaller();
     }
 
     return STATUS_SUCCESS;
@@ -2010,7 +1963,7 @@ FdoDispatchPnp(
                 FdoLogTargets("QUERY_RELATIONS", Fdo);
 
             if (NeedReboot)
-                __FdoNotifyInstaller(Fdo);
+                DriverNotifyInstaller();
         }
         FdoDereference(Fdo);
         break;
-- 
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

 


Rackspace

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