Skip to content

Commit

Permalink
Merge pull request #6968 from lioncash/mmu
Browse files Browse the repository at this point in the history
MMU: Normalize parameter naming
  • Loading branch information
leoetlino committed May 26, 2018
2 parents 41fe797 + 5d42f31 commit f64cbc8
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions Source/Core/Core/PowerPC/MMU.cpp
Expand Up @@ -164,7 +164,7 @@ static void EFB_Write(u32 data, u32 addr)
BatTable ibat_table;
BatTable dbat_table;

static void GenerateDSIException(u32 _EffectiveAddress, bool _bWrite);
static void GenerateDSIException(u32 effective_address, bool write);

template <XCheckTLBFlag flag, typename T, bool never_translate = false>
static T ReadFromHardware(u32 em_address)
Expand Down Expand Up @@ -689,76 +689,76 @@ bool HostIsInstructionRAMAddress(u32 address)
return !(address & 3) && IsRAMAddress<XCheckTLBFlag::OpcodeNoException>(address, MSR.IR);
}

void DMA_LCToMemory(const u32 memAddr, const u32 cacheAddr, const u32 numBlocks)
void DMA_LCToMemory(const u32 mem_address, const u32 cache_address, const u32 num_blocks)
{
// TODO: It's not completely clear this is the right spot for this code;
// what would happen if, for example, the DVD drive tried to write to the EFB?
// TODO: This is terribly slow.
// TODO: Refactor.
// Avatar: The Last Airbender (GC) uses this for videos.
if ((memAddr & 0x0F000000) == 0x08000000)
if ((mem_address & 0x0F000000) == 0x08000000)
{
for (u32 i = 0; i < 32 * numBlocks; i += 4)
for (u32 i = 0; i < 32 * num_blocks; i += 4)
{
const u32 data = Common::swap32(Memory::m_pL1Cache + ((cacheAddr + i) & 0x3FFFF));
EFB_Write(data, memAddr + i);
const u32 data = Common::swap32(Memory::m_pL1Cache + ((cache_address + i) & 0x3FFFF));
EFB_Write(data, mem_address + i);
}
return;
}

// No known game uses this; here for completeness.
// TODO: Refactor.
if ((memAddr & 0x0F000000) == 0x0C000000)
if ((mem_address & 0x0F000000) == 0x0C000000)
{
for (u32 i = 0; i < 32 * numBlocks; i += 4)
for (u32 i = 0; i < 32 * num_blocks; i += 4)
{
const u32 data = Common::swap32(Memory::m_pL1Cache + ((cacheAddr + i) & 0x3FFFF));
Memory::mmio_mapping->Write(memAddr + i, data);
const u32 data = Common::swap32(Memory::m_pL1Cache + ((cache_address + i) & 0x3FFFF));
Memory::mmio_mapping->Write(mem_address + i, data);
}
return;
}

const u8* src = Memory::m_pL1Cache + (cacheAddr & 0x3FFFF);
u8* dst = Memory::GetPointer(memAddr);
const u8* src = Memory::m_pL1Cache + (cache_address & 0x3FFFF);
u8* dst = Memory::GetPointer(mem_address);
if (dst == nullptr)
return;

memcpy(dst, src, 32 * numBlocks);
memcpy(dst, src, 32 * num_blocks);
}

