aboutsummaryrefslogtreecommitdiff
path: root/src/core/arm/arm_interface.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-26 16:29:34 -0500
committerLioncash <mathew1800@gmail.com>2019-11-26 21:55:39 -0500
commitcc3d6fdf73a553f425535ccdc767edb3ddc4a6cd (patch)
treebc0937d11bbe31458785a69478edbf11a720b0ae /src/core/arm/arm_interface.cpp
parent9e3cbf71fcae9b97a5e7011a1170cbed72ac7f60 (diff)
core/memory: Migrate over Read{8, 16, 32, 64, Block} to the Memory class
With all of the trivial parts of the memory interface moved over, we can get right into moving over the bits that are used. Note that this does require the use of GetInstance from the global system instance to be used within hle_ipc.cpp and the gdbstub. This is fine for the time being, as they both already rely on the global system instance in other functions. These will be removed in a change directed at both of these respectively. For now, it's sufficient, as it still accomplishes the goal of de-globalizing the memory code.
Diffstat (limited to 'src/core/arm/arm_interface.cpp')
-rw-r--r--src/core/arm/arm_interface.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp
index dea192869f..7e846ddd5c 100644
--- a/src/core/arm/arm_interface.cpp
+++ b/src/core/arm/arm_interface.cpp
@@ -60,15 +60,15 @@ static_assert(sizeof(ELFSymbol) == 0x18, "ELFSymbol has incorrect size.");
using Symbols = std::vector<std::pair<ELFSymbol, std::string>>;
-Symbols GetSymbols(VAddr text_offset) {
- const auto mod_offset = text_offset + Memory::Read32(text_offset + 4);
+Symbols GetSymbols(VAddr text_offset, Memory::Memory& memory) {
+ const auto mod_offset = text_offset + memory.Read32(text_offset + 4);
if (mod_offset < text_offset || (mod_offset & 0b11) != 0 ||
- Memory::Read32(mod_offset) != Common::MakeMagic('M', 'O', 'D', '0')) {
+ memory.Read32(mod_offset) != Common::MakeMagic('M', 'O', 'D', '0')) {
return {};
}
- const auto dynamic_offset = Memory::Read32(mod_offset + 0x4) + mod_offset;
+ const auto dynamic_offset = memory.Read32(mod_offset + 0x4) + mod_offset;
VAddr string_table_offset{};
VAddr symbol_table_offset{};
@@ -76,8 +76,8 @@ Symbols GetSymbols(VAddr text_offset) {
VAddr dynamic_index = dynamic_offset;
while (true) {
- const auto tag = Memory::Read64(dynamic_index);
- const auto value = Memory::Read64(dynamic_index + 0x8);
+ const u64 tag = memory.Read64(dynamic_index);
+ const u64 value = memory.Read64(dynamic_index + 0x8);
dynamic_index += 0x10;
if (tag == ELF_DYNAMIC_TAG_NULL) {
@@ -105,11 +105,11 @@ Symbols GetSymbols(VAddr text_offset) {
VAddr symbol_index = symbol_table_address;
while (symbol_index < string_table_address) {
ELFSymbol symbol{};
- Memory::ReadBlock(symbol_index, &symbol, sizeof(ELFSymbol));
+ memory.ReadBlock(symbol_index, &symbol, sizeof(ELFSymbol));
VAddr string_offset = string_table_address + symbol.name_index;
std::string name;
- for (u8 c = Memory::Read8(string_offset); c != 0; c = Memory::Read8(++string_offset)) {
+ for (u8 c = memory.Read8(string_offset); c != 0; c = memory.Read8(++string_offset)) {
name += static_cast<char>(c);
}
@@ -141,17 +141,17 @@ constexpr u64 SEGMENT_BASE = 0x7100000000ull;
std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const {
std::vector<BacktraceEntry> out;
+ auto& memory = system.Memory();
auto fp = GetReg(29);
auto lr = GetReg(30);
-
while (true) {
out.push_back({"", 0, lr, 0});
if (!fp) {
break;
}
- lr = Memory::Read64(fp + 8) - 4;
- fp = Memory::Read64(fp);
+ lr = memory.Read64(fp + 8) - 4;
+ fp = memory.Read64(fp);
}
std::map<VAddr, std::string> modules;
@@ -162,7 +162,7 @@ std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const {
std::map<std::string, Symbols> symbols;
for (const auto& module : modules) {
- symbols.insert_or_assign(module.second, GetSymbols(module.first));
+ symbols.insert_or_assign(module.second, GetSymbols(module.first, memory));
}
for (auto& entry : out) {