1/**
2 * \file
3 * \brief System call numbers.
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef BARRELFISH_SYSCALLS_H
16#define BARRELFISH_SYSCALLS_H
17
18#ifndef __ASSEMBLER__
19
20#include <stdint.h>
21#include <errors/errno.h>
22
23/// return type from a system call: two words
24struct sysret {
25    errval_t  error;
26    uintptr_t value;
27};
28
29/// Macro used for constructing return values from single-value syscalls
30#define SYSRET(x) (struct sysret){ /*error*/ x, /*value*/ 0 }
31#endif // __ASSEMBLER__
32
33/*
34 * These are the system call ordinals. Please keep the space contiguous
35 * as far as possible and make sure SYSCALL_COUNT is the number of system
36 * calls. Lower layers may build direct-mapped syscall tables and so
37 * compactness is a virtue.
38 */
39
40/* Proper Barrelfish system calls */
41#define SYSCALL_INVOKE              0       ///< Invoke a cap
42#define SYSCALL_YIELD               1       ///< Yield the CPU
43#define SYSCALL_LRPC                2       ///< Fast LRPC
44
45/* Debug/Benchmarking system calls */
46#define SYSCALL_DEBUG               3     ///< Benchmarking and debug syscalls
47#define SYSCALL_REBOOT              4     ///< Reboot the machine
48#define SYSCALL_NOP                 5     ///< No operation
49#define SYSCALL_PRINT               6     ///< Write to console
50#define SYSCALL_GETCHAR             7     ///< Read from console
51
52/* Architecture-specific syscalls - X86
53 * FIXME: shouldn't these be in an arch-specific header? -AB */
54#define SYSCALL_X86_RELOAD_LDT       8    ///< Reload the LDT register (x86_64)
55#define SYSCALL_SUSPEND              9    ///< Suspend the CPU
56
57/* Architecture-specific syscalls - ARMv7 */
58#define SYSCALL_ARMv7_CACHE_CLEAN    8    ///< Clean (write back) by VA
59#define SYSCALL_ARMv7_CACHE_INVAL    9    ///< Invalidate (discard) by VA
60
61#define SYSCALL_COUNT               10     ///< Number of syscalls [0..SYSCALL_COUNT - 1]
62
63/*
64 * To understand system calls it might be helpful to know that there
65 * are four different levels of abstraction with multiplexing
66 * performed at three of them (compare with Tennenhouse: Layered
67 * Multiplexing Considered Harmful).
68 *
69 * At the bottom two levels of abstraction are the system call number
70 * as defined in this file.  This is one point of multiplexing and two
71 * levels of abstraction; the second one comes about because the
72 * system calls defined here use non primitive C types such as
73 * "struct sysret" which have to be converted and dealt with by a
74 * level of abstraction to deal with the encoding used over the
75 * protection boundary.  For example, on some architectures
76 * structures, including output structures, are passed by reference in
77 * the argument list.  Therefore below the C abstraction of the system
78 * call there must be a translation to an abstraction which can cross
79 * the protection boundary.
80 *
81 * Above this is the invoke system call.  It deals with two different
82 * ways of doing additional multiplexing, based on the type of the
83 * capability being invoked, and the command being invoked on the
84 * capability.  This defines which kernel system call implementation
85 * is to be run.  An aspect of this is that the arguments to the
86 * intended kernel code have to multiplexed up in user space onto the
87 * invoke system call and demultiplexed by the kernel, thus preventing
88 * direct dispatch to the intended implementation.
89 *
90 * Above this is the endpoint invocation in which the above system
91 * invocation system call is performed and demultiplexed, but the
92 * target capability is a special type in which the implementation
93 * code being called is not in the kernel; in this the arguments to
94 * the desired functionality must be marshalled in such a way that
95 * they can be delivered to the desired domain instead of the kernel.
96 *
97 * Knowing this will help the reader understand the various different
98 * marshalling and unmarshalling code found variously in
99 * monitor_invocations.h, invocations.h, syscalls.c, syscall_arch.h,
100 * syscall.c and related assembler.
101 */
102
103#endif // BARRELFISH_SYSCALLS_H
104