Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/23190 )

Change subject: sim: Add a transitional syscall ABI which defers to Process.
......................................................................

sim: Add a transitional syscall ABI which defers to Process.

This change adds a transitional ABI which just falls back to the
existing Process syscall arg getters. It should be phased out once each
ISA implements its own actual ABI.

Jira Issue: https://gem5.atlassian.net/browse/GEM5-187

Change-Id: Ic40bd924989f91de70bbce59fda888b79bbbfca4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23190
Reviewed-by: Gabe Black <gabebl...@google.com>
Maintainer: Gabe Black <gabebl...@google.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/sim/syscall_desc.hh
1 file changed, 48 insertions(+), 2 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/sim/syscall_desc.hh b/src/sim/syscall_desc.hh
index e5adf8b..c34dc90 100644
--- a/src/sim/syscall_desc.hh
+++ b/src/sim/syscall_desc.hh
@@ -50,12 +50,12 @@
 #include <string>

 #include "base/types.hh"
+#include "cpu/thread_context.hh"
 #include "sim/guest_abi.hh"
+#include "sim/process.hh"
 #include "sim/syscall_return.hh"

-class Process;
 class SyscallDesc;
-class ThreadContext;

 SyscallReturn unimplementedFunc(SyscallDesc *desc, int num,
                                 ThreadContext *tc);
@@ -154,4 +154,50 @@
     using SyscallDesc::SyscallDesc;
 };

+struct DefaultSyscallABI
+{
+    using Position = int;
+};
+
+namespace GuestABI
+{
+
+template <>
+struct Result<DefaultSyscallABI, SyscallReturn>
+{
+    static void
+    store(ThreadContext *tc, const SyscallReturn &ret)
+    {
+        auto *process = tc->getProcessPtr();
+        process->setSyscallReturn(tc, ret);
+    }
+};
+
+template <typename Arg>
+struct Argument<DefaultSyscallABI, Arg,
+    typename std::enable_if<std::is_integral<Arg>::value>::type>
+{
+    static Arg
+    get(ThreadContext *tc, DefaultSyscallABI::Position &position)
+    {
+        auto *process = tc->getProcessPtr();
+        return process->getSyscallArg(tc, position);
+    }
+};
+
+template <typename Arg>
+struct Argument<DefaultSyscallABI, Arg,
+    typename std::enable_if<std::is_pointer<Arg>::value>::type>
+{
+    static Arg
+    get(ThreadContext *tc, DefaultSyscallABI::Position &position)
+    {
+        auto *process = tc->getProcessPtr();
+        RegVal reg = process->getSyscallArg(tc, position);
+        return (Arg)(uintptr_t)(reg);
+    }
+};
+
+} // namespace GuestABI
+
 #endif // __SIM_SYSCALL_DESC_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/23190
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ic40bd924989f91de70bbce59fda888b79bbbfca4
Gerrit-Change-Number: 23190
Gerrit-PatchSet: 13
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Brandon Potter <brandon.pot...@amd.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to