Author: sir_richard
Date: Mon Jun 7 22:59:00 2010
New Revision: 47677
URL: http://svn.reactos.org/svn/reactos?rev=47677&view=rev
Log:
[HAL]: Implement system bus address translation.
Modified:
trunk/reactos/hal/halx86/generic/legacy/bus/sysbus.c
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 22:59:00 2010
@@ -24,8 +24,89 @@
IN OUT PULONG AddressSpace,
OUT PPHYSICAL_ADDRESS TranslatedAddress)
{
- DPRINT1("SYSTEM Translate\n");
- while (TRUE);
+ PSUPPORTED_RANGE Range = NULL;
+
+ /* Check what kind of address space this is */
+ switch (*AddressSpace)
+ {
+ /* Memory address */
+ case 0:
+
+ /* Loop all prefetech memory */
+ for (Range = &BusHandler->BusAddresses->PrefetchMemory;
+ Range;
+ Range = Range->Next)
+ {
+ /* Check if it's in a valid range */
+ if ((BusAddress.QuadPart >= Range->Base) &&
+ (BusAddress.QuadPart <= Range->Limit))
+ {
+ /* Get out */
+ break;
+ }
+ }
+
+ /* Check if we haven't found anything yet */
+ if (!Range)
+ {
+ /* Loop all bus memory */
+ for (Range = &BusHandler->BusAddresses->Memory;
+ Range;
+ Range = Range->Next)
+ {
+ /* Check if it's in a valid range */
+ if ((BusAddress.QuadPart >= Range->Base) &&
+ (BusAddress.QuadPart <= Range->Limit))
+ {
+ /* Get out */
+ break;
+ }
+ }
+ }
+
+ /* Done */
+ break;
+
+ /* I/O Space */
+ case 1:
+
+ /* Loop all bus I/O memory */
+ for (Range = &BusHandler->BusAddresses->IO;
+ Range;
+ Range = Range->Next)
+ {
+ /* Check if it's in a valid range */
+ if ((BusAddress.QuadPart >= Range->Base) &&
+ (BusAddress.QuadPart <= Range->Limit))
+ {
+ /* Get out */
+ break;
+ }
+ }
+
+ /* Done */
+ break;
+ }
+
+ /* Check if we found a range */
+ if (Range)
+ {
+ /* Do the translation and return the kind of address space this is */
+ TranslatedAddress->QuadPart = BusAddress.QuadPart + Range->SystemBase;
+ if ((TranslatedAddress->QuadPart != BusAddress.QuadPart) ||
+ (*AddressSpace != Range->SystemAddressSpace))
+ {
+ /* Different than what the old HAL would do */
+ DPRINT1("Translation of %I64x is %I64x %s\n",
+ BusAddress.QuadPart, TranslatedAddress->QuadPart,
+ Range->SystemAddressSpace ? "In I/O Space" : "In RAM");
+ }
+ *AddressSpace = Range->SystemAddressSpace;
+ return TRUE;
+ }
+
+ /* Nothing found */
+ DPRINT1("Translation of %I64x failed!\n", BusAddress.QuadPart);
return FALSE;
}
Author: sir_richard
Date: Mon Jun 7 22:39:11 2010
New Revision: 47676
URL: http://svn.reactos.org/svn/reactos?rev=47676&view=rev
Log:
[HAL]: Implement Bus Handler support for HalGetInterruptVector too. The new functionality now includes support for checking against reserved HAL vectors instead of blindling assining IRQLs/Vectors to callers. A warning is printed on the debug log when the old HAL would've returned different values. Please test. If you have issues, the problem is in the DRIVERS, not this code.
Modified:
trunk/reactos/hal/halx86/generic/legacy/bussupp.c
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/legacy/bussupp.c [iso-8859-1] Mon Jun 7 22:39:11 2010
@@ -1163,10 +1163,10 @@
ULONG
NTAPI
HalpGetSystemInterruptVector_Acpi(IN ULONG BusNumber,
- IN ULONG BusInterruptLevel,
- IN ULONG BusInterruptVector,
- OUT PKIRQL Irql,
- OUT PKAFFINITY Affinity)
+ IN ULONG BusInterruptLevel,
+ IN ULONG BusInterruptVector,
+ OUT PKIRQL Irql,
+ OUT PKAFFINITY Affinity)
{
ULONG Vector = IRQ2VECTOR(BusInterruptLevel);
*Irql = (KIRQL)VECTOR2IRQL(Vector);
@@ -1314,12 +1314,38 @@
OUT PKIRQL Irql,
OUT PKAFFINITY Affinity)
{
- /* Call the system bus translator */
- return HalpGetSystemInterruptVector_Acpi(BusNumber,
- BusInterruptLevel,
- BusInterruptVector,
- Irql,
- Affinity);
+ PBUS_HANDLER Handler;
+ ULONG Vector;
+ PAGED_CODE();
+
+ /* Defaults */
+ *Irql = 0;
+ *Affinity = 0;
+
+ /* Find the handler */
+ Handler = HalReferenceHandlerForBus(InterfaceType, BusNumber);
+ if (!Handler) return 0;
+
+ /* Do the assignment */
+ Vector = Handler->GetInterruptVector(Handler,
+ Handler,
+ BusInterruptLevel,
+ BusInterruptVector,
+ Irql,
+ Affinity);
+ if ((Vector != IRQ2VECTOR(BusInterruptLevel)) ||
+ (*Irql != VECTOR2IRQL(IRQ2VECTOR(BusInterruptLevel))))
+ {
+ DPRINT1("Returning IRQL %lx, Vector %lx for Level/Vector: %lx/%lx\n",
+ *Irql, Vector, BusInterruptLevel, BusInterruptVector);
+ DPRINT1("Old HAL would've returned IRQL %lx and Vector %lx\n",
+ VECTOR2IRQL(IRQ2VECTOR(BusInterruptLevel)),
+ IRQ2VECTOR(BusInterruptLevel));
+ }
+
+ /* Dereference the handler and return */
+ HalDereferenceBusHandler(Handler);
+ return Vector;
}
/*