void DMA_MemoryToLC(const u32 cacheAddr, const u32 memAddr, const u32 numBlocks)
void DMA_MemoryToLC(const u32 cache_address, const u32 mem_address, const u32 num_blocks)
{
const u8* src = Memory::GetPointer(memAddr);
u8* dst = Memory::m_pL1Cache + (cacheAddr & 0x3FFFF);
const u8* src = Memory::GetPointer(mem_address);
u8* dst = Memory::m_pL1Cache + (cache_address & 0x3FFFF);

// No known game uses this; here for completeness.
// TODO: Refactor.
if ((memAddr & 0x0F000000) == 0x08000000)
if ((mem_address & 0x0F000000) == 0x08000000)
{
for (u32 i = 0; i < 32 * numBlocks; i += 4)
for (u32 i = 0; i < 32 * num_blocks; i += 4)
{
const u32 data = Common::swap32(EFB_Read(memAddr + i));
std::memcpy(Memory::m_pL1Cache + ((cacheAddr + i) & 0x3FFFF), &data, sizeof(u32));
const u32 data = Common::swap32(EFB_Read(mem_address + i));
std::memcpy(Memory::m_pL1Cache + ((cache_address + i) & 0x3FFFF), &data, sizeof(u32));
}
return;
}

// No known game uses this.
// TODO: Refactor.
if ((memAddr & 0x0F000000) == 0x0C000000)
if ((mem_address & 0x0F000000) == 0x0C000000)
{
for (u32 i = 0; i < 32 * numBlocks; i += 4)
for (u32 i = 0; i < 32 * num_blocks; i += 4)
{
const u32 data = Common::swap32(Memory::mmio_mapping->Read<u32>(memAddr + i));
std::memcpy(Memory::m_pL1Cache + ((cacheAddr + i) & 0x3FFFF), &data, sizeof(u32));
const u32 data = Common::swap32(Memory::mmio_mapping->Read<u32>(mem_address + i));
std::memcpy(Memory::m_pL1Cache + ((cache_address + i) & 0x3FFFF), &data, sizeof(u32));
}
return;
}

if (src == nullptr)
return;

memcpy(dst, src, 32 * numBlocks);
memcpy(dst, src, 32 * num_blocks);
}

void ClearCacheLine(u32 address)
Expand Down Expand Up @@ -789,7 +789,7 @@ void ClearCacheLine(u32 address)
WriteToHardware<XCheckTLBFlag::Write, u64, true>(address + i, 0);
}

u32 IsOptimizableMMIOAccess(u32 address, u32 accessSize)
u32 IsOptimizableMMIOAccess(u32 address, u32 access_size)
{
if (PowerPC::memchecks.HasAny())
return 0;
Expand All @@ -804,7 +804,7 @@ u32 IsOptimizableMMIOAccess(u32 address, u32 accessSize)
return 0;

// Check whether the address is an aligned address of an MMIO register.
bool aligned = (address & ((accessSize >> 3) - 1)) == 0;
const bool aligned = (address & ((access_size >> 3) - 1)) == 0;
if (!aligned || !MMIO::IsMMIOAddress(address))
return 0;

Expand Down Expand Up @@ -937,30 +937,30 @@ union UPTE2
u32 Hex;
};

static void GenerateDSIException(u32 effectiveAddress, bool write)
static void GenerateDSIException(u32 effective_address, bool write)
{
// DSI exceptions are only supported in MMU mode.
if (!SConfig::GetInstance().bMMU)
{
PanicAlert("Invalid %s 0x%08x, PC = 0x%08x ", write ? "write to" : "read from",
effectiveAddress, PC);
effective_address, PC);
return;
}

if (effectiveAddress)
if (effective_address)
PowerPC::ppcState.spr[SPR_DSISR] = PPC_EXC_DSISR_PAGE | PPC_EXC_DSISR_STORE;
else
PowerPC::ppcState.spr[SPR_DSISR] = PPC_EXC_DSISR_PAGE;

PowerPC::ppcState.spr[SPR_DAR] = effectiveAddress;
PowerPC::ppcState.spr[SPR_DAR] = effective_address;

PowerPC::ppcState.Exceptions |= EXCEPTION_DSI;
}

static void GenerateISIException(u32 _EffectiveAddress)
static void GenerateISIException(u32 effective_address)
{
// Address of instruction could not be translated
NPC = _EffectiveAddress;
NPC = effective_address;

PowerPC::ppcState.Exceptions |= EXCEPTION_ISI;
WARN_LOG(POWERPC, "ISI exception at 0x%08x", PC);
Expand Down

0 comments on commit f64cbc8

Please sign in to comment.