Author: sir_richard
Date: Mon Jun 7 03:09:41 2010
New Revision: 47649
URL:
http://svn.reactos.org/svn/reactos?rev=47649&view=rev
Log:
[HAL]: Bus support in the HAL actually creates a further wedge between the different x86
HALs: There are actually two dinstinct implementations. On the ACPI HAL, the system is
assumed not to have things like special ISA, MCA, EISA buses, and a PCI driver is used in
combination with the ACPI Interface for PCI Bus support. On non-ACPI systems, the legacy
"Bus Handler" library is used, and the HAL provides a core set of CMOS, EISA,
ISA, MCA and PCI bus handlers, each with their own routines and specific code.
Additionally, PCI IRQ Routing and other PCI bus internals are handled directly by the HAL
-- on the ACPI HAL, the PCI Bus support is implemented through a "Fake"/static
bus handler, just to keep the functions shared. On ReactOS, both the ACPI and non-ACPI HAL
were currently using a mix of both HAL bus handling types, mostly implemented the
"ACPI way" (with a fake PCI bus handler and such).
As a result, none of the Hal*Bus HALDISPATCH routines were implemented, which bus
drivers expect to find when they're not on ACPI systems (ReactOS today). eVb's new
PCI driver was crashing, for example.
Furthermore, legacy systems suffer, because the ACPI HAL Bus routines (that we
currently have) expect perfect ACPI-style-compliant systems, not the legacy crap from the
early 90ies. This works fine in VMs and new hardware, but old hardware is left behind.
This patch basically corrects the first part of the problem, by making the bus
handling support separate between ACPI and non-ACPI HALs. For now, the code remains 100%
the same in functionality between both.
However, I have started adding the first few elements:
[HAL]: Implement HalRegisterBusHandler HALDISPATCH routine.
[HAL]: On legacy HALs, register the CMOS, ISA, SYSTEM handlers.
[HAL]: Add cmosbus.c. Stub all bus-specific bus handler routines in the xxxbus.c files.
No real functionality change occurs with this patch, yet.
Added:
trunk/reactos/hal/halx86/generic/acpi/busemul.c (with props)
trunk/reactos/hal/halx86/generic/legacy/bus/
- copied from r47576, trunk/reactos/hal/halx86/generic/bus/
trunk/reactos/hal/halx86/generic/legacy/bus/cmosbus.c (with props)
trunk/reactos/hal/halx86/generic/legacy/bussupp.c (with props)
Removed:
trunk/reactos/hal/halx86/generic/bus/
trunk/reactos/hal/halx86/generic/legacy/bus/halbus.c
Modified:
trunk/reactos/hal/halx86/generic/acpi/halacpi.c
trunk/reactos/hal/halx86/generic/halinit.c
trunk/reactos/hal/halx86/generic/legacy/bus/bushndlr.c
trunk/reactos/hal/halx86/generic/legacy/bus/isabus.c
trunk/reactos/hal/halx86/generic/legacy/bus/pcibus.c
trunk/reactos/hal/halx86/generic/legacy/bus/sysbus.c
trunk/reactos/hal/halx86/generic/legacy/halpcat.c
trunk/reactos/hal/halx86/hal_generic.rbuild
trunk/reactos/hal/halx86/hal_generic_acpi.rbuild
trunk/reactos/hal/halx86/hal_generic_pcat.rbuild
trunk/reactos/hal/halx86/hal_mini.rbuild
trunk/reactos/hal/halx86/include/bus.h
trunk/reactos/hal/halx86/include/halp.h
Added: trunk/reactos/hal/halx86/generic/acpi/busemul.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/acpi/bu…
==============================================================================
--- trunk/reactos/hal/halx86/generic/acpi/busemul.c (added)
+++ trunk/reactos/hal/halx86/generic/acpi/busemul.c [iso-8859-1] Mon Jun 7 03:09:41 2010
@@ -1,0 +1,346 @@
+/*
+ * PROJECT: ReactOS HAL
+ * 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 *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+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 */
Propchange: trunk/reactos/hal/halx86/generic/acpi/busemul.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/hal/halx86/generic/acpi/busemul.c
------------------------------------------------------------------------------
svn:eol-syle = native
Propchange: trunk/reactos/hal/halx86/generic/acpi/busemul.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/reactos/hal/halx86/generic/acpi/halacpi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/acpi/ha…
==============================================================================
--- trunk/reactos/hal/halx86/generic/acpi/halacpi.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/acpi/halacpi.c [iso-8859-1] Mon Jun 7 03:09:41 2010
@@ -881,6 +881,24 @@
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)
{
/* ACPI is magic baby */
Modified: trunk/reactos/hal/halx86/generic/halinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/halinit…
==============================================================================
--- trunk/reactos/hal/halx86/generic/halinit.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/halinit.c [iso-8859-1] Mon Jun 7 03:09:41 2010
@@ -155,7 +155,7 @@
else if (BootPhase == 1)
{
/* Initialize bus handlers */
- HalpInitBusHandler();
+ HalpInitBusHandlers();
#ifndef _MINIHAL_
/* Enable IRQ 0 */
Modified: trunk/reactos/hal/halx86/generic/legacy/bus/bushndlr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/bus/bushndlr.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/legacy/bus/bushndlr.c [iso-8859-1] Mon Jun 7
03:09:41 2010
@@ -103,6 +103,45 @@
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)
@@ -162,25 +201,224 @@
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;
- HalPciAssignSlotResources = HalpAssignSlotResources;
HalFindBusAddressTranslation = HalpFindBusAddressTranslation;
-}
+#endif
+}
+
+/* EOF */
Added: trunk/reactos/hal/halx86/generic/legacy/bus/cmosbus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/bus/cmosbus.c (added)
+++ trunk/reactos/hal/halx86/generic/legacy/bus/cmosbus.c [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -1,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(a)reactos.org)
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* 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 */
Propchange: trunk/reactos/hal/halx86/generic/legacy/bus/cmosbus.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/hal/halx86/generic/legacy/bus/cmosbus.c
------------------------------------------------------------------------------
svn:eol-syle = native
Propchange: trunk/reactos/hal/halx86/generic/legacy/bus/cmosbus.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Removed: trunk/reactos/hal/halx86/generic/legacy/bus/halbus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/bus/hal…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/bus/halbus.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/legacy/bus/halbus.c (removed)
@@ -1,348 +1,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <hal.h>
-#define NDEBUG
-#include <debug.h>
-
-/* GLOBALS *******************************************************************/
-
-ULONG HalpBusType;
-
-/* PRIVATE FUNCTIONS *********************************************************/
-
-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(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(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 */
Modified: trunk/reactos/hal/halx86/generic/legacy/bus/isabus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/bus/isabus.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/legacy/bus/isabus.c [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -5,3 +5,28 @@
* PURPOSE:
* PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg(a)reactos.org)
*/
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* 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 */
Modified: trunk/reactos/hal/halx86/generic/legacy/bus/pcibus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/bus/pcibus.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/legacy/bus/pcibus.c [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -13,6 +13,8 @@
#include <debug.h>
/* GLOBALS *******************************************************************/
+
+ULONG HalpBusType;
PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}};
Modified: trunk/reactos/hal/halx86/generic/legacy/bus/sysbus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/bus/sysbus.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/legacy/bus/sysbus.c [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -5,3 +5,43 @@
* PURPOSE:
* PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg(a)reactos.org)
*/
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* 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 */
Added: trunk/reactos/hal/halx86/generic/legacy/bussupp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/bussupp.c (added)
+++ trunk/reactos/hal/halx86/generic/legacy/bussupp.c [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -1,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 <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* 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 */
Propchange: trunk/reactos/hal/halx86/generic/legacy/bussupp.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/hal/halx86/generic/legacy/bussupp.c
------------------------------------------------------------------------------
svn:eol-syle = native
Propchange: trunk/reactos/hal/halx86/generic/legacy/bussupp.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/reactos/hal/halx86/generic/legacy/halpcat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/…
==============================================================================
--- trunk/reactos/hal/halx86/generic/legacy/halpcat.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/legacy/halpcat.c [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -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
*/
@@ -27,19 +27,6 @@
{
/* There is no ACPI on these HALs */
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
Modified: trunk/reactos/hal/halx86/hal_generic.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/hal_generic.rbu…
==============================================================================
--- trunk/reactos/hal/halx86/hal_generic.rbuild [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/hal_generic.rbuild [iso-8859-1] Mon Jun 7 03:09:41 2010
@@ -7,14 +7,6 @@
<define name="_NTHALDLL_" />
<define name="_NTHAL_" />
<directory name="generic">
- <directory name="bus">
- <file>bushndlr.c</file>
- <file>isabus.c</file>
- <file>halbus.c</file>
- <file>pcibus.c</file>
- <file>pcidata.c</file>
- <file>sysbus.c</file>
- </directory>
<file>beep.c</file>
<file>cmos.c</file>
<file>display.c</file>
Modified: trunk/reactos/hal/halx86/hal_generic_acpi.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/hal_generic_acp…
==============================================================================
--- trunk/reactos/hal/halx86/hal_generic_acpi.rbuild [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/hal_generic_acpi.rbuild [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -10,7 +10,13 @@
<directory name="acpi">
<file>halacpi.c</file>
<file>halpnpdd.c</file>
+ <file>busemul.c</file>
</directory>
+ <directory name="legacy">
+ <directory name="bus">
+ <file>pcibus.c</file>
+ </directory>
+ </directory>
</directory>
</module>
</group>
Modified: trunk/reactos/hal/halx86/hal_generic_pcat.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/hal_generic_pca…
==============================================================================
--- trunk/reactos/hal/halx86/hal_generic_pcat.rbuild [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/hal_generic_pcat.rbuild [iso-8859-1] Mon Jun 7 03:09:41
2010
@@ -8,6 +8,15 @@
<define name="_NTHAL_" />
<directory name="generic">
<directory name="legacy">
+ <directory name="bus">
+ <file>bushndlr.c</file>
+ <file>cmosbus.c</file>
+ <file>isabus.c</file>
+ <file>pcibus.c</file>
+ <file>pcidata.c</file>
+ <file>sysbus.c</file>
+ </directory>
+ <file>bussupp.c</file>
<file>halpcat.c</file>
</directory>
</directory>
Modified: trunk/reactos/hal/halx86/hal_mini.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/hal_mini.rbuild…
==============================================================================
--- trunk/reactos/hal/halx86/hal_mini.rbuild [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/hal_mini.rbuild [iso-8859-1] Mon Jun 7 03:09:41 2010
@@ -9,13 +9,16 @@
<define name="_BLDR_" />
<define name="_MINIHAL_" />
<directory name="generic">
- <directory name="bus">
- <file>bushndlr.c</file>
- <file>isabus.c</file>
- <file>halbus.c</file>
- <file>pcibus.c</file>
- <file>pcidata.c</file>
- <file>sysbus.c</file>
+ <directory name="legacy">
+ <directory name="bus">
+ <file>bushndlr.c</file>
+ <file>cmosbus.c</file>
+ <file>isabus.c</file>
+ <file>pcibus.c</file>
+ <file>pcidata.c</file>
+ <file>sysbus.c</file>
+ </directory>
+ <file>bussupp.c</file>
</directory>
<file>beep.c</file>
<file>bios.c</file>
Modified: trunk/reactos/hal/halx86/include/bus.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/bus.h?r…
==============================================================================
--- trunk/reactos/hal/halx86/include/bus.h [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/include/bus.h [iso-8859-1] Mon Jun 7 03:09:41 2010
@@ -205,6 +205,8 @@
/* FUNCTIONS *****************************************************************/
+/* SHARED (Fake PCI-BUS HANDLER) */
+
VOID
NTAPI
HalpPCISynchronizeType1(
@@ -279,34 +281,6 @@
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(
IN PBUS_HANDLER BusHandler,
IN PBUS_HANDLER RootBusHandler,
@@ -340,6 +314,36 @@
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(
@@ -349,12 +353,6 @@
VOID
NTAPI
HalpInitializePciStubs(
- VOID
-);
-
-VOID
-NTAPI
-HalpInitBusHandler(
VOID
);
@@ -397,6 +395,78 @@
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;
Modified: trunk/reactos/hal/halx86/include/halp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/halp.h?…
==============================================================================
--- trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] Mon Jun 7 03:09:41 2010
@@ -765,6 +765,12 @@
IN KIRQL OldIrql
);
+VOID
+NTAPI
+HalpInitBusHandlers(
+ VOID
+);
+
#ifdef _M_AMD64
#define KfLowerIrql KeLowerIrql
#ifndef CONFIG_SMP