[HAL]: Use Bus Handler support for HalSetBusDataByOffset. Please report any problems.
authorSir Richard <sir_richard@svn.reactos.org>
Mon, 7 Jun 2010 20:13:05 +0000 (20:13 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Mon, 7 Jun 2010 20:13:05 +0000 (20:13 +0000)
svn path=/trunk/; revision=47671

reactos/hal/halx86/generic/legacy/bussupp.c

index 0f52c97..1e5037f 100644 (file)
@@ -1354,31 +1354,24 @@ HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType,
                       IN ULONG Offset,
                       IN ULONG Length)
 {
-    BUS_HANDLER BusHandler;
-
-    /* Look as the bus type */
-    if (BusDataType == Cmos)
-    {
-        /* Call CMOS Function */
-        return HalpSetCmosData(0, SlotNumber, Buffer, Length);
-    }
-    else if ((BusDataType == PCIConfiguration) && (HalpPCIConfigInitialized))
-    {
-        /* Setup fake PCI Bus handler */
-        RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
-        BusHandler.BusNumber = BusNumber;
-
-        /* Call PCI function */
-        return HalpSetPCIData(&BusHandler,
-                              &BusHandler,
-                              *(PPCI_SLOT_NUMBER)&SlotNumber,
-                              Buffer,
-                              Offset,
-                              Length);
-    }
-
-    /* Invalid bus */
-    return 0;
+    PBUS_HANDLER Handler;
+    ULONG Status;
+    
+    /* Find the handler */
+    Handler = HaliReferenceHandlerForConfigSpace(BusDataType, BusNumber);
+    if (!Handler) return 0;
+    
+    /* Do the assignment */
+    Status = Handler->SetBusData(Handler,
+                                 Handler,
+                                 SlotNumber,
+                                 Buffer,
+                                 Offset,
+                                 Length);
+    
+    /* Dereference the handler and return */
+    HalDereferenceBusHandler(Handler);
+    return Status;
 }
 
 /*