summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-06-27 19:42:42 +0200
committerwwylele <wwylele@gmail.com>2016-08-27 15:38:06 +0200
commitb2df959733ee65cbf705dbfbd05761a06929a6b6 (patch)
tree90327dc0e58493de455fa4a4fdd4599ee8c6477a /src
parentMerge pull request #2022 from MerryMage/issue-tpl (diff)
downloadyuzu-b2df959733ee65cbf705dbfbd05761a06929a6b6.tar
yuzu-b2df959733ee65cbf705dbfbd05761a06929a6b6.tar.gz
yuzu-b2df959733ee65cbf705dbfbd05761a06929a6b6.tar.bz2
yuzu-b2df959733ee65cbf705dbfbd05761a06929a6b6.tar.lz
yuzu-b2df959733ee65cbf705dbfbd05761a06929a6b6.tar.xz
yuzu-b2df959733ee65cbf705dbfbd05761a06929a6b6.tar.zst
yuzu-b2df959733ee65cbf705dbfbd05761a06929a6b6.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/memory.cpp14
-rw-r--r--src/core/memory.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 8c9e5d46d..9aa8c4e5a 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -280,6 +280,20 @@ u8* GetPointer(const VAddr vaddr) {
return nullptr;
}
+std::string ReadCString(VAddr vaddr, std::size_t max_length) {
+ std::string string;
+ string.reserve(max_length);
+ for (std::size_t i = 0; i < max_length; ++i) {
+ char c = Read8(vaddr);
+ if (c == '\0')
+ break;
+ string.push_back(c);
+ ++vaddr;
+ }
+ string.shrink_to_fit();
+ return string;
+}
+
u8* GetPhysicalPointer(PAddr address) {
// TODO(Subv): This call should not go through the application's memory mapping.
return GetPointer(PhysicalToVirtualAddress(address));
diff --git a/src/core/memory.h b/src/core/memory.h
index ae5588dee..cad845385 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -5,6 +5,7 @@
#pragma once
#include <cstddef>
+#include <string>
#include "common/common_types.h"
@@ -130,6 +131,8 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, size_t size);
u8* GetPointer(VAddr virtual_address);
+std::string ReadCString(VAddr virtual_address, std::size_t max_length);
+
/**
* 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.