42#ifndef __SIM_SYSCALL_DESC_HH__
43#define __SIM_SYSCALL_DESC_HH__
120template <
typename ABI>
125 template <
typename ...Args>
129 template <
typename ...Args>
136 template <
typename ...Args>
144 auto partial = [target,desc](
146 return target(desc, tc, args...);
157 template <
typename ...Args>
168 template <
typename ...Args>
174 template <
typename ...Args>
190template <
typename ABI>
194 std::map<int, SyscallDescABI<ABI>>
_descs;
199 for (
auto &desc: descs) {
200 auto res =
_descs.insert({desc.num(), desc});
201 panic_if(!res.second,
"Failed to insert desc %s", desc.name());
206 *
get(
int num,
bool fatal_if_missing=
true)
208 auto it =
_descs.find(num);
210 if (fatal_if_missing)
211 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
virtual ~SyscallDesc()=default
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 Arm Limited 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.