#ifndef SYSCALL_SYSCALL_H_
#define SYSCALL_SYSCALL_H_

#include <stdint.h>
#include "compiler/attr.h"
#include "hal/hal.h"

#define SYSCALLS_MAX 0xff

#define SYSCALL0(name) \
  name(UNUSED IntrStackFrame *frame, \
       UNUSED uint64_t _caller_pid, \
       UNUSED uint64_t _1, \
       UNUSED uint64_t _2, \
       UNUSED uint64_t _3, \
       UNUSED uint64_t _4, \
       UNUSED uint64_t _5, \
       UNUSED uint64_t _6 \
      )

#define SYSCALL1(name, arg1) \
  name(UNUSED IntrStackFrame *frame, \
       UNUSED uint64_t _caller_pid, \
       uint64_t arg1, \
       UNUSED uint64_t _2, \
       UNUSED uint64_t _3, \
       UNUSED uint64_t _4, \
       UNUSED uint64_t _5, \
       UNUSED uint64_t _6 \
      )

#define SYSCALL2(name, arg1, arg2) \
  name(UNUSED IntrStackFrame *frame, \
       UNUSED uint64_t _caller_pid, \
       uint64_t arg1, \
       uint64_t arg2, \
       UNUSED uint64_t _3, \
       UNUSED uint64_t _4, \
       UNUSED uint64_t _5, \
       UNUSED uint64_t _6 \
      )

#define SYSCALL3(name, arg1, arg2, arg3) \
  name(UNUSED IntrStackFrame *frame, \
       UNUSED uint64_t _caller_pid, \
       uint64_t arg1, \
       uint64_t arg2, \
       uint64_t arg3, \
       UNUSED uint64_t _4, \
       UNUSED uint64_t _5, \
       UNUSED uint64_t _6 \
      )

#define SYSCALL4(name, arg1, arg2, arg3, arg4) \
  name(UNUSED IntrStackFrame *frame, \
       UNUSED uint64_t _caller_pid, \
       uint64_t arg1, \
       uint64_t arg2, \
       uint64_t arg3, \
       uint64_t arg4, \
       UNUSED uint64_t _5, \
       UNUSED uint64_t _6 \
      )

#define SYSCALL5(name, arg1, arg2, arg3, arg4, arg5) \
  name(UNUSED IntrStackFrame *frame, \
       UNUSED uint64_t _caller_pid, \
       uint64_t arg1, \
       uint64_t arg2, \
       uint64_t arg3, \
       uint64_t arg4, \
       uint64_t arg5, \
       UNUSED uint64_t _6 \
      )

#define SYSCALL6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
  name(UNUSED IntrStackFrame *frame, \
       UNUSED uint64_t _caller_pid, \
       uint64_t arg1, \
       uint64_t arg2, \
       uint64_t arg3, \
       uint64_t arg4, \
       uint64_t arg5, \
       uint64_t arg6 \
      )

typedef int32_t (*SyscallFn)(IntrStackFrame *, uint64_t,
                                               uint64_t,
                                               uint64_t,
                                               uint64_t,
                                               uint64_t,
                                               uint64_t,
                                               uint64_t);

extern SyscallFn SYSCALL_TABLE[SYSCALLS_MAX];

#endif // SYSCALL_SYSCALL_H_
