summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorCamilleLaVey <camillelavey@citron-emu.org>2025-03-05 00:25:31 -0400
committerCamilleLaVey <camillelavey@citron-emu.org>2025-03-05 00:25:31 -0400
commit6565055865688ba316801d99a3c3a5a0300cad5d (patch)
treedc5221234a3bdecb1bf7cc6841ecdd2bbfd0c44c /src/core/memory.cpp
parentee3d858935600e23a7914620b21f45082cccf8bd (diff)
Fix: Core_Memory logging and ARM_NCE Mutex logging
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index dd6ffaf6c..b32071899 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -27,6 +27,7 @@
#include "video_core/host1x/gpu_device_memory_manager.h"
#include "video_core/host1x/host1x.h"
#include "video_core/rasterizer_download_area.h"
+#include "core/arm/nce/arm_nce.h"
namespace Core::Memory {
@@ -1151,7 +1152,7 @@ bool Memory::InvalidateSeparateHeap(void* fault_address) {
#endif
}
-bool Memory::Remap(u64 guest_addr, u32 size) {
+bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) {
// Unmap the old address
UnmapRegion(*impl->current_page_table, guest_addr, size, false);
@@ -1161,7 +1162,7 @@ bool Memory::Remap(u64 guest_addr, u32 size) {
// Allocate new memory
void* new_memory = std::malloc(size);
if (!new_memory) {
- LOG_ERROR(Core_Memory, "Failed to allocate new memory for remapping address {:X}", guest_addr);
+ LOG_ERROR(Core_ARM, "Failed to allocate new memory for remapping address {:X}", guest_addr);
return false;
}
@@ -1170,7 +1171,7 @@ bool Memory::Remap(u64 guest_addr, u32 size) {
// Verify the mapping
if (GetPointer(guest_addr) != nullptr) {
- LOG_INFO(Core_Memory, "Successfully remapped address {:X}", guest_addr);
+ LOG_INFO(Core_ARM, "Successfully remapped address {:X}", guest_addr);
return true;
} else {
LOG_ERROR(Core_Memory, "Failed to remap address {:X}", guest_addr);
@@ -1179,10 +1180,12 @@ bool Memory::Remap(u64 guest_addr, u32 size) {
}
}
-void Memory::ReclaimUnusedMemory() {
- std::lock_guard lock(m_tlb_mutex);
+void Memory::ReclaimUnusedMemory(ArmNce& arm_nce) {
+ std::lock_guard<std::mutex> lock(arm_nce.m_tlb_mutex); // Correct usage of lock_guard
- for (auto& entry : m_tlb) {
+ 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);
@@ -1191,7 +1194,7 @@ void Memory::ReclaimUnusedMemory() {
std::free(reinterpret_cast<void*>(entry.host_addr));
// 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);
}