[HAL]: Implement HalTranslateBusAddress using Bus Handler support. The old HAL would...
authorSir Richard <sir_richard@svn.reactos.org>
Mon, 7 Jun 2010 21:01:53 +0000 (21:01 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Mon, 7 Jun 2010 21:01:53 +0000 (21:01 +0000)
       This change also allows for the PCI driver to override the translation mechanism (which will piggy-back to the system bus translator) with its own. Please test.

svn path=/trunk/; revision=47679

reactos/hal/halx86/generic/legacy/bus/bushndlr.c
reactos/hal/halx86/generic/legacy/bussupp.c
reactos/hal/halx86/include/bus.h

index a3a2390..0e5774b 100644 (file)
@@ -407,13 +407,12 @@ HalpInitBusHandler(VOID)
     HalDereferenceBusHandler = HaliDereferenceBusHandler;
 #endif
     HalPciAssignSlotResources = HalpAssignSlotResources;
+    HalPciTranslateBusAddress = HaliTranslateBusAddress; /* PCI Driver can override */
     /* FIXME: Fix later */
 #if 0
-    HalPciTranslateBusAddress = HaliTranslateBusAddress;
     if (!HalFindBusAddressTranslation) HalFindBusAddressTranslation = HaliFindBusAddressTranslation;
 #else
     /* These should be written by the PCI driver later, but we give defaults */
-    HalPciTranslateBusAddress = HalpTranslateBusAddress;
     HalFindBusAddressTranslation = HalpFindBusAddressTranslation;
 #endif
 }
index af88221..1118def 100644 (file)
@@ -1196,6 +1196,37 @@ HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress,
     return TRUE;
 }
 
+BOOLEAN
+NTAPI
+HaliTranslateBusAddress(IN INTERFACE_TYPE InterfaceType,
+                        IN ULONG BusNumber,
+                        IN PHYSICAL_ADDRESS BusAddress,
+                        IN OUT PULONG AddressSpace,
+                        OUT PPHYSICAL_ADDRESS TranslatedAddress)
+{
+    PBUS_HANDLER Handler;
+    BOOLEAN Status;
+    
+    /* Find the handler */
+    Handler = HalReferenceHandlerForBus(InterfaceType, BusNumber);
+    if (!(Handler) || !(Handler->TranslateBusAddress))
+    {
+        DPRINT1("No translator!\n");
+        return FALSE;
+    }
+    
+    /* Do the assignment */
+    Status = Handler->TranslateBusAddress(Handler,
+                                          Handler,
+                                          BusAddress,
+                                          AddressSpace,
+                                          TranslatedAddress);
+    
+    /* Dereference the handler and return */
+    HalDereferenceBusHandler(Handler);
+    return Status;
+}
+
 /* PUBLIC FUNCTIONS **********************************************************/
 
 /*
@@ -1423,9 +1454,12 @@ HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType,
     }
     else
     {
-        /* Translation is easy */
-        TranslatedAddress->QuadPart = BusAddress.QuadPart;
-        return TRUE;
+        /* Call the bus handler */
+        return HaliTranslateBusAddress(InterfaceType,
+                                       BusNumber,
+                                       BusAddress,
+                                       AddressSpace,
+                                       TranslatedAddress);
     }
 }
 
index b0ffded..91fa6bb 100644 (file)
@@ -368,7 +368,7 @@ HalpInitializePciStubs(
 
 BOOLEAN
 NTAPI
-HalpTranslateBusAddress(
+HaliTranslateBusAddress(
     IN INTERFACE_TYPE InterfaceType,
     IN ULONG BusNumber,
     IN PHYSICAL_ADDRESS BusAddress,