summaryrefslogtreecommitdiff
path: root/DevTools/UserspaceEmulator/SimpleRegion.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-09-23 14:45:43 -0400
committerGitHub <noreply@github.com>2020-09-23 20:45:43 +0200
commitf1c0f661f44b54894aee0efb5c76f32af33430d6 (patch)
tree58790944a447f41802df96074051bd9855e7bc51 /DevTools/UserspaceEmulator/SimpleRegion.cpp
parent1fa5a526e8a75ecc32f38b949375da1e7c8ba7aa (diff)
downloadserenity-f1c0f661f44b54894aee0efb5c76f32af33430d6.zip
UserspaceEmulator+LibX86: Add support for 64-bit memory reads and writes (#3584)
This is useful for reading and writing doubles for #3329. It is also useful for emulating 64-bit binaries. MemoryOrRegisterReference assumes that 64-bit values are always memory references since that's enough for fpu support. If we ever want to emulate 64-bit binaries, that part will need minor updating.
Diffstat (limited to 'DevTools/UserspaceEmulator/SimpleRegion.cpp')
-rw-r--r--DevTools/UserspaceEmulator/SimpleRegion.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/DevTools/UserspaceEmulator/SimpleRegion.cpp b/DevTools/UserspaceEmulator/SimpleRegion.cpp
index cf5d2ee88c..173efd0e32 100644
--- a/DevTools/UserspaceEmulator/SimpleRegion.cpp
+++ b/DevTools/UserspaceEmulator/SimpleRegion.cpp
@@ -61,6 +61,12 @@ ValueWithShadow<u32> SimpleRegion::read32(u32 offset)
return { *reinterpret_cast<const u32*>(m_data + offset), *reinterpret_cast<const u32*>(m_shadow_data + offset) };
}
+ValueWithShadow<u64> SimpleRegion::read64(u32 offset)
+{
+ ASSERT(offset + 7 < size());
+ return { *reinterpret_cast<const u64*>(m_data + offset), *reinterpret_cast<const u64*>(m_shadow_data + offset) };
+}
+
void SimpleRegion::write8(u32 offset, ValueWithShadow<u8> value)
{
ASSERT(offset < size());
@@ -82,6 +88,13 @@ void SimpleRegion::write32(u32 offset, ValueWithShadow<u32> value)
*reinterpret_cast<u32*>(m_shadow_data + offset) = value.shadow();
}
+void SimpleRegion::write64(u32 offset, ValueWithShadow<u64> value)
+{
+ ASSERT(offset + 7 < size());
+ *reinterpret_cast<u64*>(m_data + offset) = value.value();
+ *reinterpret_cast<u64*>(m_shadow_data + offset) = value.shadow();
+}
+
u8* SimpleRegion::cacheable_ptr(u32 offset)
{
return m_data + offset;