diff --git a/reactos/hal/halx86/generic/bus/halbus.c b/reactos/hal/halx86/generic/acpi/busemul.c similarity index 91% rename from reactos/hal/halx86/generic/bus/halbus.c rename to reactos/hal/halx86/generic/acpi/busemul.c index d8e478f450f..7a317f56728 100644 --- a/reactos/hal/halx86/generic/bus/halbus.c +++ b/reactos/hal/halx86/generic/acpi/busemul.c @@ -1,22 +1,20 @@ /* * PROJECT: ReactOS HAL - * LICENSE: GPL - See COPYING in the top level directory - * FILE: hal/halx86/generic/bus/halbus.c - * PURPOSE: Bus Support Routines - * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: hal/halx86/generic/acpi/busemul.c + * PURPOSE: ACPI HAL Bus Handler Emulation Code + * PROGRAMMERS: ReactOS Portable Systems Group */ -/* INCLUDES ******************************************************************/ +/* INCLUDES *******************************************************************/ #include #define NDEBUG #include -/* GLOBALS *******************************************************************/ +/* GLOBALS ********************************************************************/ -ULONG HalpBusType; - -/* PRIVATE FUNCTIONS *********************************************************/ +/* PRIVATE FUNCTIONS **********************************************************/ VOID NTAPI @@ -83,11 +81,11 @@ HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, ULONG NTAPI -HalpGetSystemInterruptVector(IN ULONG BusNumber, - IN ULONG BusInterruptLevel, - IN ULONG BusInterruptVector, - OUT PKIRQL Irql, - OUT PKAFFINITY Affinity) +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); @@ -250,11 +248,11 @@ HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType, OUT PKAFFINITY Affinity) { /* Call the system bus translator */ - return HalpGetSystemInterruptVector(BusNumber, - BusInterruptLevel, - BusInterruptVector, - Irql, - Affinity); + return HalpGetSystemInterruptVector_Acpi(BusNumber, + BusInterruptLevel, + BusInterruptVector, + Irql, + Affinity); } /* diff --git a/reactos/hal/halx86/generic/acpi/halacpi.c b/reactos/hal/halx86/generic/acpi/halacpi.c index 1efee7996a4..22d3c9b6a72 100644 --- a/reactos/hal/halx86/generic/acpi/halacpi.c +++ b/reactos/hal/halx86/generic/acpi/halacpi.c @@ -879,6 +879,24 @@ HalpInitializePciBus(VOID) HalpGetNMICrashFlag(); } +VOID +NTAPI +HalpInitNonBusHandler(VOID) +{ + /* These should be written by the PCI driver later, but we give defaults */ + HalPciTranslateBusAddress = HalpTranslateBusAddress; + HalPciAssignSlotResources = HalpAssignSlotResources; + HalFindBusAddressTranslation = HalpFindBusAddressTranslation; +} + +VOID +NTAPI +HalpInitBusHandlers(VOID) +{ + /* On ACPI, we only have a fake PCI bus to worry about */ + HalpInitNonBusHandler(); +} + VOID NTAPI HalpBuildAddressMap(VOID) diff --git a/reactos/hal/halx86/generic/bus/bushndlr.c b/reactos/hal/halx86/generic/bus/bushndlr.c deleted file mode 100644 index 18121360a62..00000000000 --- a/reactos/hal/halx86/generic/bus/bushndlr.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * PROJECT: ReactOS HAL - * LICENSE: GPL - See COPYING in the top level directory - * FILE: hal/halx86/generic/bus/bushndlr.c - * PURPOSE: Generic HAL Bus Handler Support - * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) - */ - -/* INCLUDES *******************************************************************/ - -#include -#define NDEBUG -#include - -/* GLOBALS ********************************************************************/ - -KSPIN_LOCK HalpBusDatabaseSpinLock; -KEVENT HalpBusDatabaseEvent; -LIST_ENTRY HalpAllBusHandlers; -PARRAY HalpBusTable; -PARRAY HalpConfigTable; - -/* PRIVATE FUNCTIONS **********************************************************/ - -PARRAY -NTAPI -HalpAllocateArray(IN ULONG ArraySize) -{ - PARRAY Array; - ULONG Size; - - /* Compute array size */ - if (ArraySize == MAXULONG) ArraySize = 0; - Size = ArraySize * sizeof(PARRAY) + sizeof(ARRAY); - - /* Allocate the array */ - Array = ExAllocatePoolWithTag(NonPagedPool, - Size, - 'BusH'); - if (!Array) KeBugCheckEx(HAL_MEMORY_ALLOCATION, Size, 0, (ULONG_PTR)__FILE__, __LINE__); - - /* Initialize it */ - Array->ArraySize = ArraySize; - RtlZeroMemory(Array->Element, sizeof(PVOID) * (ArraySize + 1)); - return Array; -} - -VOID -NTAPI -HalpGrowArray(IN PARRAY *CurrentArray, - IN PARRAY *NewArray) -{ - PVOID Tmp; - - /* Check if the current array doesn't exist yet, or if it's smaller than the new one */ - if (!(*CurrentArray) || ((*NewArray)->ArraySize > (*CurrentArray)->ArraySize)) - { - /* Does it exist (and can it fit?) */ - if (*CurrentArray) - { - /* Copy the current array into the new one */ - RtlCopyMemory(&(*NewArray)->Element, - &(*CurrentArray)->Element, - sizeof(PVOID) * ((*CurrentArray)->ArraySize + 1)); - } - - /* Swap the pointers (XOR swap would be more l33t) */ - Tmp = *CurrentArray; - *CurrentArray = *NewArray; - *NewArray = Tmp; - } -} - -PBUS_HANDLER -FASTCALL -HalpLookupHandler(IN PARRAY Array, - IN ULONG Type, - IN ULONG Number, - IN BOOLEAN AddReference) -{ - PHAL_BUS_HANDLER Bus; - PBUS_HANDLER Handler = NULL; - - /* Make sure the entry exists */ - if (Array->ArraySize >= Type) - { - /* Retrieve it */ - Array = Array->Element[Type]; - - /* Make sure the entry array exists */ - if ((Array) && (Array->ArraySize >= Number)) - { - /* Retrieve the bus and its handler */ - Bus = Array->Element[Number]; - Handler = &Bus->Handler; - - /* Reference the handler if needed */ - if (AddReference) Bus->ReferenceCount++; - } - } - - /* Return the handler */ - return Handler; -} - -VOID -FASTCALL -HaliReferenceBusHandler(IN PBUS_HANDLER Handler) -{ - PHAL_BUS_HANDLER Bus; - - /* Find and reference the bus handler */ - Bus = CONTAINING_RECORD(Handler, HAL_BUS_HANDLER, Handler); - Bus->ReferenceCount++; -} - -VOID -FASTCALL -HaliDereferenceBusHandler(IN PBUS_HANDLER Handler) -{ - PHAL_BUS_HANDLER Bus; - - /* Find and dereference the bus handler */ - Bus = CONTAINING_RECORD(Handler, HAL_BUS_HANDLER, Handler); - Bus->ReferenceCount--; - ASSERT(Bus->ReferenceCount != 0); -} - -PBUS_HANDLER -FASTCALL -HaliHandlerForBus(IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber) -{ - /* Lookup the interface in the bus table */ - return HalpLookupHandler(HalpBusTable, InterfaceType, BusNumber, FALSE); -} - -PBUS_HANDLER -FASTCALL -HaliHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, - IN ULONG BusNumber) -{ - /* Lookup the configuration in the configuration table */ - return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, FALSE); -} - -PBUS_HANDLER -FASTCALL -HaliReferenceHandlerForBus(IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber) -{ - /* Lookup the interface in the bus table, and reference the handler */ - return HalpLookupHandler(HalpBusTable, InterfaceType, BusNumber, TRUE); -} - -PBUS_HANDLER -FASTCALL -HaliReferenceHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, - IN ULONG BusNumber) -{ - /* Lookup the configuration in the configuration table and add a reference */ - return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, TRUE); -} - -VOID -NTAPI -HalpInitBusHandler(VOID) -{ - /* Setup the bus lock */ - KeInitializeSpinLock(&HalpBusDatabaseSpinLock); - - /* Setup the bus event */ - KeInitializeEvent(&HalpBusDatabaseEvent, SynchronizationEvent, TRUE); - - /* Setup the bus configuration and bus table */ - HalpBusTable = HalpAllocateArray(0); - HalpConfigTable = HalpAllocateArray(0); - - /* Setup the bus list */ - InitializeListHead(&HalpAllBusHandlers); - - /* These should be written by the PCI driver later, but we give defaults */ - HalPciTranslateBusAddress = HalpTranslateBusAddress; - HalPciAssignSlotResources = HalpAssignSlotResources; - HalFindBusAddressTranslation = HalpFindBusAddressTranslation; -} diff --git a/reactos/hal/halx86/generic/bus/isabus.c b/reactos/hal/halx86/generic/bus/isabus.c deleted file mode 100644 index 7e9631f6536..00000000000 --- a/reactos/hal/halx86/generic/bus/isabus.c +++ /dev/null @@ -1,7 +0,0 @@ -/* - * PROJECT: ReactOS HAL - * LICENSE: GPL - See COPYING in the top level directory - * FILE: hal/halx86/generic/bus/isabus.c - * PURPOSE: - * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) - */ diff --git a/reactos/hal/halx86/generic/bus/sysbus.c b/reactos/hal/halx86/generic/bus/sysbus.c deleted file mode 100644 index d011cb568c5..00000000000 --- a/reactos/hal/halx86/generic/bus/sysbus.c +++ /dev/null @@ -1,7 +0,0 @@ -/* - * PROJECT: ReactOS HAL - * LICENSE: GPL - See COPYING in the top level directory - * FILE: hal/halx86/generic/bus/sysbus.c - * PURPOSE: - * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) - */ diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 6a6b1660694..f0ebd33d4ca 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -155,7 +155,7 @@ HalInitSystem(IN ULONG BootPhase, else if (BootPhase == 1) { /* Initialize bus handlers */ - HalpInitBusHandler(); + HalpInitBusHandlers(); #ifndef _MINIHAL_ /* Enable IRQ 0 */ diff --git a/reactos/hal/halx86/generic/legacy/bus/bushndlr.c b/reactos/hal/halx86/generic/legacy/bus/bushndlr.c new file mode 100644 index 00000000000..6186d540ff4 --- /dev/null +++ b/reactos/hal/halx86/generic/legacy/bus/bushndlr.c @@ -0,0 +1,424 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/bus/bushndlr.c + * PURPOSE: Generic HAL Bus Handler Support + * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +KSPIN_LOCK HalpBusDatabaseSpinLock; +KEVENT HalpBusDatabaseEvent; +LIST_ENTRY HalpAllBusHandlers; +PARRAY HalpBusTable; +PARRAY HalpConfigTable; + +/* PRIVATE FUNCTIONS **********************************************************/ + +PARRAY +NTAPI +HalpAllocateArray(IN ULONG ArraySize) +{ + PARRAY Array; + ULONG Size; + + /* Compute array size */ + if (ArraySize == MAXULONG) ArraySize = 0; + Size = ArraySize * sizeof(PARRAY) + sizeof(ARRAY); + + /* Allocate the array */ + Array = ExAllocatePoolWithTag(NonPagedPool, + Size, + 'BusH'); + if (!Array) KeBugCheckEx(HAL_MEMORY_ALLOCATION, Size, 0, (ULONG_PTR)__FILE__, __LINE__); + + /* Initialize it */ + Array->ArraySize = ArraySize; + RtlZeroMemory(Array->Element, sizeof(PVOID) * (ArraySize + 1)); + return Array; +} + +VOID +NTAPI +HalpGrowArray(IN PARRAY *CurrentArray, + IN PARRAY *NewArray) +{ + PVOID Tmp; + + /* Check if the current array doesn't exist yet, or if it's smaller than the new one */ + if (!(*CurrentArray) || ((*NewArray)->ArraySize > (*CurrentArray)->ArraySize)) + { + /* Does it exist (and can it fit?) */ + if (*CurrentArray) + { + /* Copy the current array into the new one */ + RtlCopyMemory(&(*NewArray)->Element, + &(*CurrentArray)->Element, + sizeof(PVOID) * ((*CurrentArray)->ArraySize + 1)); + } + + /* Swap the pointers (XOR swap would be more l33t) */ + Tmp = *CurrentArray; + *CurrentArray = *NewArray; + *NewArray = Tmp; + } +} + +PBUS_HANDLER +FASTCALL +HalpLookupHandler(IN PARRAY Array, + IN ULONG Type, + IN ULONG Number, + IN BOOLEAN AddReference) +{ + PHAL_BUS_HANDLER Bus; + PBUS_HANDLER Handler = NULL; + + /* Make sure the entry exists */ + if (Array->ArraySize >= Type) + { + /* Retrieve it */ + Array = Array->Element[Type]; + + /* Make sure the entry array exists */ + if ((Array) && (Array->ArraySize >= Number)) + { + /* Retrieve the bus and its handler */ + Bus = Array->Element[Number]; + Handler = &Bus->Handler; + + /* Reference the handler if needed */ + if (AddReference) Bus->ReferenceCount++; + } + } + + /* Return the handler */ + return Handler; +} + +ULONG +NTAPI +HalpNoBusData(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + /* Not implemented */ + DPRINT1("STUB GetSetBusData\n"); + return 0; +} + +NTSTATUS +NTAPI +HalpNoAdjustResourceList(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList) +{ + DPRINT1("STUB Adjustment\n"); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +HalpNoAssignSlotResources(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject OPTIONAL, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources) +{ + DPRINT1("STUB Assignment\n"); + return STATUS_NOT_SUPPORTED; +} + +VOID +FASTCALL +HaliReferenceBusHandler(IN PBUS_HANDLER Handler) +{ + PHAL_BUS_HANDLER Bus; + + /* Find and reference the bus handler */ + Bus = CONTAINING_RECORD(Handler, HAL_BUS_HANDLER, Handler); + Bus->ReferenceCount++; +} + +VOID +FASTCALL +HaliDereferenceBusHandler(IN PBUS_HANDLER Handler) +{ + PHAL_BUS_HANDLER Bus; + + /* Find and dereference the bus handler */ + Bus = CONTAINING_RECORD(Handler, HAL_BUS_HANDLER, Handler); + Bus->ReferenceCount--; + ASSERT(Bus->ReferenceCount != 0); +} + +PBUS_HANDLER +FASTCALL +HaliHandlerForBus(IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber) +{ + /* Lookup the interface in the bus table */ + return HalpLookupHandler(HalpBusTable, InterfaceType, BusNumber, FALSE); +} + +PBUS_HANDLER +FASTCALL +HaliHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, + IN ULONG BusNumber) +{ + /* Lookup the configuration in the configuration table */ + return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, FALSE); +} + +PBUS_HANDLER +FASTCALL +HaliReferenceHandlerForBus(IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber) +{ + /* Lookup the interface in the bus table, and reference the handler */ + return HalpLookupHandler(HalpBusTable, InterfaceType, BusNumber, TRUE); +} + +PBUS_HANDLER +FASTCALL +HaliReferenceHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, + IN ULONG BusNumber) +{ + /* Lookup the configuration in the configuration table and add a reference */ + return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, TRUE); +} + +#ifndef _MINIHAL_ +NTSTATUS +NTAPI +HaliRegisterBusHandler(IN INTERFACE_TYPE InterfaceType, + IN BUS_DATA_TYPE ConfigType, + IN ULONG BusNumber, + IN INTERFACE_TYPE ParentBusType, + IN ULONG ParentBusNumber, + IN ULONG ExtraData, + IN PINSTALL_BUS_HANDLER InstallCallback, + OUT PBUS_HANDLER *ReturnedBusHandler) +{ + PHAL_BUS_HANDLER Bus, OldHandler = NULL; + PHAL_BUS_HANDLER* BusEntry; + PVOID CodeHandle; + PARRAY InterfaceArray, InterfaceBusNumberArray, ConfigArray, ConfigBusNumberArray; + PBUS_HANDLER ParentHandler; + KIRQL OldIrql; + NTSTATUS Status; + DPRINT1("HAL BUS REGISTRATION: %d.%d on bus %d with parent %d on bus %d\n", + InterfaceType, ConfigType, BusNumber, ParentBusType, ParentBusNumber); + + /* Make sure we have a valid handler */ + ASSERT((InterfaceType != InterfaceTypeUndefined) || + (ConfigType != ConfigurationSpaceUndefined)); + + /* Allocate the bus handler */ + Bus = ExAllocatePoolWithTag(NonPagedPool, + sizeof(HAL_BUS_HANDLER) + ExtraData, + 'HsuB'); + if (!Bus) return STATUS_INSUFFICIENT_RESOURCES; + + /* Return the handler */ + *ReturnedBusHandler = &Bus->Handler; + + /* Don't page us out */ + CodeHandle = MmLockPagableDataSection(&HaliRegisterBusHandler); + + /* Synchronize with anyone else */ + KeWaitForSingleObject(&HalpBusDatabaseEvent, + WrExecutive, + KernelMode, + FALSE, + NULL); + + /* Check for unknown/root bus */ + if (BusNumber == -1) + { + /* We must have an interface */ + ASSERT(InterfaceType != InterfaceTypeUndefined); + + /* Find the right bus */ + BusNumber = 0; + while (HaliHandlerForBus(InterfaceType, BusNumber)) BusNumber++; + } + + /* Allocate arrays for the handler */ + InterfaceArray = HalpAllocateArray(InterfaceType); + InterfaceBusNumberArray = HalpAllocateArray(BusNumber); + ConfigArray = HalpAllocateArray(ConfigType); + ConfigBusNumberArray = HalpAllocateArray(BusNumber); + + /* Only proceed if all allocations succeeded */ + if (InterfaceArray && InterfaceBusNumberArray && ConfigArray && ConfigBusNumberArray) + { + /* Find the parent handler if any */ + ParentHandler = HaliReferenceHandlerForBus(ParentBusType, ParentBusNumber); + + /* Initialize the handler */ + RtlZeroMemory(Bus, sizeof(HAL_BUS_HANDLER) + ExtraData); + Bus->ReferenceCount = 1; + + /* Fill out bus data */ + Bus->Handler.BusNumber = BusNumber; + Bus->Handler.InterfaceType = InterfaceType; + Bus->Handler.ConfigurationType = ConfigType; + Bus->Handler.ParentHandler = ParentHandler; + + /* Fill out dummy handlers */ + Bus->Handler.GetBusData = HalpNoBusData; + Bus->Handler.SetBusData = HalpNoBusData; + Bus->Handler.AdjustResourceList = HalpNoAdjustResourceList; + Bus->Handler.AssignSlotResources = HalpNoAssignSlotResources; + + /* Make space for extra data */ + if (ExtraData) Bus->Handler.BusData = Bus + 1; + + /* Check for a parent handler */ + if (ParentHandler) + { + /* Inherit the parent routines */ + Bus->Handler.GetBusData = ParentHandler->GetBusData; + Bus->Handler.SetBusData = ParentHandler->SetBusData; + Bus->Handler.AdjustResourceList = ParentHandler->AdjustResourceList; + Bus->Handler.AssignSlotResources = ParentHandler->AssignSlotResources; + Bus->Handler.TranslateBusAddress = ParentHandler->TranslateBusAddress; + Bus->Handler.GetInterruptVector = ParentHandler->GetInterruptVector; + } + + /* We don't support this yet */ + ASSERT(!InstallCallback); + + /* Lock the buses */ + KeAcquireSpinLock(&HalpBusDatabaseSpinLock, &OldIrql); + + /* Make space for the interface */ + HalpGrowArray(&HalpBusTable, &InterfaceArray); + + /* Check if we really have an interface */ + if (InterfaceType != InterfaceTypeUndefined) + { + /* Make space for the association */ + HalpGrowArray((PARRAY*)&HalpBusTable->Element[InterfaceType], + &InterfaceBusNumberArray); + + /* Get the bus handler pointer */ + BusEntry = (PHAL_BUS_HANDLER*)&((PARRAY)HalpBusTable->Element[InterfaceType])->Element[BusNumber]; + + /* Check if there was already a handler there, and set the new one */ + if (*BusEntry) OldHandler = *BusEntry; + *BusEntry = Bus; + } + + /* Now add a space for the configuration space */ + HalpGrowArray(&HalpConfigTable, &ConfigArray); + + /* Check if we really have one */ + if (ConfigType != ConfigurationSpaceUndefined) + { + /* Make space for this association */ + HalpGrowArray((PARRAY*)&HalpConfigTable->Element[ConfigType], + &ConfigBusNumberArray); + + /* Get the bus handler pointer */ + BusEntry = (PHAL_BUS_HANDLER*)&((PARRAY)HalpConfigTable->Element[ConfigType])->Element[BusNumber]; + if (*BusEntry) + { + /* Get the old entry, but make sure it's the same we had before */ + ASSERT((OldHandler == NULL) || (OldHandler == *BusEntry)); + OldHandler = *BusEntry; + } + + /* Set the new entry */ + *BusEntry = Bus; + } + + /* Link the adapter */ + InsertTailList(&HalpAllBusHandlers, &Bus->AllHandlers); + + /* Remove the old linkage */ + Bus = OldHandler; + if (Bus) RemoveEntryList(&Bus->AllHandlers); + + /* Release the lock */ + KeReleaseSpinLock(&HalpBusDatabaseSpinLock, OldIrql); + Status = STATUS_SUCCESS; + } + else + { + /* Fail */ + Status = STATUS_INSUFFICIENT_RESOURCES; + } + + /* Signal the event */ + KeSetEvent(&HalpBusDatabaseEvent, 0, FALSE); + + /* Re-page the function */ + MmUnlockPagableImageSection(CodeHandle); + + /* Free all allocations */ + if (Bus) ExFreePool(Bus); + if (InterfaceArray) ExFreePool(InterfaceArray); + if (InterfaceBusNumberArray) ExFreePool(InterfaceBusNumberArray); + if (ConfigArray) ExFreePool(ConfigArray); + if (ConfigBusNumberArray) ExFreePool(ConfigBusNumberArray); + + /* And we're done */ + DPRINT1("Bus handler has been registered: %p\n", *ReturnedBusHandler); + return Status; +} +#endif + +VOID +NTAPI +HalpInitBusHandler(VOID) +{ + /* Setup the bus lock */ + KeInitializeSpinLock(&HalpBusDatabaseSpinLock); + + /* Setup the bus event */ + KeInitializeEvent(&HalpBusDatabaseEvent, SynchronizationEvent, TRUE); + + /* Setup the bus configuration and bus table */ + HalpBusTable = HalpAllocateArray(0); + HalpConfigTable = HalpAllocateArray(0); + + /* Setup the bus list */ + InitializeListHead(&HalpAllBusHandlers); + + /* Setup the HAL Dispatch routines */ +#ifndef _MINIHAL_ + HalRegisterBusHandler = HaliRegisterBusHandler; + HalHandlerForBus = HaliHandlerForBus; + HalHandlerForConfigSpace = HaliHandlerForConfigSpace; + HalReferenceHandlerForBus = HaliReferenceHandlerForBus; + HalReferenceBusHandler = HaliReferenceBusHandler; + HalDereferenceBusHandler = HaliDereferenceBusHandler; +#endif + HalPciAssignSlotResources = HalpAssignSlotResources; + /* 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 +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/legacy/bus/cmosbus.c b/reactos/hal/halx86/generic/legacy/bus/cmosbus.c new file mode 100644 index 00000000000..279aebf9e20 --- /dev/null +++ b/reactos/hal/halx86/generic/legacy/bus/cmosbus.c @@ -0,0 +1,47 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/bus/sysbus.c + * PURPOSE: + * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +/* PRIVATE FUNCTIONS **********************************************************/ + +ULONG +NTAPI +HalpcGetCmosData(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + DPRINT1("CMOS GetData\n"); + while (TRUE); + return 0; +} + +ULONG +NTAPI +HalpcSetCmosData(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + DPRINT1("CMOS SetData\n"); + while (TRUE); + return 0; +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/legacy/bus/isabus.c b/reactos/hal/halx86/generic/legacy/bus/isabus.c new file mode 100644 index 00000000000..884e6d026bb --- /dev/null +++ b/reactos/hal/halx86/generic/legacy/bus/isabus.c @@ -0,0 +1,32 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/bus/isabus.c + * PURPOSE: + * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +/* PRIVATE FUNCTIONS **********************************************************/ + +BOOLEAN +NTAPI +HalpTranslateIsaBusAddress(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress) +{ + DPRINT1("ISA Translate\n"); + while (TRUE); + return FALSE; +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/bus/pcibus.c b/reactos/hal/halx86/generic/legacy/bus/pcibus.c similarity index 99% rename from reactos/hal/halx86/generic/bus/pcibus.c rename to reactos/hal/halx86/generic/legacy/bus/pcibus.c index ef3def412bd..f4d64e3b063 100644 --- a/reactos/hal/halx86/generic/bus/pcibus.c +++ b/reactos/hal/halx86/generic/legacy/bus/pcibus.c @@ -14,6 +14,8 @@ /* GLOBALS *******************************************************************/ +ULONG HalpBusType; + PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}}; BOOLEAN HalpPCIConfigInitialized; diff --git a/reactos/hal/halx86/generic/bus/pcidata.c b/reactos/hal/halx86/generic/legacy/bus/pcidata.c similarity index 100% rename from reactos/hal/halx86/generic/bus/pcidata.c rename to reactos/hal/halx86/generic/legacy/bus/pcidata.c diff --git a/reactos/hal/halx86/generic/legacy/bus/sysbus.c b/reactos/hal/halx86/generic/legacy/bus/sysbus.c new file mode 100644 index 00000000000..ab8d2925c44 --- /dev/null +++ b/reactos/hal/halx86/generic/legacy/bus/sysbus.c @@ -0,0 +1,47 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/bus/sysbus.c + * PURPOSE: + * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +/* PRIVATE FUNCTIONS **********************************************************/ + +BOOLEAN +NTAPI +HalpTranslateSystemBusAddress(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress) +{ + DPRINT1("SYSTEM Translate\n"); + while (TRUE); + return FALSE; +} + +ULONG +NTAPI +HalpGetSystemInterruptVector(IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity) +{ + /* Get the root vector */ + DPRINT1("SYSTEM GetVector\n"); + while (TRUE); + return 0; +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/legacy/bussupp.c b/reactos/hal/halx86/generic/legacy/bussupp.c new file mode 100644 index 00000000000..831d27981d9 --- /dev/null +++ b/reactos/hal/halx86/generic/legacy/bussupp.c @@ -0,0 +1,488 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: hal/halx86/generic/legacy/bussupp.c + * PURPOSE: HAL Legacy Bus Support Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +/* PRIVATE FUNCTIONS **********************************************************/ + +PBUS_HANDLER +NTAPI +HalpAllocateBusHandler(IN INTERFACE_TYPE InterfaceType, + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN INTERFACE_TYPE ParentBusInterfaceType, + IN ULONG ParentBusNumber, + IN ULONG BusSpecificData) +{ + PBUS_HANDLER Bus; + + /* Register the bus handler */ + HalRegisterBusHandler(InterfaceType, + BusDataType, + BusNumber, + ParentBusInterfaceType, + ParentBusNumber, + BusSpecificData, + NULL, + &Bus); + if (!Bus) return NULL; + + /* Check for a valid interface */ + if (InterfaceType != InterfaceTypeUndefined) + { + /* Allocate address ranges and zero them out */ + Bus->BusAddresses = ExAllocatePoolWithTag(NonPagedPool, + sizeof(SUPPORTED_RANGES), + ' laH'); + RtlZeroMemory(Bus->BusAddresses, sizeof(SUPPORTED_RANGES)); + + /* Build the data structure */ + Bus->BusAddresses->Version = HAL_SUPPORTED_RANGE_VERSION; + Bus->BusAddresses->Dma.Limit = 7; + Bus->BusAddresses->Memory.Limit = 0xFFFFFFFF; + Bus->BusAddresses->IO.Limit = 0xFFFF; + Bus->BusAddresses->IO.SystemAddressSpace = 1; + Bus->BusAddresses->PrefetchMemory.Base = 1; + } + + /* Return the bus address */ + return Bus; +} + +VOID +NTAPI +HalpRegisterInternalBusHandlers(VOID) +{ + PBUS_HANDLER Bus; + + /* Only do processor 1 */ + if (KeGetCurrentPrcb()->Number) return; + + /* Register root support */ + HalpInitBusHandler(); + + /* Allocate the system bus */ + Bus = HalpAllocateBusHandler(Internal, + ConfigurationSpaceUndefined, + 0, + InterfaceTypeUndefined, + 0, + 0); + DPRINT1("Registering Internal Bus: %p\n", Bus); + if (Bus) + { + /* Set it up */ + Bus->GetInterruptVector = HalpGetSystemInterruptVector; + Bus->TranslateBusAddress = HalpTranslateSystemBusAddress; + } + + /* Allocate the CMOS bus */ + Bus = HalpAllocateBusHandler(InterfaceTypeUndefined, + Cmos, + 0, + InterfaceTypeUndefined, + 0, + 0); + DPRINT1("Registering CMOS Bus: %p\n", Bus); + if (Bus) + { + /* Set it up */ + Bus->GetBusData = HalpcGetCmosData; + Bus->SetBusData = HalpcSetCmosData; + } + + /* Allocate the CMOS bus */ + Bus = HalpAllocateBusHandler(InterfaceTypeUndefined, + Cmos, + 1, + InterfaceTypeUndefined, + 0, + 0); + DPRINT1("Registering CMOS Bus: %p\n", Bus); + if (Bus) + { + /* Set it up */ + Bus->GetBusData = HalpcGetCmosData; + Bus->SetBusData = HalpcSetCmosData; + } + + /* Allocate ISA bus */ + Bus = HalpAllocateBusHandler(Isa, + ConfigurationSpaceUndefined, + 0, + Internal, + 0, + 0); + DPRINT1("Registering ISA Bus: %p\n", Bus); + if (Bus) + { + /* Set it up */ + Bus->GetBusData = HalpNoBusData; + Bus->BusAddresses->Memory.Limit = 0xFFFFFF; + Bus->TranslateBusAddress = HalpTranslateIsaBusAddress; + } + + /* No support for EISA or MCA */ + ASSERT(HalpBusType == MACHINE_TYPE_ISA); +} + +VOID +NTAPI +HalpInitializePciBus(VOID) +{ + /* FIXME: Should do legacy PCI bus detection */ + + /* FIXME: Should detect chipset hacks */ + + /* FIXME: Should detect broken PCI hardware and apply hacks */ + + /* FIXME: Should build resource ranges */ +} + +VOID +NTAPI +HalpInitBusHandlers(VOID) +{ + /* Register the HAL Bus Handler support */ + HalpRegisterInternalBusHandlers(); +} + +VOID +NTAPI +HalpRegisterKdSupportFunctions(VOID) +{ + /* Register PCI Device Functions */ + KdSetupPciDeviceForDebugging = HalpSetupPciDeviceForDebugging; + KdReleasePciDeviceforDebugging = HalpReleasePciDeviceForDebugging; + + /* Register memory functions */ +#ifndef _MINIHAL_ + KdMapPhysicalMemory64 = HalpMapPhysicalMemory64; + KdUnmapVirtualAddress = HalpUnmapVirtualAddress; +#endif + + /* Register ACPI stub */ + KdCheckPowerButton = HalpCheckPowerButton; +} + +NTSTATUS +NTAPI +HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources) +{ + BUS_HANDLER BusHandler; + PAGED_CODE(); + + /* Only PCI is supported */ + if (BusType != PCIBus) return STATUS_NOT_IMPLEMENTED; + + /* Setup fake PCI Bus handler */ + RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER)); + BusHandler.BusNumber = BusNumber; + + /* Call the PCI function */ + return HalpAssignPCISlotResources(&BusHandler, + &BusHandler, + RegistryPath, + DriverClassName, + DriverObject, + DeviceObject, + SlotNumber, + AllocatedResources); +} + +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, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress, + IN OUT PULONG_PTR Context, + IN BOOLEAN NextBus) +{ + /* 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; + return TRUE; +} + +/* PUBLIC FUNCTIONS **********************************************************/ + +/* + * @implemented + */ +NTSTATUS +NTAPI +HalAdjustResourceList(IN PCM_RESOURCE_LIST Resources) +{ + /* Deprecated, return success */ + return STATUS_SUCCESS; +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +HalAssignSlotResources(IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources) +{ + /* Check the bus type */ + if (BusType != PCIBus) + { + /* Call our internal handler */ + return HalpAssignSlotResources(RegistryPath, + DriverClassName, + DriverObject, + DeviceObject, + BusType, + BusNumber, + SlotNumber, + AllocatedResources); + } + else + { + /* Call the PCI registered function */ + return HalPciAssignSlotResources(RegistryPath, + DriverClassName, + DriverObject, + DeviceObject, + PCIBus, + BusNumber, + SlotNumber, + AllocatedResources); + } +} + +/* + * @implemented + */ +ULONG +NTAPI +HalGetBusData(IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length) +{ + /* Call the extended function */ + return HalGetBusDataByOffset(BusDataType, + BusNumber, + SlotNumber, + Buffer, + 0, + Length); +} + +/* + * @implemented + */ +ULONG +NTAPI +HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + BUS_HANDLER BusHandler; + + /* Look as the bus type */ + if (BusDataType == Cmos) + { + /* Call CMOS Function */ + return HalpGetCmosData(0, SlotNumber, Buffer, Length); + } + else if (BusDataType == EisaConfiguration) + { + /* FIXME: TODO */ + ASSERT(FALSE); + } + else if ((BusDataType == PCIConfiguration) && + (HalpPCIConfigInitialized) && + ((BusNumber >= HalpMinPciBus) && (BusNumber <= HalpMaxPciBus))) + { + /* Setup fake PCI Bus handler */ + RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER)); + BusHandler.BusNumber = BusNumber; + + /* Call PCI function */ + return HalpGetPCIData(&BusHandler, + &BusHandler, + *(PPCI_SLOT_NUMBER)&SlotNumber, + Buffer, + Offset, + Length); + } + + /* Invalid bus */ + return 0; +} + +/* + * @implemented + */ +ULONG +NTAPI +HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity) +{ + /* Call the system bus translator */ + return HalpGetSystemInterruptVector_Acpi(BusNumber, + BusInterruptLevel, + BusInterruptVector, + Irql, + Affinity); +} + +/* + * @implemented + */ +ULONG +NTAPI +HalSetBusData(IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length) +{ + /* Call the extended function */ + return HalSetBusDataByOffset(BusDataType, + BusNumber, + SlotNumber, + Buffer, + 0, + Length); +} + +/* + * @implemented + */ +ULONG +NTAPI +HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + 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; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress) +{ + /* Look as the bus type */ + if (InterfaceType == PCIBus) + { + /* Call the PCI registered function */ + return HalPciTranslateBusAddress(PCIBus, + BusNumber, + BusAddress, + AddressSpace, + TranslatedAddress); + } + else + { + /* Translation is easy */ + TranslatedAddress->QuadPart = BusAddress.QuadPart; + return TRUE; + } +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/legacy/halpcat.c b/reactos/hal/halx86/generic/legacy/halpcat.c index ea16403676e..0b85acd54ae 100644 --- a/reactos/hal/halx86/generic/legacy/halpcat.c +++ b/reactos/hal/halx86/generic/legacy/halpcat.c @@ -1,7 +1,7 @@ /* * PROJECT: ReactOS HAL * LICENSE: BSD - See COPYING.ARM in the top level directory - * FILE: hal/halx86/generic/acpi/halpcat.c + * FILE: hal/halx86/generic/legacy/halpcat.c * PURPOSE: HAL Legacy Support Code * PROGRAMMERS: ReactOS Portable Systems Group */ @@ -29,19 +29,6 @@ HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) return STATUS_NO_SUCH_DEVICE; } -VOID -NTAPI -HalpInitializePciBus(VOID) -{ - /* FIXME: Should do legacy PCI bus detection */ - - /* FIXME: Should detect chipset hacks */ - - /* FIXME: Should detect broken PCI hardware and apply hacks */ - - /* FIXME: Should build resource ranges */ -} - VOID NTAPI HalpBuildAddressMap(VOID) diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index a6ee63b3b88..0cd4e5aac43 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -7,14 +7,6 @@ - - bushndlr.c - isabus.c - halbus.c - pcibus.c - pcidata.c - sysbus.c - beep.c cmos.c display.c diff --git a/reactos/hal/halx86/hal_generic_acpi.rbuild b/reactos/hal/halx86/hal_generic_acpi.rbuild index 3784394b642..97501cb1823 100644 --- a/reactos/hal/halx86/hal_generic_acpi.rbuild +++ b/reactos/hal/halx86/hal_generic_acpi.rbuild @@ -10,7 +10,13 @@ halacpi.c halpnpdd.c + busemul.c + + + pcibus.c + + diff --git a/reactos/hal/halx86/hal_generic_pcat.rbuild b/reactos/hal/halx86/hal_generic_pcat.rbuild index e00ed5bdb4e..51f46eefc71 100644 --- a/reactos/hal/halx86/hal_generic_pcat.rbuild +++ b/reactos/hal/halx86/hal_generic_pcat.rbuild @@ -8,6 +8,15 @@ + + bushndlr.c + cmosbus.c + isabus.c + pcibus.c + pcidata.c + sysbus.c + + bussupp.c halpcat.c diff --git a/reactos/hal/halx86/hal_mini.rbuild b/reactos/hal/halx86/hal_mini.rbuild index a7baed44639..b2c8b718735 100644 --- a/reactos/hal/halx86/hal_mini.rbuild +++ b/reactos/hal/halx86/hal_mini.rbuild @@ -9,13 +9,16 @@ - - bushndlr.c - isabus.c - halbus.c - pcibus.c - pcidata.c - sysbus.c + + + bushndlr.c + cmosbus.c + isabus.c + pcibus.c + pcidata.c + sysbus.c + + bussupp.c beep.c bios.c diff --git a/reactos/hal/halx86/include/bus.h b/reactos/hal/halx86/include/bus.h index 03840227411..e8e6ef16f86 100644 --- a/reactos/hal/halx86/include/bus.h +++ b/reactos/hal/halx86/include/bus.h @@ -205,6 +205,8 @@ typedef struct _HAL_BUS_HANDLER /* FUNCTIONS *****************************************************************/ +/* SHARED (Fake PCI-BUS HANDLER) */ + VOID NTAPI HalpPCISynchronizeType1( @@ -277,34 +279,6 @@ HalpWritePCIConfig( IN ULONG Length ); -ULONG -NTAPI -HalpGetSystemInterruptVector( - ULONG BusNumber, - ULONG BusInterruptLevel, - ULONG BusInterruptVector, - PKIRQL Irql, - PKAFFINITY Affinity -); - -ULONG -NTAPI -HalpGetCmosData( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length -); - -ULONG -NTAPI -HalpSetCmosData( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length -); - ULONG NTAPI HalpGetPCIData( @@ -340,6 +314,36 @@ HalpAssignPCISlotResources( IN OUT PCM_RESOURCE_LIST *pAllocatedResources ); +/* NON-LEGACY */ + +ULONG +NTAPI +HalpGetSystemInterruptVector_Acpi( + ULONG BusNumber, + ULONG BusInterruptLevel, + ULONG BusInterruptVector, + PKIRQL Irql, + PKAFFINITY Affinity +); + +ULONG +NTAPI +HalpGetCmosData( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length +); + +ULONG +NTAPI +HalpSetCmosData( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length +); + VOID NTAPI HalpInitializePciBus( @@ -352,12 +356,6 @@ HalpInitializePciStubs( VOID ); -VOID -NTAPI -HalpInitBusHandler( - VOID -); - BOOLEAN NTAPI HalpTranslateBusAddress( @@ -397,6 +395,78 @@ HalpRegisterPciDebuggingDeviceInfo( VOID ); +/* LEGACY */ + +VOID +NTAPI +HalpInitBusHandler( + VOID +); + +ULONG +NTAPI +HalpNoBusData( + IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length +); + +ULONG +NTAPI +HalpcGetCmosData( + IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length +); + +ULONG +NTAPI +HalpcSetCmosData( + IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length +); + +BOOLEAN +NTAPI +HalpTranslateSystemBusAddress( + IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress +); + +BOOLEAN +NTAPI +HalpTranslateIsaBusAddress( + IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress +); + +ULONG +NTAPI +HalpGetSystemInterruptVector( + IN PBUS_HANDLER BusHandler, + IN PBUS_HANDLER RootHandler, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity +); + extern ULONG HalpBusType; extern BOOLEAN HalpPCIConfigInitialized; extern BUS_HANDLER HalpFakePciBusHandler; diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index 6edb85570d7..aa36554c7ec 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -765,6 +765,12 @@ KeUpdateSystemTime( IN KIRQL OldIrql ); +VOID +NTAPI +HalpInitBusHandlers( + VOID +); + #ifdef _M_AMD64 #define KfLowerIrql KeLowerIrql #ifndef CONFIG_SMP