From 28bde112e1d2de1ca192ee2a5945eeda34dc3b1f Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 7 Jun 2010 21:01:53 +0000 Subject: [PATCH] [HAL]: Implement HalTranslateBusAddress using Bus Handler support. The old HAL would just return whatever the caller gave (no translation was done). For example, with the new HAL, this now results in the translation of 0xCF800 in I/O space to fail (not sure which driver requests this), because this is not a valid I/O address on PC/AT systems (highest is 0xFFFF). 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 --- .../hal/halx86/generic/legacy/bus/bushndlr.c | 3 +- reactos/hal/halx86/generic/legacy/bussupp.c | 40 +++++++++++++++++-- reactos/hal/halx86/include/bus.h | 2 +- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/reactos/hal/halx86/generic/legacy/bus/bushndlr.c b/reactos/hal/halx86/generic/legacy/bus/bushndlr.c index a3a23903055..0e5774be6d2 100644 --- a/reactos/hal/halx86/generic/legacy/bus/bushndlr.c +++ b/reactos/hal/halx86/generic/legacy/bus/bushndlr.c @@ -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 } diff --git a/reactos/hal/halx86/generic/legacy/bussupp.c b/reactos/hal/halx86/generic/legacy/bussupp.c index af882214cae..1118def18bc 100644 --- a/reactos/hal/halx86/generic/legacy/bussupp.c +++ b/reactos/hal/halx86/generic/legacy/bussupp.c @@ -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); } } diff --git a/reactos/hal/halx86/include/bus.h b/reactos/hal/halx86/include/bus.h index b0ffded5425..91fa6bb8194 100644 --- a/reactos/hal/halx86/include/bus.h +++ b/reactos/hal/halx86/include/bus.h @@ -368,7 +368,7 @@ HalpInitializePciStubs( BOOLEAN NTAPI -HalpTranslateBusAddress( +HaliTranslateBusAddress( IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress,