X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fhal%2Fhalx86%2Fgeneric%2Flegacy%2Fbussupp.c;h=6faa60fb765948816da7b84b5a21cc048c1a8b4f;hp=a6978604a5843e4a837c40ac2aa5fe4c88a858d1;hb=90d92560f434a907c0364686a6891a3b14ec30dc;hpb=a37a4a9e073af8cd0210ae2011662a4cda33ec86 diff --git a/reactos/hal/halx86/generic/legacy/bussupp.c b/reactos/hal/halx86/generic/legacy/bussupp.c index a6978604a58..6faa60fb765 100644 --- a/reactos/hal/halx86/generic/legacy/bussupp.c +++ b/reactos/hal/halx86/generic/legacy/bussupp.c @@ -1152,50 +1152,75 @@ HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath, BOOLEAN NTAPI -HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress) -{ - /* Translation is easy */ - TranslatedAddress->QuadPart = BusAddress.QuadPart; - return TRUE; -} - -ULONG -NTAPI -HalpGetSystemInterruptVector_Acpi(IN ULONG BusNumber, - IN ULONG BusInterruptLevel, - IN ULONG BusInterruptVector, - OUT PKIRQL Irql, - OUT PKAFFINITY Affinity) -{ - ULONG Vector = IRQ2VECTOR(BusInterruptLevel); - *Irql = (KIRQL)VECTOR2IRQL(Vector); - *Affinity = 0xFFFFFFFF; - return Vector; -} - -BOOLEAN -NTAPI -HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, +HaliFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus) { + PHAL_BUS_HANDLER BusHandler; + PBUS_HANDLER Handler; + PLIST_ENTRY NextEntry; + ULONG ContextValue; + /* Make sure we have a context */ if (!Context) return FALSE; - - /* If we have data in the context, then this shouldn't be a new lookup */ - if ((*Context) && (NextBus == TRUE)) return FALSE; - - /* Return bus data */ - TranslatedAddress->QuadPart = BusAddress.QuadPart; - - /* Set context value and return success */ - *Context = 1; + ASSERT((*Context) || (NextBus == TRUE)); + + /* Read the context */ + ContextValue = *Context; + + /* Find the bus handler */ + Handler = HalpContextToBusHandler(ContextValue); + if (!Handler) return FALSE; + + /* Check if this is an ongoing lookup */ + if (NextBus) + { + /* Get the HAL bus handler */ + BusHandler = CONTAINING_RECORD(Handler, HAL_BUS_HANDLER, Handler); + NextEntry = &BusHandler->AllHandlers; + + /* Get the next one if we were already with one */ + if (ContextValue) NextEntry = NextEntry->Flink; + + /* Start scanning */ + while (TRUE) + { + /* Check if this is the last one */ + if (NextEntry == &HalpAllBusHandlers) + { + /* Quit */ + *Context = 1; + return FALSE; + } + + /* Call this translator */ + BusHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers); + if (HalTranslateBusAddress(BusHandler->Handler.InterfaceType, + BusHandler->Handler.BusNumber, + BusAddress, + AddressSpace, + TranslatedAddress)) break; + + /* Try the next one */ + NextEntry = NextEntry->Flink; + } + + /* If we made it, we're done */ + *Context = (ULONG_PTR)Handler; + return TRUE; + } + + /* Try the first one through */ + if (!HalTranslateBusAddress(Handler->InterfaceType, + Handler->BusNumber, + BusAddress, + AddressSpace, + TranslatedAddress)) return FALSE; + + /* Remember for next time */ + *Context = (ULONG_PTR)Handler; return TRUE; }