42#ifndef __SIM_SYSCALL_DESC_HH__
43#define __SIM_SYSCALL_DESC_HH__
118template <
typename ABI>
123 template <
typename ...Args>
127 template <
typename ...Args>
134 template <
typename ...Args>
142 auto partial = [target,desc](
144 return target(desc, tc, args...);
155 template <
typename ...Args>
166 template <
typename ...Args>
172 template <
typename ...Args>
188template <
typename ABI>
192 std::map<int, SyscallDescABI<ABI>>
_descs;
197 for (
auto &desc: descs) {
198 auto res =
_descs.insert({desc.num(), desc});
199 panic_if(!res.second,
"Failed to insert desc %s", desc.name());
204 *
get(
int num,
bool fatal_if_missing=
true)
206 auto it =
_descs.find(num);
208 if (fatal_if_missing)
209 fatal(
"Syscall %d out of range", num);
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
std::function< SyscallReturn(SyscallDesc *, ThreadContext *, Args...)> ABIExecutor
SyscallDescABI(int num, const char *name)
SyscallDescABI(int num, const char *name, ABIExecutor< Args... > target)
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...
SyscallDescABI(int num, const char *name, ABIExecutorPtr< Args... > target)
SyscallReturn(*)(SyscallDesc *, ThreadContext *, Args...) ABIExecutorPtr
static Dumper buildDumper()
static Executor buildExecutor(ABIExecutor< Args... > target)
SyscallDesc * get(int num, bool fatal_if_missing=true)
std::map< int, SyscallDescABI< ABI > > _descs
SyscallDescTable(std::initializer_list< SyscallDescABI< ABI > > descs)
This class provides the wrapper interface for the system call implementations which are defined in th...
SyscallDesc(int num, const char *name, Executor exec, Dumper dump)
std::function< SyscallReturn(SyscallDesc *, ThreadContext *)> Executor
std::string _name
System call name (e.g., open, mmap, clone, socket, etc.)
std::function< std::string(std::string, ThreadContext *)> Dumper
void handleReturn(ThreadContext *tc, const SyscallReturn &ret)
void setupRetry(ThreadContext *tc)
void doSyscall(ThreadContext *tc)
Interface for invoking the system call funcion pointer.
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...
Executor executor
Mechanism for ISAs to connect to the emul function definitions.
void retrySyscall(ThreadContext *tc)
This class represents the return value from an emulated system call, including any errno setting.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
#define fatal(...)
This implements a cprintf based fatal() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
void dump()
Dump all statistics data to the registered outputs.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::string dumpSimcall(std::string name, ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target=std::function< Ret(ThreadContext *, Args...)>())
Ret invokeSimcall(ThreadContext *tc, std::function< Ret(ThreadContext *, Args...)> target)
SyscallReturn unimplementedFunc(SyscallDesc *desc, ThreadContext *tc)
Handler for unimplemented syscalls that we haven't thought about.