mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 16:49:58 -06:00
Configurable MEM1 and MEM2 sizes at runtime via Dolphin.ini
Changed several enums from Memmap.h to be static vars and implemented Get functions to query them. This seems to have boosted speed a bit in some titles? The new variables and some previously statically initialized items are now initialized via Memory::Init() and the new AddressSpace::Init(). s_ram_size_real and the new s_exram_size_real in particular are initialized from new OnionConfig values "MAIN_MEM1_SIZE" and "MAIN_MEM2_SIZE", only if "MAIN_RAM_OVERRIDE_ENABLE" is true. GUI features have been added to Config > Advanced to adjust the new OnionConfig values. A check has been added to State::doState to ensure savestates with memory configurations different from the current settings aren't loaded. The STATE_VERSION is now 115. FIFO Files have been updated from version 4 to version 5, now including the MEM1 and MEM2 sizes from the time of DFF creation. FIFO Logs not using the new features (OnionConfig MAIN_RAM_OVERRIDE_ENABLE is false) are still backwards compatible. FIFO Logs that do use the new features have a MIN_LOADER_VERSION of 5. Thanks to the order of function calls, FIFO logs are able to automatically configure the new OnionConfig settings to match what is needed. This is a bit hacky, though, so I also threw in a failsafe for if the conditions that allow this to work ever go away. I took the liberty of adding a log message to explain why the core fails to initialize if the MIN_LOADER_VERSION is too great. Some IOS code has had the function "RAMOverrideForIOSMemoryValues" appended to it to recalculate IOS Memory Values from retail IOSes/apploaders to fit the extended memory sizes. Worry not, if MAIN_RAM_OVERRIDE_ENABLE is false, this function does absolutely nothing. A hotfix in DolphinQt/MenuBar.cpp has been implemented for RAM Override.
This commit is contained in:
@ -211,14 +211,14 @@ static T ReadFromHardware(u32 em_address)
|
||||
{
|
||||
// Handle RAM; the masking intentionally discards bits (essentially creating
|
||||
// mirrors of memory).
|
||||
// TODO: Only the first REALRAM_SIZE is supposed to be backed by actual memory.
|
||||
// TODO: Only the first GetRamSizeReal() is supposed to be backed by actual memory.
|
||||
T value;
|
||||
std::memcpy(&value, &Memory::m_pRAM[em_address & Memory::RAM_MASK], sizeof(T));
|
||||
std::memcpy(&value, &Memory::m_pRAM[em_address & Memory::GetRamMask()], sizeof(T));
|
||||
return bswap(value);
|
||||
}
|
||||
|
||||
if (Memory::m_pEXRAM && (em_address >> 28) == 0x1 &&
|
||||
(em_address & 0x0FFFFFFF) < Memory::EXRAM_SIZE)
|
||||
(em_address & 0x0FFFFFFF) < Memory::GetExRamSizeReal())
|
||||
{
|
||||
T value;
|
||||
std::memcpy(&value, &Memory::m_pEXRAM[em_address & 0x0FFFFFFF], sizeof(T));
|
||||
@ -226,7 +226,7 @@ static T ReadFromHardware(u32 em_address)
|
||||
}
|
||||
|
||||
// Locked L1 technically doesn't have a fixed address, but games all use 0xE0000000.
|
||||
if ((em_address >> 28) == 0xE && (em_address < (0xE0000000 + Memory::L1_CACHE_SIZE)))
|
||||
if ((em_address >> 28) == 0xE && (em_address < (0xE0000000 + Memory::GetL1CacheSize())))
|
||||
{
|
||||
T value;
|
||||
std::memcpy(&value, &Memory::m_pL1Cache[em_address & 0x0FFFFFFF], sizeof(T));
|
||||
@ -238,7 +238,7 @@ static T ReadFromHardware(u32 em_address)
|
||||
if (Memory::m_pFakeVMEM && ((em_address & 0xFE000000) == 0x7E000000))
|
||||
{
|
||||
T value;
|
||||
std::memcpy(&value, &Memory::m_pFakeVMEM[em_address & Memory::RAM_MASK], sizeof(T));
|
||||
std::memcpy(&value, &Memory::m_pFakeVMEM[em_address & Memory::GetRamMask()], sizeof(T));
|
||||
return bswap(value);
|
||||
}
|
||||
|
||||
@ -300,14 +300,14 @@ static void WriteToHardware(u32 em_address, const T data)
|
||||
{
|
||||
// Handle RAM; the masking intentionally discards bits (essentially creating
|
||||
// mirrors of memory).
|
||||
// TODO: Only the first REALRAM_SIZE is supposed to be backed by actual memory.
|
||||
// TODO: Only the first GetRamSizeReal() is supposed to be backed by actual memory.
|
||||
const T swapped_data = bswap(data);
|
||||
std::memcpy(&Memory::m_pRAM[em_address & Memory::RAM_MASK], &swapped_data, sizeof(T));
|
||||
std::memcpy(&Memory::m_pRAM[em_address & Memory::GetRamMask()], &swapped_data, sizeof(T));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Memory::m_pEXRAM && (em_address >> 28) == 0x1 &&
|
||||
(em_address & 0x0FFFFFFF) < Memory::EXRAM_SIZE)
|
||||
(em_address & 0x0FFFFFFF) < Memory::GetExRamSizeReal())
|
||||
{
|
||||
const T swapped_data = bswap(data);
|
||||
std::memcpy(&Memory::m_pEXRAM[em_address & 0x0FFFFFFF], &swapped_data, sizeof(T));
|
||||
@ -315,7 +315,7 @@ static void WriteToHardware(u32 em_address, const T data)
|
||||
}
|
||||
|
||||
// Locked L1 technically doesn't have a fixed address, but games all use 0xE0000000.
|
||||
if ((em_address >> 28 == 0xE) && (em_address < (0xE0000000 + Memory::L1_CACHE_SIZE)))
|
||||
if ((em_address >> 28 == 0xE) && (em_address < (0xE0000000 + Memory::GetL1CacheSize())))
|
||||
{
|
||||
const T swapped_data = bswap(data);
|
||||
std::memcpy(&Memory::m_pL1Cache[em_address & 0x0FFFFFFF], &swapped_data, sizeof(T));
|
||||
@ -328,7 +328,7 @@ static void WriteToHardware(u32 em_address, const T data)
|
||||
if (Memory::m_pFakeVMEM && ((em_address & 0xFE000000) == 0x7E000000))
|
||||
{
|
||||
const T swapped_data = bswap(data);
|
||||
std::memcpy(&Memory::m_pFakeVMEM[em_address & Memory::RAM_MASK], &swapped_data, sizeof(T));
|
||||
std::memcpy(&Memory::m_pFakeVMEM[em_address & Memory::GetRamMask()], &swapped_data, sizeof(T));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ TryReadInstResult TryReadInstruction(u32 address)
|
||||
// TODO: Refactor this. This icache implementation is totally wrong if used with the fake vmem.
|
||||
if (Memory::m_pFakeVMEM && ((address & 0xFE000000) == 0x7E000000))
|
||||
{
|
||||
hex = Common::swap32(&Memory::m_pFakeVMEM[address & Memory::FAKEVMEM_MASK]);
|
||||
hex = Common::swap32(&Memory::m_pFakeVMEM[address & Memory::GetFakeVMemMask()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -667,13 +667,14 @@ static bool IsRAMAddress(u32 address, bool translate)
|
||||
}
|
||||
|
||||
u32 segment = address >> 28;
|
||||
if (segment == 0x0 && (address & 0x0FFFFFFF) < Memory::REALRAM_SIZE)
|
||||
if (segment == 0x0 && (address & 0x0FFFFFFF) < Memory::GetRamSizeReal())
|
||||
return true;
|
||||
else if (Memory::m_pEXRAM && segment == 0x1 && (address & 0x0FFFFFFF) < Memory::EXRAM_SIZE)
|
||||
else if (Memory::m_pEXRAM && segment == 0x1 &&
|
||||
(address & 0x0FFFFFFF) < Memory::GetExRamSizeReal())
|
||||
return true;
|
||||
else if (Memory::m_pFakeVMEM && ((address & 0xFE000000) == 0x7E000000))
|
||||
return true;
|
||||
else if (segment == 0xE && (address < (0xE0000000 + Memory::L1_CACHE_SIZE)))
|
||||
else if (segment == 0xE && (address < (0xE0000000 + Memory::GetL1CacheSize())))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -1212,13 +1213,13 @@ static void UpdateBATs(BatTable& bat_table, u32 base_spr)
|
||||
u32 valid_bit = BAT_MAPPED_BIT;
|
||||
if (Memory::m_pFakeVMEM && (physical_address & 0xFE000000) == 0x7E000000)
|
||||
valid_bit |= BAT_PHYSICAL_BIT;
|
||||
else if (physical_address < Memory::REALRAM_SIZE)
|
||||
else if (physical_address < Memory::GetRamSizeReal())
|
||||
valid_bit |= BAT_PHYSICAL_BIT;
|
||||
else if (Memory::m_pEXRAM && physical_address >> 28 == 0x1 &&
|
||||
(physical_address & 0x0FFFFFFF) < Memory::EXRAM_SIZE)
|
||||
(physical_address & 0x0FFFFFFF) < Memory::GetExRamSizeReal())
|
||||
valid_bit |= BAT_PHYSICAL_BIT;
|
||||
else if (physical_address >> 28 == 0xE &&
|
||||
physical_address < 0xE0000000 + Memory::L1_CACHE_SIZE)
|
||||
physical_address < 0xE0000000 + Memory::GetL1CacheSize())
|
||||
valid_bit |= BAT_PHYSICAL_BIT;
|
||||
|
||||
// Fastmem doesn't support memchecks, so disable it for all overlapping virtual pages.
|
||||
@ -1239,7 +1240,7 @@ static void UpdateFakeMMUBat(BatTable& bat_table, u32 start_addr)
|
||||
// Map from 0x4XXXXXXX or 0x7XXXXXXX to the range
|
||||
// [0x7E000000,0x80000000).
|
||||
u32 e_address = i + (start_addr >> BAT_INDEX_SHIFT);
|
||||
u32 p_address = 0x7E000000 | (i << BAT_INDEX_SHIFT & Memory::FAKEVMEM_MASK);
|
||||
u32 p_address = 0x7E000000 | (i << BAT_INDEX_SHIFT & Memory::GetFakeVMemMask());
|
||||
u32 flags = BAT_MAPPED_BIT | BAT_PHYSICAL_BIT;
|
||||
|
||||
if (PowerPC::memchecks.OverlapsMemcheck(e_address << BAT_INDEX_SHIFT, BAT_PAGE_SIZE))
|
||||
|
Reference in New Issue
Block a user