42 #ifndef __SIM_SYSCALL_DESC_HH__ 43 #define __SIM_SYSCALL_DESC_HH__ 87 std::function<SyscallReturn(SyscallDesc *, ThreadContext *)>;
88 using Dumper = std::function<std::string(std::string, ThreadContext *)>;
109 template <
typename ABI>
114 template <
typename ...Args>
118 template <
typename ...Args>
125 template <
typename ...Args>
133 auto partial = [target,desc](
135 return target(desc, tc, args...);
141 std::function<SyscallReturn(ThreadContext *, Args...)>(
146 template <
typename ...Args>
150 return [](std::string
name, ThreadContext *tc) -> std::string {
157 template <
typename ...Args>
159 SyscallDesc(num, name, buildExecutor<Args...>(target),
160 buildDumper<Args...>())
163 template <
typename ...Args>
179 template <
typename ABI>
183 std::map<int, SyscallDescABI<ABI>>
_descs;
188 for (
auto &desc: descs) {
189 auto res = _descs.insert({desc.num(), desc});
190 panic_if(!res.second,
"Failed to insert desc %s", desc.name());
195 *
get(
int num,
bool fatal_if_missing=
true)
197 auto it = _descs.find(num);
198 if (it == _descs.end()) {
199 if (fatal_if_missing)
200 fatal(
"Syscall %d out of range", num);
208 #endif // __SIM_SYSCALL_DESC_HH__ std::string dumpSimcall(std::string name, ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target=std::function< Ret(ThreadContext *, Args...)>())
#define fatal(...)
This implements a cprintf based fatal() function.
Ret invokeSimcall(ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target)
SyscallDescABI(int num, const char *name, ABIExecutor< Args... > target)
Executor executor
Mechanism for ISAs to connect to the emul function definitions.
static void store(ThreadContext *tc, const Ret &ret)
SyscallDescABI(int num, const char *name, ABIExecutorPtr< Args... > target)
std::function< SyscallReturn(SyscallDesc *, ThreadContext *)> Executor
ThreadContext is the external interface to all thread state for anything outside of the CPU...
static Dumper buildDumper()
std::function< SyscallReturn(SyscallDesc *, ThreadContext *, Args...)> ABIExecutor
std::string _name
System call name (e.g., open, mmap, clone, socket, etc.)
SyscallDesc(int num, const char *name, Executor exec, Dumper dump)
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
std::map< int, SyscallDescABI< ABI > > _descs
void returnInto(ThreadContext *tc, const SyscallReturn &ret) override
For use within the system call executor if new threads are created and need something returned into t...
This class provides the wrapper interface for the system call implementations which are defined in th...
SyscallDescABI(int num, const char *name)
std::function< std::string(std::string, ThreadContext *)> Dumper
void dump()
Dump all statistics data to the registered outputs.
SyscallReturn unimplementedFunc(SyscallDesc *desc, ThreadContext *tc)
This class represents the return value from an emulated system call, including any errno setting...
static Executor buildExecutor(ABIExecutor< Args... > target)
void doSyscall(ThreadContext *tc, Fault *fault)
Interface for invoking the system call funcion pointer.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
SyscallReturn(*)(SyscallDesc *, ThreadContext *, Args...) ABIExecutorPtr
std::shared_ptr< FaultBase > Fault
virtual void returnInto(ThreadContext *tc, const SyscallReturn &ret)=0
For use within the system call executor if new threads are created and need something returned into t...
SyscallDescTable(std::initializer_list< SyscallDescABI< ABI >> descs)