aboutsummaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-26 13:46:41 -0500
committerLioncash <mathew1800@gmail.com>2019-11-26 21:53:34 -0500
commite58748fd802dc069e90928d12d4db9ff994a869d (patch)
tree152c306a9a51f0ba49e2a34d1dc0db9eb2923013 /src/core/memory.cpp
parent323680e5ad3ca0e27f2dd1de26816741b3243bed (diff)
core/memory: Migrate over address checking functions to the new Memory class
A fairly straightforward migration. These member functions can just be mostly moved verbatim with minor changes. We already have the necessary plumbing in places that they're used. IsKernelVirtualAddress() can remain a non-member function, since it doesn't rely on class state in any form.
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 28b65ca5eb..4c13ea1e7a 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -75,6 +75,29 @@ struct Memory::Impl {
std::make_pair(interval, std::set<Common::SpecialRegion>{region}));
}
+ bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) const {
+ const auto& page_table = process.VMManager().page_table;
+
+ const u8* const page_pointer = page_table.pointers[vaddr >> PAGE_BITS];
+ if (page_pointer != nullptr) {
+ return true;
+ }
+
+ if (page_table.attributes[vaddr >> PAGE_BITS] == Common::PageType::RasterizerCachedMemory) {
+ return true;
+ }
+
+ if (page_table.attributes[vaddr >> PAGE_BITS] != Common::PageType::Special) {
+ return false;
+ }
+
+ return false;
+ }
+
+ bool IsValidVirtualAddress(VAddr vaddr) const {
+ return IsValidVirtualAddress(*system.CurrentProcess(), vaddr);
+ }
+
/**
* Maps a region of pages as a specific type.
*
@@ -148,6 +171,14 @@ void Memory::RemoveDebugHook(Common::PageTable& page_table, VAddr base, u64 size
impl->RemoveDebugHook(page_table, base, size, std::move(hook));
}
+bool Memory::IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) const {
+ return impl->IsValidVirtualAddress(process, vaddr);
+}
+
+bool Memory::IsValidVirtualAddress(const VAddr vaddr) const {
+ return impl->IsValidVirtualAddress(vaddr);
+}
+
void SetCurrentPageTable(Kernel::Process& process) {
current_page_table = &process.VMManager().page_table;
@@ -256,26 +287,6 @@ void Write(const VAddr vaddr, const T data) {
}
}
-bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) {
- const auto& page_table = process.VMManager().page_table;
-
- const u8* page_pointer = page_table.pointers[vaddr >> PAGE_BITS];
- if (page_pointer)
- return true;
-
- if (page_table.attributes[vaddr >> PAGE_BITS] == Common::PageType::RasterizerCachedMemory)
- return true;
-
- if (page_table.attributes[vaddr >> PAGE_BITS] != Common::PageType::Special)
- return false;
-
- return false;
-}
-
-bool IsValidVirtualAddress(const VAddr vaddr) {
- return IsValidVirtualAddress(*Core::System::GetInstance().CurrentProcess(), vaddr);
-}
-
bool IsKernelVirtualAddress(const VAddr vaddr) {
return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END;
}