Memory: move GetPhysicalPointer and IsValidPhysicalAddress into class
This commit is contained in:
parent
cfee59c6db
commit
296c458e0e
18 changed files with 76 additions and 65 deletions
|
@ -46,6 +46,7 @@ class SharedMemory;
|
|||
class ThreadManager;
|
||||
class TimerManager;
|
||||
class VMManager;
|
||||
struct AddressMapping;
|
||||
|
||||
enum class ResetType {
|
||||
OneShot,
|
||||
|
@ -216,6 +217,8 @@ public:
|
|||
|
||||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region);
|
||||
|
||||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping);
|
||||
|
||||
std::array<MemoryRegionInfo, 3> memory_regions;
|
||||
|
||||
/// Adds a port to the named port table
|
||||
|
|
|
@ -83,7 +83,7 @@ MemoryRegionInfo* KernelSystem::GetMemoryRegion(MemoryRegion region) {
|
|||
}
|
||||
}
|
||||
|
||||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping) {
|
||||
void KernelSystem::HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping) {
|
||||
using namespace Memory;
|
||||
|
||||
struct MemoryArea {
|
||||
|
@ -128,7 +128,7 @@ void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mappin
|
|||
return;
|
||||
}
|
||||
|
||||
u8* target_pointer = Memory::GetPhysicalPointer(area->paddr_base + offset_into_region);
|
||||
u8* target_pointer = memory.GetPhysicalPointer(area->paddr_base + offset_into_region);
|
||||
|
||||
// TODO(yuriks): This flag seems to have some other effect, but it's unknown what
|
||||
MemoryState memory_state = mapping.unk_flag ? MemoryState::Static : MemoryState::IO;
|
||||
|
|
|
@ -62,6 +62,4 @@ struct MemoryRegionInfo {
|
|||
void Free(u32 offset, u32 size);
|
||||
};
|
||||
|
||||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping);
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -136,7 +136,7 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) {
|
|||
// Map special address mappings
|
||||
kernel.MapSharedPages(vm_manager);
|
||||
for (const auto& mapping : address_mappings) {
|
||||
HandleSpecialMapping(vm_manager, mapping);
|
||||
kernel.HandleSpecialMapping(vm_manager, mapping);
|
||||
}
|
||||
|
||||
status = ProcessStatus::Running;
|
||||
|
|
|
@ -79,12 +79,12 @@ static void MemoryFill(const Regs::MemoryFillConfig& config) {
|
|||
const PAddr end_addr = config.GetEndAddress();
|
||||
|
||||
// TODO: do hwtest with these cases
|
||||
if (!Memory::IsValidPhysicalAddress(start_addr)) {
|
||||
if (!g_memory->IsValidPhysicalAddress(start_addr)) {
|
||||
LOG_CRITICAL(HW_GPU, "invalid start address {:#010X}", start_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Memory::IsValidPhysicalAddress(end_addr)) {
|
||||
if (!g_memory->IsValidPhysicalAddress(end_addr)) {
|
||||
LOG_CRITICAL(HW_GPU, "invalid end address {:#010X}", end_addr);
|
||||
return;
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ static void MemoryFill(const Regs::MemoryFillConfig& config) {
|
|||
return;
|
||||
}
|
||||
|
||||
u8* start = Memory::GetPhysicalPointer(start_addr);
|
||||
u8* end = Memory::GetPhysicalPointer(end_addr);
|
||||
u8* start = g_memory->GetPhysicalPointer(start_addr);
|
||||
u8* end = g_memory->GetPhysicalPointer(end_addr);
|
||||
|
||||
if (VideoCore::g_renderer->Rasterizer()->AccelerateFill(config))
|
||||
return;
|
||||
|
@ -132,12 +132,12 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
|
|||
const PAddr dst_addr = config.GetPhysicalOutputAddress();
|
||||
|
||||
// TODO: do hwtest with these cases
|
||||
if (!Memory::IsValidPhysicalAddress(src_addr)) {
|
||||
if (!g_memory->IsValidPhysicalAddress(src_addr)) {
|
||||
LOG_CRITICAL(HW_GPU, "invalid input address {:#010X}", src_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Memory::IsValidPhysicalAddress(dst_addr)) {
|
||||
if (!g_memory->IsValidPhysicalAddress(dst_addr)) {
|
||||
LOG_CRITICAL(HW_GPU, "invalid output address {:#010X}", dst_addr);
|
||||
return;
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
|
|||
if (VideoCore::g_renderer->Rasterizer()->AccelerateDisplayTransfer(config))
|
||||
return;
|
||||
|
||||
u8* src_pointer = Memory::GetPhysicalPointer(src_addr);
|
||||
u8* dst_pointer = Memory::GetPhysicalPointer(dst_addr);
|
||||
u8* src_pointer = g_memory->GetPhysicalPointer(src_addr);
|
||||
u8* dst_pointer = g_memory->GetPhysicalPointer(dst_addr);
|
||||
|
||||
if (config.scaling > config.ScaleXY) {
|
||||
LOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode {}",
|
||||
|
@ -308,12 +308,12 @@ static void TextureCopy(const Regs::DisplayTransferConfig& config) {
|
|||
const PAddr dst_addr = config.GetPhysicalOutputAddress();
|
||||
|
||||
// TODO: do hwtest with invalid addresses
|
||||
if (!Memory::IsValidPhysicalAddress(src_addr)) {
|
||||
if (!g_memory->IsValidPhysicalAddress(src_addr)) {
|
||||
LOG_CRITICAL(HW_GPU, "invalid input address {:#010X}", src_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Memory::IsValidPhysicalAddress(dst_addr)) {
|
||||
if (!g_memory->IsValidPhysicalAddress(dst_addr)) {
|
||||
LOG_CRITICAL(HW_GPU, "invalid output address {:#010X}", dst_addr);
|
||||
return;
|
||||
}
|
||||
|
@ -321,8 +321,8 @@ static void TextureCopy(const Regs::DisplayTransferConfig& config) {
|
|||
if (VideoCore::g_renderer->Rasterizer()->AccelerateTextureCopy(config))
|
||||
return;
|
||||
|
||||
u8* src_pointer = Memory::GetPhysicalPointer(src_addr);
|
||||
u8* dst_pointer = Memory::GetPhysicalPointer(dst_addr);
|
||||
u8* src_pointer = g_memory->GetPhysicalPointer(src_addr);
|
||||
u8* dst_pointer = g_memory->GetPhysicalPointer(dst_addr);
|
||||
|
||||
u32 remaining_size = Common::AlignDown(config.texture_copy.size, 16);
|
||||
|
||||
|
@ -471,7 +471,7 @@ inline void Write(u32 addr, const T data) {
|
|||
if (config.trigger & 1) {
|
||||
MICROPROFILE_SCOPE(GPU_CmdlistProcessing);
|
||||
|
||||
u32* buffer = (u32*)Memory::GetPhysicalPointer(config.GetPhysicalAddress());
|
||||
u32* buffer = (u32*)g_memory->GetPhysicalPointer(config.GetPhysicalAddress());
|
||||
|
||||
if (Pica::g_debug_context && Pica::g_debug_context->recorder) {
|
||||
Pica::g_debug_context->recorder->MemoryAccessed((u8*)buffer, config.size,
|
||||
|
|
|
@ -206,7 +206,7 @@ bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool IsValidPhysicalAddress(const PAddr paddr) {
|
||||
bool MemorySystem::IsValidPhysicalAddress(const PAddr paddr) {
|
||||
return GetPhysicalPointer(paddr) != nullptr;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ std::string ReadCString(VAddr vaddr, std::size_t max_length) {
|
|||
return string;
|
||||
}
|
||||
|
||||
u8* GetPhysicalPointer(PAddr address) {
|
||||
u8* MemorySystem::GetPhysicalPointer(PAddr address) {
|
||||
struct MemoryArea {
|
||||
PAddr paddr_base;
|
||||
u32 size;
|
||||
|
|
|
@ -183,8 +183,6 @@ extern std::array<u8, Memory::FCRAM_N3DS_SIZE> fcram;
|
|||
/// Determines if the given VAddr is valid for the specified process.
|
||||
bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr);
|
||||
|
||||
bool IsValidPhysicalAddress(PAddr paddr);
|
||||
|
||||
u8 Read8(VAddr addr);
|
||||
u16 Read16(VAddr addr);
|
||||
u32 Read32(VAddr addr);
|
||||
|
@ -207,11 +205,6 @@ u8* GetPointer(VAddr vaddr);
|
|||
|
||||
std::string ReadCString(VAddr vaddr, std::size_t max_length);
|
||||
|
||||
/**
|
||||
* Gets a pointer to the memory region beginning at the specified physical address.
|
||||
*/
|
||||
u8* GetPhysicalPointer(PAddr address);
|
||||
|
||||
/**
|
||||
* Mark each page touching the region as cached.
|
||||
*/
|
||||
|
@ -253,6 +246,13 @@ public:
|
|||
void SetCurrentPageTable(PageTable* page_table);
|
||||
PageTable* GetCurrentPageTable();
|
||||
|
||||
/**
|
||||
* Gets a pointer to the memory region beginning at the specified physical address.
|
||||
*/
|
||||
u8* GetPhysicalPointer(PAddr address);
|
||||
|
||||
bool IsValidPhysicalAddress(PAddr paddr);
|
||||
|
||||
/// Gets offset in FCRAM from a pointer inside FCRAM range
|
||||
u32 GetFCRAMOffset(u8* pointer);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue