[bus,driver] Put bus IRP_MJ_PNP handler in driver
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Thu, 23 Dec 2010 20:18:17 +0000 (15:18 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Thu, 23 Dec 2010 20:18:17 +0000 (15:18 -0500)
src/include/bus.h
src/winvblock/bus/bus.c
src/winvblock/bus/pnp.c
src/winvblock/driver.c

index 901be5d..e978a6f 100644 (file)
@@ -102,5 +102,11 @@ extern winvblock__lib_func NTSTATUS STDCALL WvBusPower(
     IN WV_SP_BUS_T,
     IN PIRP
   );
+/* IRP_MJ_PNP dispatcher in bus/pnp.c */
+extern winvblock__lib_func NTSTATUS STDCALL WvBusPnp(
+    IN WV_SP_BUS_T,
+    IN PIRP,
+    IN UCHAR
+  );
 
 #endif  /* WV_M_BUS_H_ */
index a16552f..ca86bdf 100644 (file)
@@ -37,8 +37,6 @@
 
 /* IRP_MJ_DEVICE_CONTROL dispatcher from bus/dev_ctl.c */
 extern WV_F_DEV_CTL WvBusDevCtlDispatch;
-/* IRP_MJ_PNP dispatcher from bus/pnp.c */
-extern WV_F_DEV_PNP WvBusPnpDispatch;
 
 /* Types. */
 typedef enum WV_BUS_WORK_ITEM_CMD_ {
@@ -73,7 +71,7 @@ WV_S_DEV_IRP_MJ WvBusIrpMj_ = {
     (WV_FP_DEV_DISPATCH) 0,
     WvBusDevCtlDispatch,
     (WV_FP_DEV_SCSI) 0,
-    WvBusPnpDispatch,
+    (WV_FP_DEV_PNP) 0,
   };
 
 /**
index 0b2994c..7fe8217 100644 (file)
@@ -47,7 +47,6 @@ static WV_F_DEV_DISPATCH WvBusPnpQueryCapabilities_;
 static WV_F_DEV_DISPATCH WvBusPnpQueryDevText_;
 static WV_F_DEV_DISPATCH WvBusPnpQueryBusInfo_;
 static WV_F_DEV_PNP WvBusPnpSimple_;
-WV_F_DEV_PNP WvBusPnpDispatch;
 
 static NTSTATUS STDCALL WvBusPnpIoCompletion_(
     IN PDEVICE_OBJECT dev_obj,
@@ -415,11 +414,13 @@ static NTSTATUS STDCALL WvBusPnpSimple_(
   }
 
 /* Bus PnP dispatch routine. */
-NTSTATUS STDCALL WvBusPnpDispatch(
-    IN WV_SP_DEV_T dev,
+winvblock__lib_func NTSTATUS STDCALL WvBusPnp(
+    IN WV_SP_BUS_T bus,
     IN PIRP irp,
     IN UCHAR code
   ) {
+    WV_SP_DEV_T dev = &bus->Dev;
+
     switch (code) {
         case IRP_MN_QUERY_ID:
           DBG("bus_pnp: IRP_MN_QUERY_ID\n");
index d8b9b4c..71e49ee 100644 (file)
@@ -81,6 +81,7 @@ static driver__dispatch_func driver__dispatch_pnp_;
 static void STDCALL driver__unload_(IN PDRIVER_OBJECT);
 static WV_F_DEV_DISPATCH WvDriverBusSysCtl_;
 static WV_F_DEV_DISPATCH WvDriverBusPower_;
+static WV_F_DEV_PNP WvDriverBusPnp_;
 
 static LPWSTR STDCALL get_opt(IN LPWSTR opt_name) {
     LPWSTR our_opts, the_opt;
@@ -185,6 +186,7 @@ static NTSTATUS STDCALL driver__attach_fdo_(
     WvDriverBus_.Dev.IsBus = TRUE;
     WvDriverBus_.Dev.IrpMj->SysCtl = WvDriverBusSysCtl_;
     WvDriverBus_.Dev.IrpMj->Power = WvDriverBusPower_;
+    WvDriverBus_.Dev.IrpMj->Pnp = WvDriverBusPnp_;
     WvDriverBus_.PhysicalDeviceObject = PhysicalDeviceObject;
     fdo->Flags |= DO_DIRECT_IO;         /* FIXME? */
     fdo->Flags |= DO_POWER_INRUSH;      /* FIXME? */
@@ -581,3 +583,15 @@ static NTSTATUS STDCALL WvDriverBusPower_(IN WV_SP_DEV_T dev, IN PIRP irp) {
 
     return WvBusPower(bus, irp);
   }
+
+/* Pass an IRP_MJ_PNP to the bus. */
+static NTSTATUS STDCALL WvDriverBusPnp_(
+    IN WV_SP_DEV_T dev,
+    IN PIRP irp,
+    IN UCHAR code
+  ) {
+    WV_SP_BUS_T bus = WvBusFromDev(dev);
+
+    return WvBusPnp(bus, irp, code);
+  }
+