[bus,driver] Move WvBusGetDevCapabilities as WvDriverGetDevCapabilities
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Wed, 29 Dec 2010 04:51:26 +0000 (23:51 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Wed, 29 Dec 2010 04:51:26 +0000 (23:51 -0500)
There is nothing really bus-specific about the function.

src/include/bus.h
src/include/driver.h
src/winvblock/bus/bus.c
src/winvblock/bus/pnp.c
src/winvblock/disk/pnp.c
src/winvblock/driver.c

index fa92f1a..e6cce84 100644 (file)
@@ -70,10 +70,6 @@ typedef struct WV_BUS_NODE {
   } WV_S_BUS_NODE, * WV_SP_BUS_NODE;
 
 /* Exports. */
-extern NTSTATUS STDCALL WvBusGetDevCapabilities(
-    IN PDEVICE_OBJECT,
-    IN PDEVICE_CAPABILITIES
-  );
 extern winvblock__lib_func void WvBusInit(WV_SP_BUS_T);
 extern winvblock__lib_func WV_SP_BUS_T WvBusCreate(void);
 extern winvblock__lib_func WV_SP_BUS_T WvBusFromDev(WV_SP_DEV_T);
index 09ffd3f..22ae8ef 100644 (file)
@@ -70,5 +70,9 @@ extern winvblock__lib_func NTSTATUS STDCALL driver__complete_irp(
 extern winvblock__lib_func winvblock__bool STDCALL WvDriverBusAddDev(
     IN WV_SP_DEV_T
   );
+extern NTSTATUS STDCALL WvDriverGetDevCapabilities(
+    IN PDEVICE_OBJECT,
+    IN PDEVICE_CAPABILITIES
+  );
 
 #endif /* WV_M_DRIVER_H_ */
index 41c2dc3..912b628 100644 (file)
@@ -90,60 +90,6 @@ winvblock__lib_func NTSTATUS STDCALL WvBusPower(
     return driver__complete_irp(Irp, 0, STATUS_SUCCESS);
   }
 
-NTSTATUS STDCALL WvBusGetDevCapabilities(
-    IN PDEVICE_OBJECT DevObj,
-    IN PDEVICE_CAPABILITIES DevCapabilities
-  ) {
-    IO_STATUS_BLOCK io_status;
-    KEVENT pnp_event;
-    NTSTATUS status;
-    PDEVICE_OBJECT target_obj;
-    PIO_STACK_LOCATION io_stack_loc;
-    PIRP pnp_irp;
-
-    RtlZeroMemory(DevCapabilities, sizeof *DevCapabilities);
-    DevCapabilities->Size = sizeof *DevCapabilities;
-    DevCapabilities->Version = 1;
-    DevCapabilities->Address = -1;
-    DevCapabilities->UINumber = -1;
-
-    KeInitializeEvent(&pnp_event, NotificationEvent, FALSE);
-    target_obj = IoGetAttachedDeviceReference(DevObj);
-    pnp_irp = IoBuildSynchronousFsdRequest(
-        IRP_MJ_PNP,
-        target_obj,
-        NULL,
-        0,
-        NULL,
-        &pnp_event,
-        &io_status
-      );
-    if (pnp_irp == NULL) {
-        status = STATUS_INSUFFICIENT_RESOURCES;
-      } else {
-        pnp_irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
-        io_stack_loc = IoGetNextIrpStackLocation(pnp_irp);
-        RtlZeroMemory(io_stack_loc, sizeof *io_stack_loc);
-        io_stack_loc->MajorFunction = IRP_MJ_PNP;
-        io_stack_loc->MinorFunction = IRP_MN_QUERY_CAPABILITIES;
-        io_stack_loc->Parameters.DeviceCapabilities.Capabilities =
-          DevCapabilities;
-        status = IoCallDriver(target_obj, pnp_irp);
-        if (status == STATUS_PENDING) {
-            KeWaitForSingleObject(
-                &pnp_event,
-                Executive,
-                KernelMode,
-                FALSE,
-                NULL
-              );
-            status = io_status.Status;
-          }
-      }
-    ObDereferenceObject(target_obj);
-    return status;
-  }
-
 /* Initialize a bus. */
 static winvblock__bool STDCALL WvBusDevInit_(IN WV_SP_DEV_T dev) {
     return TRUE;
index 32bb8d3..ac382f3 100644 (file)
@@ -253,7 +253,7 @@ static NTSTATUS STDCALL WvBusPnpQueryCapabilities_(
         return IoCallDriver(lower, irp);
       }
     /* Otherwise, return our parent's capabilities. */
-    status = WvBusGetDevCapabilities(
+    status = WvDriverGetDevCapabilities(
         dev->Parent,
         DeviceCapabilities
       );
index 8938cfa..a7ae817 100644 (file)
@@ -218,12 +218,12 @@ static NTSTATUS STDCALL disk_pnp__query_capabilities_(
     bus = WvBusFromDev(WvDevFromDevObj(dev->Parent));
     bus_lower = bus->LowerDeviceObject;
     if (bus_lower) {
-        status = WvBusGetDevCapabilities(
+        status = WvDriverGetDevCapabilities(
             bus_lower,
             &ParentDeviceCapabilities
           );
       } else {
-        status = WvBusGetDevCapabilities(
+        status = WvDriverGetDevCapabilities(
             bus->Dev.Self,
             &ParentDeviceCapabilities
           );
index c7ebf58..24c6781 100644 (file)
@@ -711,3 +711,57 @@ NTSTATUS STDCALL WvDriverBusDevCtl_(
     IoCompleteRequest(irp, IO_NO_INCREMENT);
     return status;
   }
+
+NTSTATUS STDCALL WvDriverGetDevCapabilities(
+    IN PDEVICE_OBJECT DevObj,
+    IN PDEVICE_CAPABILITIES DevCapabilities
+  ) {
+    IO_STATUS_BLOCK io_status;
+    KEVENT pnp_event;
+    NTSTATUS status;
+    PDEVICE_OBJECT target_obj;
+    PIO_STACK_LOCATION io_stack_loc;
+    PIRP pnp_irp;
+
+    RtlZeroMemory(DevCapabilities, sizeof *DevCapabilities);
+    DevCapabilities->Size = sizeof *DevCapabilities;
+    DevCapabilities->Version = 1;
+    DevCapabilities->Address = -1;
+    DevCapabilities->UINumber = -1;
+
+    KeInitializeEvent(&pnp_event, NotificationEvent, FALSE);
+    target_obj = IoGetAttachedDeviceReference(DevObj);
+    pnp_irp = IoBuildSynchronousFsdRequest(
+        IRP_MJ_PNP,
+        target_obj,
+        NULL,
+        0,
+        NULL,
+        &pnp_event,
+        &io_status
+      );
+    if (pnp_irp == NULL) {
+        status = STATUS_INSUFFICIENT_RESOURCES;
+      } else {
+        pnp_irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+        io_stack_loc = IoGetNextIrpStackLocation(pnp_irp);
+        RtlZeroMemory(io_stack_loc, sizeof *io_stack_loc);
+        io_stack_loc->MajorFunction = IRP_MJ_PNP;
+        io_stack_loc->MinorFunction = IRP_MN_QUERY_CAPABILITIES;
+        io_stack_loc->Parameters.DeviceCapabilities.Capabilities =
+          DevCapabilities;
+        status = IoCallDriver(target_obj, pnp_irp);
+        if (status == STATUS_PENDING) {
+            KeWaitForSingleObject(
+                &pnp_event,
+                Executive,
+                KernelMode,
+                FALSE,
+                NULL
+              );
+            status = io_status.Status;
+          }
+      }
+    ObDereferenceObject(target_obj);
+    return status;
+  }