mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-09 18:45:40 +00:00
MMU: Coding style fixes.
This commit is contained in:
parent
ae1421b606
commit
6493ea1eb9
@ -96,20 +96,17 @@ bool IsInitialized()
|
|||||||
return m_IsInitialized;
|
return m_IsInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
MV_FAKE_VMEM = 1,
|
|
||||||
MV_WII_ONLY = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PhysicalMemoryRegion
|
struct PhysicalMemoryRegion
|
||||||
{
|
{
|
||||||
u8** out_pointer;
|
u8** out_pointer;
|
||||||
u32 physical_address;
|
u32 physical_address;
|
||||||
u32 size;
|
u32 size;
|
||||||
u32 flags;
|
enum
|
||||||
|
{
|
||||||
|
ALWAYS = 0,
|
||||||
|
FAKE_VMEM = 1,
|
||||||
|
WII_ONLY = 2,
|
||||||
|
} flags;
|
||||||
u32 shm_position;
|
u32 shm_position;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,7 +115,6 @@ struct LogicalMemoryView
|
|||||||
void* mapped_pointer;
|
void* mapped_pointer;
|
||||||
u32 mapped_size;
|
u32 mapped_size;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
// Dolphin allocates memory to represent four regions:
|
// Dolphin allocates memory to represent four regions:
|
||||||
// - 32MB RAM (actually 24MB on hardware), available on Gamecube and Wii
|
// - 32MB RAM (actually 24MB on hardware), available on Gamecube and Wii
|
||||||
@ -161,10 +157,10 @@ struct LogicalMemoryView
|
|||||||
// TODO: The actual size of RAM is REALRAM_SIZE (24MB); the other 8MB shouldn't
|
// TODO: The actual size of RAM is REALRAM_SIZE (24MB); the other 8MB shouldn't
|
||||||
// be backed by actual memory.
|
// be backed by actual memory.
|
||||||
static PhysicalMemoryRegion physical_regions[] = {
|
static PhysicalMemoryRegion physical_regions[] = {
|
||||||
{&m_pRAM, 0x00000000, RAM_SIZE, 0},
|
{&m_pRAM, 0x00000000, RAM_SIZE, PhysicalMemoryRegion::ALWAYS},
|
||||||
{&m_pL1Cache, 0xE0000000, L1_CACHE_SIZE, 0},
|
{&m_pL1Cache, 0xE0000000, L1_CACHE_SIZE, PhysicalMemoryRegion::ALWAYS},
|
||||||
{&m_pFakeVMEM, 0x7E000000, FAKEVMEM_SIZE, MV_FAKE_VMEM},
|
{&m_pFakeVMEM, 0x7E000000, FAKEVMEM_SIZE, PhysicalMemoryRegion::FAKE_VMEM},
|
||||||
{&m_pEXRAM, 0x10000000, EXRAM_SIZE, MV_WII_ONLY},
|
{&m_pEXRAM, 0x10000000, EXRAM_SIZE, PhysicalMemoryRegion::WII_ONLY},
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<LogicalMemoryView> logical_mapped_entries;
|
static std::vector<LogicalMemoryView> logical_mapped_entries;
|
||||||
@ -182,9 +178,9 @@ void Init()
|
|||||||
|
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
if (wii)
|
if (wii)
|
||||||
flags |= MV_WII_ONLY;
|
flags |= PhysicalMemoryRegion::WII_ONLY;
|
||||||
if (bFakeVMEM)
|
if (bFakeVMEM)
|
||||||
flags |= MV_FAKE_VMEM;
|
flags |= PhysicalMemoryRegion::FAKE_VMEM;
|
||||||
u32 mem_size = 0;
|
u32 mem_size = 0;
|
||||||
for (PhysicalMemoryRegion& region : physical_regions)
|
for (PhysicalMemoryRegion& region : physical_regions)
|
||||||
{
|
{
|
||||||
@ -226,22 +222,22 @@ void Init()
|
|||||||
m_IsInitialized = true;
|
m_IsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateLogicalMemory(u32* dbat_table)
|
void UpdateLogicalMemory(const PowerPC::BatTable& dbat_table)
|
||||||
{
|
{
|
||||||
for (auto& entry : logical_mapped_entries)
|
for (auto& entry : logical_mapped_entries)
|
||||||
{
|
{
|
||||||
g_arena.ReleaseView(entry.mapped_pointer, entry.mapped_size);
|
g_arena.ReleaseView(entry.mapped_pointer, entry.mapped_size);
|
||||||
}
|
}
|
||||||
logical_mapped_entries.clear();
|
logical_mapped_entries.clear();
|
||||||
for (unsigned i = 0; i < (1 << (32 - PowerPC::BAT_INDEX_SHIFT)); ++i)
|
for (u32 i = 0; i < (1 << (32 - PowerPC::BAT_INDEX_SHIFT)); ++i)
|
||||||
{
|
{
|
||||||
if (dbat_table[i] & 1)
|
if (dbat_table[i] & 1)
|
||||||
{
|
{
|
||||||
unsigned logical_address = i << PowerPC::BAT_INDEX_SHIFT;
|
u32 logical_address = i << PowerPC::BAT_INDEX_SHIFT;
|
||||||
// TODO: Merge adjacent mappings to make this faster.
|
// TODO: Merge adjacent mappings to make this faster.
|
||||||
unsigned logical_size = 1 << PowerPC::BAT_INDEX_SHIFT;
|
u32 logical_size = 1 << PowerPC::BAT_INDEX_SHIFT;
|
||||||
unsigned translated_address = dbat_table[i] & ~3;
|
u32 translated_address = dbat_table[i] & ~3;
|
||||||
for (PhysicalMemoryRegion& physical_region : physical_regions)
|
for (const auto& physical_region : physical_regions)
|
||||||
{
|
{
|
||||||
u32 mapping_address = physical_region.physical_address;
|
u32 mapping_address = physical_region.physical_address;
|
||||||
u32 mapping_end = mapping_address + physical_region.size;
|
u32 mapping_end = mapping_address + physical_region.size;
|
||||||
@ -286,9 +282,9 @@ void Shutdown()
|
|||||||
m_IsInitialized = false;
|
m_IsInitialized = false;
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
if (SConfig::GetInstance().bWii)
|
if (SConfig::GetInstance().bWii)
|
||||||
flags |= MV_WII_ONLY;
|
flags |= PhysicalMemoryRegion::WII_ONLY;
|
||||||
if (bFakeVMEM)
|
if (bFakeVMEM)
|
||||||
flags |= MV_FAKE_VMEM;
|
flags |= PhysicalMemoryRegion::FAKE_VMEM;
|
||||||
for (PhysicalMemoryRegion& region : physical_regions)
|
for (PhysicalMemoryRegion& region : physical_regions)
|
||||||
{
|
{
|
||||||
if ((flags & region.flags) != region.flags)
|
if ((flags & region.flags) != region.flags)
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "Common/CommonFuncs.h"
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
|
|
||||||
// Enable memory checks in the Debug/DebugFast builds, but NOT in release
|
// Enable memory checks in the Debug/DebugFast builds, but NOT in release
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
@ -68,7 +69,7 @@ void Init();
|
|||||||
void Shutdown();
|
void Shutdown();
|
||||||
void DoState(PointerWrap& p);
|
void DoState(PointerWrap& p);
|
||||||
|
|
||||||
void UpdateLogicalMemory(u32* dbat_table);
|
void UpdateLogicalMemory(const PowerPC::BatTable& dbat_table);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
bool AreMemoryBreakpointsActivated();
|
bool AreMemoryBreakpointsActivated();
|
||||||
|
@ -375,7 +375,7 @@ void Jit64::dcbz(UGeckoInstruction inst)
|
|||||||
// Perform lookup to see if we can use fast path.
|
// Perform lookup to see if we can use fast path.
|
||||||
MOV(32, R(RSCRATCH2), R(RSCRATCH));
|
MOV(32, R(RSCRATCH2), R(RSCRATCH));
|
||||||
SHR(32, R(RSCRATCH2), Imm8(PowerPC::BAT_INDEX_SHIFT));
|
SHR(32, R(RSCRATCH2), Imm8(PowerPC::BAT_INDEX_SHIFT));
|
||||||
TEST(32, MScaled(RSCRATCH2, SCALE_4, (u32)(u64)PowerPC::dbat_table), Imm32(2));
|
TEST(32, MScaled(RSCRATCH2, SCALE_4, (u32)(u64)&PowerPC::dbat_table[0]), Imm32(2));
|
||||||
FixupBranch slow = J_CC(CC_Z, true);
|
FixupBranch slow = J_CC(CC_Z, true);
|
||||||
|
|
||||||
// Fast path: compute full address, then zero out 32 bytes of memory.
|
// Fast path: compute full address, then zero out 32 bytes of memory.
|
||||||
|
@ -234,7 +234,7 @@ FixupBranch EmuCodeBlock::CheckIfSafeAddress(const OpArg& reg_value, X64Reg reg_
|
|||||||
|
|
||||||
// Perform lookup to see if we can use fast path.
|
// Perform lookup to see if we can use fast path.
|
||||||
SHR(32, R(scratch), Imm8(PowerPC::BAT_INDEX_SHIFT));
|
SHR(32, R(scratch), Imm8(PowerPC::BAT_INDEX_SHIFT));
|
||||||
TEST(32, MScaled(scratch, SCALE_4, (u32)(u64)PowerPC::dbat_table), Imm32(2));
|
TEST(32, MScaled(scratch, SCALE_4, (u32)(u64)&PowerPC::dbat_table[0]), Imm32(2));
|
||||||
|
|
||||||
if (scratch == reg_addr)
|
if (scratch == reg_addr)
|
||||||
POP(scratch);
|
POP(scratch);
|
||||||
|
@ -100,7 +100,7 @@ struct TranslateAddressResult
|
|||||||
PAGE_FAULT
|
PAGE_FAULT
|
||||||
} result;
|
} result;
|
||||||
u32 address;
|
u32 address;
|
||||||
bool Success() { return result <= PAGE_TABLE_TRANSLATED; }
|
bool Success() const { return result <= PAGE_TABLE_TRANSLATED; }
|
||||||
};
|
};
|
||||||
template <const XCheckTLBFlag flag>
|
template <const XCheckTLBFlag flag>
|
||||||
static TranslateAddressResult TranslateAddress(const u32 address);
|
static TranslateAddressResult TranslateAddress(const u32 address);
|
||||||
@ -155,8 +155,8 @@ static void EFB_Write(u32 data, u32 addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 dbat_table[1 << (32 - BAT_INDEX_SHIFT)];
|
BatTable ibat_table;
|
||||||
u32 ibat_table[1 << (32 - BAT_INDEX_SHIFT)];
|
BatTable dbat_table;
|
||||||
|
|
||||||
static void GenerateDSIException(u32 _EffectiveAddress, bool _bWrite);
|
static void GenerateDSIException(u32 _EffectiveAddress, bool _bWrite);
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ TryReadInstResult TryReadInstruction(u32 address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
u32 hex;
|
u32 hex;
|
||||||
// TODO: Refactor this.
|
// TODO: Refactor this. This icache implementation is totally wrong if used with the fake vmem.
|
||||||
if (Memory::bFakeVMEM && ((address & 0xFE000000) == 0x7E000000))
|
if (Memory::bFakeVMEM && ((address & 0xFE000000) == 0x7E000000))
|
||||||
{
|
{
|
||||||
hex = bswap(*(const u32*)&Memory::m_pFakeVMEM[address & Memory::FAKEVMEM_MASK]);
|
hex = bswap(*(const u32*)&Memory::m_pFakeVMEM[address & Memory::FAKEVMEM_MASK]);
|
||||||
@ -1114,7 +1114,7 @@ static __forceinline TranslateAddressResult TranslatePageAddress(const u32 addre
|
|||||||
return TranslateAddressResult{TranslateAddressResult::PAGE_FAULT, 0};
|
return TranslateAddressResult{TranslateAddressResult::PAGE_FAULT, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateBATs(u32* bat_table, u32 base_spr)
|
static void UpdateBATs(BatTable& bat_table, u32 base_spr)
|
||||||
{
|
{
|
||||||
// TODO: Separate BATs for MSR.PR==0 and MSR.PR==1
|
// TODO: Separate BATs for MSR.PR==0 and MSR.PR==1
|
||||||
// TODO: Handle PP/WIMG settings.
|
// TODO: Handle PP/WIMG settings.
|
||||||
@ -1181,9 +1181,9 @@ static void UpdateBATs(u32* bat_table, u32 base_spr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateFakeMMUBat(u32* bat_table, u32 start_addr)
|
static void UpdateFakeMMUBat(BatTable& bat_table, u32 start_addr)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < (0x10000000 >> BAT_INDEX_SHIFT); ++i)
|
for (u32 i = 0; i < (0x10000000 >> BAT_INDEX_SHIFT); ++i)
|
||||||
{
|
{
|
||||||
// Map from 0x4XXXXXXX or 0x7XXXXXXX to the range
|
// Map from 0x4XXXXXXX or 0x7XXXXXXX to the range
|
||||||
// [0x7E000000,0x80000000).
|
// [0x7E000000,0x80000000).
|
||||||
@ -1195,7 +1195,7 @@ static void UpdateFakeMMUBat(u32* bat_table, u32 start_addr)
|
|||||||
|
|
||||||
void DBATUpdated()
|
void DBATUpdated()
|
||||||
{
|
{
|
||||||
memset(dbat_table, 0, sizeof(dbat_table));
|
dbat_table = {};
|
||||||
UpdateBATs(dbat_table, SPR_DBAT0U);
|
UpdateBATs(dbat_table, SPR_DBAT0U);
|
||||||
bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE;
|
bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE;
|
||||||
if (extended_bats)
|
if (extended_bats)
|
||||||
@ -1212,7 +1212,7 @@ void DBATUpdated()
|
|||||||
|
|
||||||
void IBATUpdated()
|
void IBATUpdated()
|
||||||
{
|
{
|
||||||
memset(ibat_table, 0, sizeof(ibat_table));
|
ibat_table = {};
|
||||||
UpdateBATs(ibat_table, SPR_IBAT0U);
|
UpdateBATs(ibat_table, SPR_IBAT0U);
|
||||||
bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE;
|
bool extended_bats = SConfig::GetInstance().bWii && HID4.SBE;
|
||||||
if (extended_bats)
|
if (extended_bats)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
@ -282,12 +283,11 @@ struct TranslateResult
|
|||||||
u32 address;
|
u32 address;
|
||||||
};
|
};
|
||||||
TranslateResult JitCache_TranslateAddress(u32 address);
|
TranslateResult JitCache_TranslateAddress(u32 address);
|
||||||
enum
|
|
||||||
{
|
static const int BAT_INDEX_SHIFT = 17;
|
||||||
BAT_INDEX_SHIFT = 17
|
using BatTable = std::array<u32, 1 << (32 - BAT_INDEX_SHIFT)>; // 128 KB
|
||||||
};
|
extern BatTable ibat_table;
|
||||||
extern u32 ibat_table[];
|
extern BatTable dbat_table;
|
||||||
extern u32 dbat_table[];
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
enum CRBits
|
enum CRBits
|
||||||
|
Loading…
x
Reference in New Issue
Block a user