mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 10:51:50 -05:00
Memory: Move address type conversion routines to memory.cpp/h
These helpers aren't really part of the kernel, and mem_map.cpp/h is going to be moved there next.
This commit is contained in:
parent
a12a30c9e0
commit
e2c7954be5
9 changed files with 47 additions and 53 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "common/swap.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/mem_map.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/arm/skyeye_common/armstate.h"
|
||||
#include "core/arm/skyeye_common/vfp/vfp.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "common/logging/log.h"
|
||||
|
||||
#include "core/mem_map.h"
|
||||
#include "core/arm/skyeye_common/arm_regformat.h"
|
||||
#include "core/arm/skyeye_common/armstate.h"
|
||||
#include "core/arm/skyeye_common/armsupp.h"
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "common/logging/log.h"
|
||||
|
||||
#include "core/mem_map.h"
|
||||
#include "core/hle/kernel/resource_limit.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "common/bit_field.h"
|
||||
|
||||
#include "core/mem_map.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/service/y2r_u.h"
|
||||
#include "core/hw/y2r.h"
|
||||
#include "core/mem_map.h"
|
||||
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/utils.h"
|
||||
|
|
|
@ -93,42 +93,6 @@ u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions) {
|
|||
return block.GetVirtualAddress();
|
||||
}
|
||||
|
||||
PAddr VirtualToPhysicalAddress(const VAddr addr) {
|
||||
if (addr == 0) {
|
||||
return 0;
|
||||
} else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) {
|
||||
return addr - VRAM_VADDR + VRAM_PADDR;
|
||||
} else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) {
|
||||
return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR;
|
||||
} else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) {
|
||||
return addr - DSP_RAM_VADDR + DSP_RAM_PADDR;
|
||||
} else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) {
|
||||
return addr - IO_AREA_VADDR + IO_AREA_PADDR;
|
||||
}
|
||||
|
||||
LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08x", addr);
|
||||
// To help with debugging, set bit on address so that it's obviously invalid.
|
||||
return addr | 0x80000000;
|
||||
}
|
||||
|
||||
VAddr PhysicalToVirtualAddress(const PAddr addr) {
|
||||
if (addr == 0) {
|
||||
return 0;
|
||||
} else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) {
|
||||
return addr - VRAM_PADDR + VRAM_VADDR;
|
||||
} else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) {
|
||||
return addr - FCRAM_PADDR + LINEAR_HEAP_VADDR;
|
||||
} else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) {
|
||||
return addr - DSP_RAM_PADDR + DSP_RAM_VADDR;
|
||||
} else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) {
|
||||
return addr - IO_AREA_PADDR + IO_AREA_VADDR;
|
||||
}
|
||||
|
||||
LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08x", addr);
|
||||
// To help with debugging, set bit on address so that it's obviously invalid.
|
||||
return addr | 0x80000000;
|
||||
}
|
||||
|
||||
void Init() {
|
||||
InitMemoryMap();
|
||||
LOG_DEBUG(HW_Memory, "initialized OK");
|
||||
|
|
|
@ -32,15 +32,4 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions);
|
|||
*/
|
||||
u32 MapBlock_HeapLinear(u32 size, u32 operation, u32 permissions);
|
||||
|
||||
/**
|
||||
* Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical
|
||||
* address. This should be used by services to translate addresses for use by the hardware.
|
||||
*/
|
||||
PAddr VirtualToPhysicalAddress(VAddr addr);
|
||||
|
||||
/**
|
||||
* Undoes a mapping performed by VirtualToPhysicalAddress().
|
||||
*/
|
||||
VAddr PhysicalToVirtualAddress(PAddr addr);
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "common/logging/log.h"
|
||||
#include "common/swap.h"
|
||||
|
||||
#include "core/mem_map.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/memory_setup.h"
|
||||
|
||||
|
@ -198,4 +197,40 @@ void WriteBlock(const VAddr addr, const u8* data, const size_t size) {
|
|||
Write8(addr + offset, data[offset]);
|
||||
}
|
||||
|
||||
PAddr VirtualToPhysicalAddress(const VAddr addr) {
|
||||
if (addr == 0) {
|
||||
return 0;
|
||||
} else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) {
|
||||
return addr - VRAM_VADDR + VRAM_PADDR;
|
||||
} else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) {
|
||||
return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR;
|
||||
} else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) {
|
||||
return addr - DSP_RAM_VADDR + DSP_RAM_PADDR;
|
||||
} else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) {
|
||||
return addr - IO_AREA_VADDR + IO_AREA_PADDR;
|
||||
}
|
||||
|
||||
LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08X", addr);
|
||||
// To help with debugging, set bit on address so that it's obviously invalid.
|
||||
return addr | 0x80000000;
|
||||
}
|
||||
|
||||
VAddr PhysicalToVirtualAddress(const PAddr addr) {
|
||||
if (addr == 0) {
|
||||
return 0;
|
||||
} else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) {
|
||||
return addr - VRAM_PADDR + VRAM_VADDR;
|
||||
} else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) {
|
||||
return addr - FCRAM_PADDR + LINEAR_HEAP_VADDR;
|
||||
} else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) {
|
||||
return addr - DSP_RAM_PADDR + DSP_RAM_VADDR;
|
||||
} else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) {
|
||||
return addr - IO_AREA_PADDR + IO_AREA_VADDR;
|
||||
}
|
||||
|
||||
LOG_ERROR(HW_Memory, "Unknown physical address @ 0x%08X", addr);
|
||||
// To help with debugging, set bit on address so that it's obviously invalid.
|
||||
return addr | 0x80000000;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -123,6 +123,17 @@ void WriteBlock(VAddr addr, const u8* data, size_t size);
|
|||
|
||||
u8* GetPointer(VAddr virtual_address);
|
||||
|
||||
/**
|
||||
* Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical
|
||||
* address. This should be used by services to translate addresses for use by the hardware.
|
||||
*/
|
||||
PAddr VirtualToPhysicalAddress(VAddr addr);
|
||||
|
||||
/**
|
||||
* Undoes a mapping performed by VirtualToPhysicalAddress().
|
||||
*/
|
||||
VAddr PhysicalToVirtualAddress(PAddr addr);
|
||||
|
||||
/**
|
||||
* Gets a pointer to the memory region beginning at the specified physical address.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue