From: Gabe Black Date: Tue, 26 Nov 2019 07:01:59 +0000 (-0800) Subject: sim: Add a transitional syscall ABI which defers to Process. X-Git-Tag: v19.0.0.0~31 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a255a2ee64106a2ab4f69c7867daef91feb2a241;p=gem5.git 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 Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/src/sim/syscall_desc.hh b/src/sim/syscall_desc.hh index e5adf8bd5..c34dc9045 100644 --- a/src/sim/syscall_desc.hh +++ b/src/sim/syscall_desc.hh @@ -50,12 +50,12 @@ #include #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 @@ class SyscallDescABI : public SyscallDesc using SyscallDesc::SyscallDesc; }; +struct DefaultSyscallABI +{ + using Position = int; +}; + +namespace GuestABI +{ + +template <> +struct Result +{ + static void + store(ThreadContext *tc, const SyscallReturn &ret) + { + auto *process = tc->getProcessPtr(); + process->setSyscallReturn(tc, ret); + } +}; + +template +struct Argument::value>::type> +{ + static Arg + get(ThreadContext *tc, DefaultSyscallABI::Position &position) + { + auto *process = tc->getProcessPtr(); + return process->getSyscallArg(tc, position); + } +}; + +template +struct Argument::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__