https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e19595572aa04724ee00788bb76a0328d2586700

commit e19595572aa04724ee00788bb76a0328d2586700
Author:     Dmitry Borisov <[email protected]>
AuthorDate: Thu Mar 4 18:47:34 2021 +0600
Commit:     Dmitry Borisov <[email protected]>
CommitDate: Sun Jun 20 19:24:25 2021 +0600

    [ISAPNP] Implement querying bus information
---
 drivers/bus/isapnp/isapnp.c |  2 ++
 drivers/bus/isapnp/isapnp.h |  4 ++++
 drivers/bus/isapnp/pdo.c    | 30 +++++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/isapnp/isapnp.c b/drivers/bus/isapnp/isapnp.c
index daa53f64758..c477fecf767 100644
--- a/drivers/bus/isapnp/isapnp.c
+++ b/drivers/bus/isapnp/isapnp.c
@@ -683,6 +683,7 @@ IsaAddDevice(
     PDEVICE_OBJECT Fdo;
     PISAPNP_FDO_EXTENSION FdoExt;
     NTSTATUS Status;
+    static ULONG BusNumber = 0;
 
     PAGED_CODE();
 
@@ -708,6 +709,7 @@ IsaAddDevice(
     FdoExt->Common.IsFdo = TRUE;
     FdoExt->Common.State = dsStopped;
     FdoExt->DriverObject = DriverObject;
+    FdoExt->BusNumber = BusNumber++;
     FdoExt->Pdo = PhysicalDeviceObject;
     FdoExt->Ldo = IoAttachDeviceToDeviceStack(Fdo,
                                               PhysicalDeviceObject);
diff --git a/drivers/bus/isapnp/isapnp.h b/drivers/bus/isapnp/isapnp.h
index d22037bbb90..4eb7fb4e19b 100644
--- a/drivers/bus/isapnp/isapnp.h
+++ b/drivers/bus/isapnp/isapnp.h
@@ -14,6 +14,9 @@
 #include <section_attribs.h>
 #include "isapnphw.h"
 
+#include <initguid.h>
+#include <wdmguid.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -73,6 +76,7 @@ typedef struct _ISAPNP_FDO_EXTENSION
     PDEVICE_OBJECT Ldo;
     PDEVICE_OBJECT Pdo;
     PDEVICE_OBJECT ReadPortPdo;
+    ULONG BusNumber;
     KEVENT DeviceSyncEvent;
     LIST_ENTRY DeviceListHead;
     ULONG DeviceCount;
diff --git a/drivers/bus/isapnp/pdo.c b/drivers/bus/isapnp/pdo.c
index 1227f7cf22b..1fae349f9e0 100644
--- a/drivers/bus/isapnp/pdo.c
+++ b/drivers/bus/isapnp/pdo.c
@@ -483,6 +483,31 @@ IsaPdoRepeatRequest(
     return STATUS_PENDING;
 }
 
+static
+CODE_SEG("PAGE")
+NTSTATUS
+IsaPdoQueryBusInformation(
+    _In_ PISAPNP_PDO_EXTENSION PdoExt,
+    _Inout_ PIRP Irp)
+{
+    PPNP_BUS_INFORMATION BusInformation;
+
+    PAGED_CODE();
+
+    BusInformation = ExAllocatePoolWithTag(PagedPool,
+                                           sizeof(PNP_BUS_INFORMATION),
+                                           TAG_ISAPNP);
+    if (!BusInformation)
+        return STATUS_INSUFFICIENT_RESOURCES;
+
+    BusInformation->BusTypeGuid = GUID_BUS_TYPE_ISAPNP;
+    BusInformation->LegacyBusType = Isa;
+    BusInformation->BusNumber = PdoExt->FdoExt->BusNumber;
+
+    Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
+    return STATUS_SUCCESS;
+}
+
 CODE_SEG("PAGE")
 NTSTATUS
 IsaPdoPnp(
@@ -544,6 +569,10 @@ IsaPdoPnp(
                 Status = IsaReadPortQueryId(Irp, IrpSp);
             break;
 
+        case IRP_MN_QUERY_BUS_INFORMATION:
+            Status = IsaPdoQueryBusInformation(PdoExt, Irp);
+            break;
+
         case IRP_MN_QUERY_REMOVE_DEVICE:
         case IRP_MN_REMOVE_DEVICE:
         case IRP_MN_CANCEL_REMOVE_DEVICE:
@@ -559,7 +588,6 @@ IsaPdoPnp(
         case IRP_MN_WRITE_CONFIG:
         case IRP_MN_EJECT:
         case IRP_MN_SET_LOCK:
-        case IRP_MN_QUERY_BUS_INFORMATION:
         case IRP_MN_DEVICE_USAGE_NOTIFICATION:
             return IsaPdoRepeatRequest(PdoExt, Irp, TRUE);
 

Reply via email to