mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-03-15 03:14:50 +00:00
parent
c304afe2b3
commit
4491127f52
3 changed files with 3 additions and 59 deletions
|
@ -1183,9 +1183,9 @@ bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) {
|
||||||
void Memory::ReclaimUnusedMemory(ArmNce& arm_nce) {
|
void Memory::ReclaimUnusedMemory(ArmNce& arm_nce) {
|
||||||
std::lock_guard<std::mutex> lock(arm_nce.m_tlb_mutex); // Correct usage of lock_guard
|
std::lock_guard<std::mutex> lock(arm_nce.m_tlb_mutex); // Correct usage of lock_guard
|
||||||
|
|
||||||
auto& tlb_entries = arm_nce.GetTlbEntries();
|
const auto& tlb_entries = arm_nce.GetTlbEntries();
|
||||||
|
|
||||||
for (auto& entry : tlb_entries) {
|
for (const auto& entry : tlb_entries) {
|
||||||
if (entry.valid && entry.ref_count == 0) {
|
if (entry.valid && entry.ref_count == 0) {
|
||||||
// Unmap the memory region
|
// Unmap the memory region
|
||||||
UnmapRegion(*impl->current_page_table, entry.guest_addr, entry.size, false);
|
UnmapRegion(*impl->current_page_table, entry.guest_addr, entry.size, false);
|
||||||
|
@ -1194,7 +1194,7 @@ void Memory::ReclaimUnusedMemory(ArmNce& arm_nce) {
|
||||||
std::free(reinterpret_cast<void*>(entry.host_addr));
|
std::free(reinterpret_cast<void*>(entry.host_addr));
|
||||||
|
|
||||||
// Invalidate the TLB entry
|
// Invalidate the TLB entry
|
||||||
entry.valid = false;
|
const_cast<TlbEntry&>(entry).valid = false;
|
||||||
|
|
||||||
LOG_INFO(Core_Memory, "Reclaimed memory for address {:X}", entry.guest_addr);
|
LOG_INFO(Core_Memory, "Reclaimed memory for address {:X}", entry.guest_addr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "common/typed_address.h"
|
#include "common/typed_address.h"
|
||||||
#include "core/guest_memory.h"
|
#include "core/guest_memory.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/arm/nce/arm_nce.h" // Include ArmNce header
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
enum class MemoryPermission : u32;
|
enum class MemoryPermission : u32;
|
||||||
|
@ -53,17 +52,6 @@ enum : u64 {
|
||||||
DEFAULT_STACK_SIZE = 0x100000,
|
DEFAULT_STACK_SIZE = 0x100000,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TlbEntry {
|
|
||||||
u64 guest_addr;
|
|
||||||
u64 host_addr;
|
|
||||||
u32 size;
|
|
||||||
bool valid;
|
|
||||||
bool writable;
|
|
||||||
u32 access_count;
|
|
||||||
std::chrono::steady_clock::time_point last_access_time;
|
|
||||||
u32 ref_count= 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Central class that handles all memory operations and state.
|
/// Central class that handles all memory operations and state.
|
||||||
class Memory {
|
class Memory {
|
||||||
public:
|
public:
|
||||||
|
@ -514,29 +502,11 @@ public:
|
||||||
*/
|
*/
|
||||||
bool Remap(u64 guest_addr, u32 size);
|
bool Remap(u64 guest_addr, u32 size);
|
||||||
|
|
||||||
/**
|
|
||||||
* Remaps a region of the emulated process address space.
|
|
||||||
*
|
|
||||||
* @param guest_addr The address to begin remapping at.
|
|
||||||
* @param size The amount of bytes to remap.
|
|
||||||
* @param arm_nce The ArmNce instance to use for TLB entries.
|
|
||||||
*
|
|
||||||
* @returns True if remapping is successful, false otherwise.
|
|
||||||
*/
|
|
||||||
bool Remap(u64 guest_addr, u32 size, ArmNce& arm_nce);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reclaims memory from pages that are no longer used.
|
* Reclaims memory from pages that are no longer used.
|
||||||
*/
|
*/
|
||||||
void ReclaimUnusedMemory();
|
void ReclaimUnusedMemory();
|
||||||
|
|
||||||
/**
|
|
||||||
* Reclaims memory from pages that are no longer used.
|
|
||||||
*
|
|
||||||
* @param arm_nce The ArmNce instance to use for TLB entries.
|
|
||||||
*/
|
|
||||||
void ReclaimUnusedMemory(ArmNce& arm_nce);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "video_core/memory_manager.h"
|
#include "video_core/memory_manager.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "video_core/rasterizer_interface.h"
|
||||||
#include "video_core/renderer_base.h"
|
#include "video_core/renderer_base.h"
|
||||||
#include "core/arm/nce/arm_nce.h"
|
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
using Tegra::Memory::GuestMemoryFlags;
|
using Tegra::Memory::GuestMemoryFlags;
|
||||||
|
@ -786,28 +785,3 @@ u8* MemoryManager::GetSpan(const GPUVAddr src_addr, const std::size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Tegra
|
} // namespace Tegra
|
||||||
|
|
||||||
namespace Core::Memory {
|
|
||||||
|
|
||||||
void Memory::ReclaimUnusedMemory(ArmNce& arm_nce) {
|
|
||||||
std::lock_guard<std::mutex> lock(arm_nce.m_tlb_mutex); // Correct usage of lock_guard
|
|
||||||
|
|
||||||
const auto& tlb_entries = arm_nce.GetTlbEntries();
|
|
||||||
|
|
||||||
for (const auto& entry : tlb_entries) {
|
|
||||||
if (entry.valid && entry.ref_count == 0) {
|
|
||||||
// Unmap the memory region
|
|
||||||
UnmapRegion(*impl->current_page_table, entry.guest_addr, entry.size, false);
|
|
||||||
|
|
||||||
// Free the memory
|
|
||||||
std::free(reinterpret_cast<void*>(entry.host_addr));
|
|
||||||
|
|
||||||
// Invalidate the TLB entry
|
|
||||||
const_cast<TlbEntry&>(entry).valid = false;
|
|
||||||
|
|
||||||
LOG_INFO(Core_Memory, "Reclaimed memory for address {:X}", entry.guest_addr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Core::Memory
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue