mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-22 16:25:39 +00:00
System: Remove redundant remap
This commit is contained in:
parent
02fbfae6a0
commit
c3bf267936
|
@ -154,7 +154,7 @@ static u8** s_fastmem_lut = nullptr;
|
||||||
|
|
||||||
static bool s_kernel_initialize_hook_run = false;
|
static bool s_kernel_initialize_hook_run = false;
|
||||||
|
|
||||||
static bool AllocateMemoryMap(Error* error);
|
static bool AllocateMemoryMap(bool export_shared_memory, Error* error);
|
||||||
static void ReleaseMemoryMap();
|
static void ReleaseMemoryMap();
|
||||||
static void SetRAMSize(bool enable_8mb_ram);
|
static void SetRAMSize(bool enable_8mb_ram);
|
||||||
|
|
||||||
|
@ -197,11 +197,14 @@ static constexpr size_t TOTAL_SIZE = LUT_OFFSET + LUT_SIZE;
|
||||||
#define FIXUP_WORD_WRITE_VALUE(size, offset, value) \
|
#define FIXUP_WORD_WRITE_VALUE(size, offset, value) \
|
||||||
((size == MemoryAccessSize::Word) ? (value) : ((value) << (((offset) & 3u) * 8)))
|
((size == MemoryAccessSize::Word) ? (value) : ((value) << (((offset) & 3u) * 8)))
|
||||||
|
|
||||||
bool Bus::AllocateMemoryMap(Error* error)
|
bool Bus::AllocateMemoryMap(bool export_shared_memory, Error* error)
|
||||||
{
|
{
|
||||||
// This executes super early in process startup, therefore export_shared_memory will always be false.
|
INFO_LOG("Allocating{} shared memory map.", export_shared_memory ? " EXPORTED" : "");
|
||||||
if (g_settings.export_shared_memory)
|
if (export_shared_memory)
|
||||||
|
{
|
||||||
s_shmem_name = MemMap::GetFileMappingName("duckstation");
|
s_shmem_name = MemMap::GetFileMappingName("duckstation");
|
||||||
|
INFO_LOG("Shared memory object name is \"{}\".", s_shmem_name);
|
||||||
|
}
|
||||||
s_shmem_handle = MemMap::CreateSharedMemory(s_shmem_name.c_str(), MemoryMap::TOTAL_SIZE, error);
|
s_shmem_handle = MemMap::CreateSharedMemory(s_shmem_name.c_str(), MemoryMap::TOTAL_SIZE, error);
|
||||||
if (!s_shmem_handle)
|
if (!s_shmem_handle)
|
||||||
{
|
{
|
||||||
|
@ -304,9 +307,9 @@ void Bus::ReleaseMemoryMap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bus::AllocateMemory(Error* error)
|
bool Bus::AllocateMemory(bool export_shared_memory, Error* error)
|
||||||
{
|
{
|
||||||
if (!AllocateMemoryMap(error))
|
if (!AllocateMemoryMap(export_shared_memory, error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef ENABLE_MMAP_FASTMEM
|
#ifdef ENABLE_MMAP_FASTMEM
|
||||||
|
@ -336,7 +339,7 @@ void Bus::ReleaseMemory()
|
||||||
ReleaseMemoryMap();
|
ReleaseMemoryMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bus::ReallocateMemoryMap(Error* error)
|
bool Bus::ReallocateMemoryMap(bool export_shared_memory, Error* error)
|
||||||
{
|
{
|
||||||
// Need to back up RAM+BIOS.
|
// Need to back up RAM+BIOS.
|
||||||
DynamicHeapArray<u8> ram_backup;
|
DynamicHeapArray<u8> ram_backup;
|
||||||
|
@ -354,7 +357,7 @@ bool Bus::ReallocateMemoryMap(Error* error)
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseMemoryMap();
|
ReleaseMemoryMap();
|
||||||
if (!AllocateMemoryMap(error)) [[unlikely]]
|
if (!AllocateMemoryMap(export_shared_memory, error)) [[unlikely]]
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (System::IsValid())
|
if (System::IsValid())
|
||||||
|
|
|
@ -113,12 +113,12 @@ enum : u32
|
||||||
static constexpr size_t FASTMEM_ARENA_SIZE = UINT64_C(0x100000000);
|
static constexpr size_t FASTMEM_ARENA_SIZE = UINT64_C(0x100000000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool AllocateMemory(Error* error);
|
bool AllocateMemory(bool export_shared_memory, Error* error);
|
||||||
void ReleaseMemory();
|
void ReleaseMemory();
|
||||||
|
|
||||||
/// Frees and re-allocates the memory map for the process.
|
/// Frees and re-allocates the memory map for the process.
|
||||||
/// This should be called when shared memory exports are enabled.
|
/// This should be called when shared memory exports are enabled.
|
||||||
bool ReallocateMemoryMap(Error* error);
|
bool ReallocateMemoryMap(bool export_shared_memory, Error* error);
|
||||||
|
|
||||||
/// Cleans up/deletes the shared memory object for this process.
|
/// Cleans up/deletes the shared memory object for this process.
|
||||||
/// Should be called when the process crashes, to avoid leaking.
|
/// Should be called when the process crashes, to avoid leaking.
|
||||||
|
|
|
@ -712,6 +712,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
|
||||||
Host::OSD_WARNING_DURATION);
|
Host::OSD_WARNING_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef APPEND_MESSAGE_FMT
|
||||||
#undef APPEND_MESSAGE
|
#undef APPEND_MESSAGE
|
||||||
|
|
||||||
#define BIT_FOR(ctype) (static_cast<u16>(1) << static_cast<u32>(ctype))
|
#define BIT_FOR(ctype) (static_cast<u16>(1) << static_cast<u32>(ctype))
|
||||||
|
|
|
@ -402,8 +402,11 @@ bool System::Internal::ProcessStartup(Error* error)
|
||||||
if (!CPU::CodeCache::ProcessStartup(error))
|
if (!CPU::CodeCache::ProcessStartup(error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// g_settings is not valid at this point, query global config directly.
|
||||||
|
const bool export_shared_memory = Host::GetBoolSettingValue("Hacks", "ExportSharedMemory", false);
|
||||||
|
|
||||||
// Fastmem alloc *must* come after JIT alloc, otherwise it tends to eat the 4GB region after the executable on MacOS.
|
// Fastmem alloc *must* come after JIT alloc, otherwise it tends to eat the 4GB region after the executable on MacOS.
|
||||||
if (!Bus::AllocateMemory(error))
|
if (!Bus::AllocateMemory(export_shared_memory, error))
|
||||||
{
|
{
|
||||||
CPU::CodeCache::ProcessShutdown();
|
CPU::CodeCache::ProcessShutdown();
|
||||||
return false;
|
return false;
|
||||||
|
@ -439,13 +442,6 @@ bool System::Internal::CPUThreadInitialize(Error* error)
|
||||||
// This will call back to Host::LoadSettings() -> ReloadSources().
|
// This will call back to Host::LoadSettings() -> ReloadSources().
|
||||||
LoadSettings(false);
|
LoadSettings(false);
|
||||||
|
|
||||||
// Yuckity yuck. We have to test for memory export explicitly, because the allocation happens before config load.
|
|
||||||
if (g_settings.export_shared_memory && !Bus::ReallocateMemoryMap(error))
|
|
||||||
{
|
|
||||||
Error::AddPrefix(error, "Failed to reallocate memory map:\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_RAINTEGRATION
|
#ifdef ENABLE_RAINTEGRATION
|
||||||
if (Host::GetBaseBoolSettingValue("Cheevos", "UseRAIntegration", false))
|
if (Host::GetBaseBoolSettingValue("Cheevos", "UseRAIntegration", false))
|
||||||
Achievements::SwitchToRAIntegration();
|
Achievements::SwitchToRAIntegration();
|
||||||
|
@ -4367,7 +4363,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
|
||||||
if (g_settings.export_shared_memory != old_settings.export_shared_memory) [[unlikely]]
|
if (g_settings.export_shared_memory != old_settings.export_shared_memory) [[unlikely]]
|
||||||
{
|
{
|
||||||
Error error;
|
Error error;
|
||||||
if (!Bus::ReallocateMemoryMap(&error)) [[unlikely]]
|
if (!Bus::ReallocateMemoryMap(g_settings.export_shared_memory, &error)) [[unlikely]]
|
||||||
{
|
{
|
||||||
ERROR_LOG(error.GetDescription());
|
ERROR_LOG(error.GetDescription());
|
||||||
Panic("Failed to reallocate memory map. The log may contain more information.");
|
Panic("Failed to reallocate memory map. The log may contain more information.");
|
||||||
|
|
Loading…
Reference in a new issue