1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#pragma once
8
9#include <config.h> // for arch/api/syscall.h
10#include <machine.h>
11#include <api/failures.h>
12#include <model/statedata.h>
13#include <kernel/vspace.h>
14#include <arch/api/syscall.h>
15#include <api/debug.h>
16
17#define TIME_ARG_SIZE (sizeof(ticks_t) / sizeof(word_t))
18
19#ifdef CONFIG_KERNEL_MCS
20#define MCS_DO_IF_BUDGET(_block) \
21    updateTimestamp(); \
22    if (likely(checkBudgetRestart())) { \
23        _block \
24    }
25#else
26#define MCS_DO_IF_BUDGET(_block) \
27    { \
28        _block \
29    }
30#endif
31
32exception_t handleSyscall(syscall_t syscall);
33exception_t handleInterruptEntry(void);
34exception_t handleUnknownSyscall(word_t w);
35exception_t handleUserLevelFault(word_t w_a, word_t w_b);
36exception_t handleVMFaultEvent(vm_fault_type_t vm_faultType);
37
38static inline word_t PURE getSyscallArg(word_t i, word_t *ipc_buffer)
39{
40    if (i < n_msgRegisters) {
41        return getRegister(NODE_STATE(ksCurThread), msgRegisters[i]);
42    }
43
44    assert(ipc_buffer != NULL);
45    return ipc_buffer[i + 1];
46}
47
48extern extra_caps_t current_extra_caps;
49
50