Add config interface start (PciReadWriteConfigSpace, PciReadSlotConfig)
[reactos.git] / reactos / drivers / bus / pcix / pci / config.c
index f48c187..e86d73b 100644 (file)
@@ -18,6 +18,61 @@ BOOLEAN PciAssignBusNumbers;
 
 /* FUNCTIONS ******************************************************************/
 
+VOID
+NTAPI
+PciReadWriteConfigSpace(IN PPCI_FDO_EXTENSION DeviceExtension,
+                        IN PCI_SLOT_NUMBER Slot,
+                        IN PVOID Buffer,
+                        IN ULONG Offset,
+                        IN ULONG Length,
+                        IN BOOLEAN Read)
+{
+    PPCI_BUS_INTERFACE_STANDARD PciInterface;
+    PBUS_HANDLER BusHandler;
+    PPCIBUSDATA BusData;
+    PciReadWriteConfig HalFunction;
+
+    /* Only the root FDO can access configuration space */
+    ASSERT(PCI_IS_ROOT_FDO(DeviceExtension->BusRootFdoExtension));
+
+    /* Get the ACPI-compliant PCI interface */
+    PciInterface = DeviceExtension->BusRootFdoExtension->PciBusInterface;
+    if (PciInterface)
+    {
+        /* Currently this driver only supports the legacy HAL interface */
+        UNIMPLEMENTED;
+        while (TRUE);
+    }
+    else
+    {
+        /* Make sure there's a registered HAL bus handler */
+        ASSERT(DeviceExtension->BusHandler);
+
+        /* PCI Bus Number assignment is only valid on ACPI systems */
+        ASSERT(!PciAssignBusNumbers);
+
+        /* Grab the HAL PCI Bus Handler data */
+        BusHandler = (PBUS_HANDLER)DeviceExtension->BusHandler;
+        BusData = (PPCIBUSDATA)BusHandler->BusData;
+
+        /* Choose the appropriate read or write function, and call it */
+        HalFunction = Read ? BusData->ReadConfig : BusData->WriteConfig;
+        HalFunction(BusHandler, Slot, Buffer, Offset, Length);
+    }
+}
+
+VOID
+NTAPI
+PciReadSlotConfig(IN PPCI_FDO_EXTENSION DeviceExtension,
+                  IN PCI_SLOT_NUMBER Slot,
+                  IN PVOID Buffer,
+                  IN ULONG Offset,
+                  IN ULONG Length)
+{
+    /* Call the generic worker function */
+    PciReadWriteConfigSpace(DeviceExtension, Slot, Buffer, Offset, Length, TRUE);
+}
+
 NTSTATUS
 NTAPI
 PciQueryForPciBusInterface(IN PPCI_FDO_EXTENSION FdoExtension)