X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fhal%2Fhalx86%2Fgeneric%2Flegacy%2Fbus%2Fbushndlr.c;h=2ab551c610ea6595ff33a4cc45030c360e5a33e3;hp=7cb3a205ceafe343afb57711fe526830408aed38;hb=90d92560f434a907c0364686a6891a3b14ec30dc;hpb=e2d5c9d92bf15a93c4d437ec202e3f51251b1bb7;ds=inline diff --git a/reactos/hal/halx86/generic/legacy/bus/bushndlr.c b/reactos/hal/halx86/generic/legacy/bus/bushndlr.c index 7cb3a205cea..2ab551c610e 100644 --- a/reactos/hal/halx86/generic/legacy/bus/bushndlr.c +++ b/reactos/hal/halx86/generic/legacy/bus/bushndlr.c @@ -201,6 +201,41 @@ HaliReferenceHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, TRUE); } +PBUS_HANDLER +NTAPI +HalpContextToBusHandler(IN ULONG_PTR ContextValue) +{ + PLIST_ENTRY NextEntry; + PHAL_BUS_HANDLER BusHandler, ThisHandler; + + /* Start lookup */ + NextEntry = HalpAllBusHandlers.Flink; + ThisHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers); + if (ContextValue) + { + /* If the list is empty, quit */ + if (IsListEmpty(&HalpAllBusHandlers)) return NULL; + + /* Otherwise, scan the list */ + BusHandler = CONTAINING_RECORD(ContextValue, HAL_BUS_HANDLER, Handler); + do + { + /* Check if we've reached the right one */ + ThisHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers); + if (ThisHandler == BusHandler) break; + + /* Try the next one */ + NextEntry = NextEntry->Flink; + } while (NextEntry != &HalpAllBusHandlers); + } + + /* If we looped back to the end, we didn't find anything */ + if (NextEntry == &HalpAllBusHandlers) return NULL; + + /* Otherwise return the handler */ + return &ThisHandler->Handler; +} + #ifndef _MINIHAL_ NTSTATUS NTAPI @@ -262,7 +297,7 @@ HaliRegisterBusHandler(IN INTERFACE_TYPE InterfaceType, ConfigBusNumberArray = HalpAllocateArray(BusNumber); /* Only proceed if all allocations succeeded */ - if (InterfaceArray && InterfaceBusNumberArray && ConfigArray && ConfigBusNumberArray) + if ((InterfaceArray) && (InterfaceBusNumberArray) && (ConfigArray) && (ConfigBusNumberArray)) { /* Find the parent handler if any */ ParentHandler = HaliReferenceHandlerForBus(ParentBusType, ParentBusNumber); @@ -407,15 +442,8 @@ HalpInitBusHandler(VOID) HalDereferenceBusHandler = HaliDereferenceBusHandler; #endif HalPciAssignSlotResources = HalpAssignSlotResources; - /* FIXME: Fix later */ -#if 0 - HalPciTranslateBusAddress = HaliTranslateBusAddress; + HalPciTranslateBusAddress = HaliTranslateBusAddress; /* PCI Driver can override */ if (!HalFindBusAddressTranslation) HalFindBusAddressTranslation = HaliFindBusAddressTranslation; -#else - /* These should be written by the PCI driver later, but we give defaults */ - HalPciTranslateBusAddress = HalpTranslateBusAddress; - HalFindBusAddressTranslation = HalpFindBusAddressTranslation; -#endif } /* EOF */