mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-28 18:12:44 -06:00
Kernel, APT: SharedFont/SharedMemoryOnSharedDevice should always use old linear heap VAddr
This commit is contained in:
parent
1444d60109
commit
8c65433ab5
2 changed files with 15 additions and 5 deletions
|
@ -142,7 +142,10 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
|
||||||
|
|
||||||
if (base_address == 0 && target_address == 0) {
|
if (base_address == 0 && target_address == 0) {
|
||||||
// Calculate the address at which to map the memory block.
|
// Calculate the address at which to map the memory block.
|
||||||
target_address = linear_heap_phys_offset + target_process->GetLinearHeapAreaAddress();
|
// Note: even on new firmware versions, the target address is still in the old linear heap
|
||||||
|
// region. This exception is made to keep the shared font compatibility. See
|
||||||
|
// APT:GetSharedFont for detail.
|
||||||
|
target_address = linear_heap_phys_offset + Memory::LINEAR_HEAP_VADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vma = target_process->vm_manager.FindVMA(target_address);
|
auto vma = target_process->vm_manager.FindVMA(target_address);
|
||||||
|
|
|
@ -207,10 +207,17 @@ void Module::Interface::GetSharedFont(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
||||||
// The shared font has to be relocated to the new address before being passed to the
|
// The shared font has to be relocated to the new address before being passed to the
|
||||||
// application.
|
// application.
|
||||||
auto maybe_vaddr = Memory::PhysicalToVirtualAddress(
|
|
||||||
apt->shared_font_mem->linear_heap_phys_offset + Memory::FCRAM_PADDR);
|
// Note: the target address is still in the old linear heap region even on new firmware
|
||||||
ASSERT(maybe_vaddr);
|
// versions. This exception is made for shared font to resolve the following compatibility
|
||||||
VAddr target_address = *maybe_vaddr;
|
// issue:
|
||||||
|
// The linear heap region changes depending on the kernel version marked in application's
|
||||||
|
// exheader (not the actual version the application is running on). If an application with old
|
||||||
|
// kernel version and an applet with new kernel version run at the same time, and they both use
|
||||||
|
// shared font, different linear heap region would have required shared font to relocate
|
||||||
|
// according to two different addresses at the same time, which is impossible.
|
||||||
|
VAddr target_address =
|
||||||
|
apt->shared_font_mem->linear_heap_phys_offset + Memory::LINEAR_HEAP_VADDR;
|
||||||
if (!apt->shared_font_relocated) {
|
if (!apt->shared_font_relocated) {
|
||||||
BCFNT::RelocateSharedFont(apt->shared_font_mem, target_address);
|
BCFNT::RelocateSharedFont(apt->shared_font_mem, target_address);
|
||||||
apt->shared_font_relocated = true;
|
apt->shared_font_relocated = true;
|
||||||
|
|
Loading…
Reference in a new issue