Kernel: reimplement memory management on physical FCRAM (#4392)
* Kernel: reimplement memory management on physical FCRAM * Kernel/Process: Unmap does not care the source memory permission What game usually does is after mapping the memory, they reprotect the source memory as no permission to avoid modification there * Kernel/SharedMemory: zero initialize new-allocated memory * Process/Thread: zero new TLS entry * Kernel: fix a bug where code segments memory usage are accumulated twice It is added to both misc and heap (done inside HeapAlloc), which results a doubled number reported by svcGetProcessInfo. While we are on it, we just merge the three number misc, heap and linear heap usage together, as there is no where they are distinguished. Question: is TLS page also added to this number? * Kernel/SharedMemory: add more object info on mapping error * Process: lower log level; SharedMemory: store phys offset * VMManager: add helper function to retrieve backing block list for a range
This commit is contained in:
parent
f852f9f219
commit
2067946f59
19 changed files with 389 additions and 208 deletions
|
@ -23,6 +23,7 @@ namespace Memory {
|
|||
|
||||
static std::array<u8, Memory::VRAM_SIZE> vram;
|
||||
static std::array<u8, Memory::N3DS_EXTRA_RAM_SIZE> n3ds_extra_ram;
|
||||
std::array<u8, Memory::FCRAM_N3DS_SIZE> fcram;
|
||||
|
||||
static PageTable* current_page_table = nullptr;
|
||||
|
||||
|
@ -305,15 +306,7 @@ u8* GetPhysicalPointer(PAddr address) {
|
|||
target_pointer = Core::DSP().GetDspMemory().data() + offset_into_region;
|
||||
break;
|
||||
case FCRAM_PADDR:
|
||||
for (const auto& region : Core::System::GetInstance().Kernel().memory_regions) {
|
||||
if (offset_into_region >= region.base &&
|
||||
offset_into_region < region.base + region.size) {
|
||||
target_pointer =
|
||||
region.linear_heap_memory->data() + offset_into_region - region.base;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_MSG(target_pointer != nullptr, "Invalid FCRAM address");
|
||||
target_pointer = fcram.data() + offset_into_region;
|
||||
break;
|
||||
case N3DS_EXTRA_RAM_PADDR:
|
||||
target_pointer = n3ds_extra_ram.data() + offset_into_region;
|
||||
|
@ -846,4 +839,9 @@ std::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) {
|
|||
return {};
|
||||
}
|
||||
|
||||
u32 GetFCRAMOffset(u8* pointer) {
|
||||
ASSERT(pointer >= fcram.data() && pointer < fcram.data() + fcram.size());
|
||||
return pointer - fcram.data();
|
||||
}
|
||||
|
||||
} // namespace Memory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue