mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 11:16:11 +00:00
[HAL]: Implement system bus address translation.
svn path=/trunk/; revision=47677
This commit is contained in:
parent
7ebba8b83c
commit
fc0a9b1bef
1 changed files with 83 additions and 2 deletions
|
@ -24,8 +24,89 @@ HalpTranslateSystemBusAddress(IN PBUS_HANDLER BusHandler,
|
||||||
IN OUT PULONG AddressSpace,
|
IN OUT PULONG AddressSpace,
|
||||||
OUT PPHYSICAL_ADDRESS TranslatedAddress)
|
OUT PPHYSICAL_ADDRESS TranslatedAddress)
|
||||||
{
|
{
|
||||||
DPRINT1("SYSTEM Translate\n");
|
PSUPPORTED_RANGE Range = NULL;
|
||||||
while (TRUE);
|
|
||||||
|
/* 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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue