1296781Sdes/**
257429Smarkm * \file
357429Smarkm * \brief System call numbers.
457429Smarkm */
557429Smarkm
660576Skris/*
765674Skris * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
865674Skris * All rights reserved.
965674Skris *
1065674Skris * This file is distributed under the terms in the attached LICENSE file.
1165674Skris * If you do not find this file, copies can be found by writing to:
1260576Skris * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
1365674Skris */
1465674Skris
1592559Sdes#ifndef BARRELFISH_SYSCALLS_H
1665674Skris#define BARRELFISH_SYSCALLS_H
1765674Skris
1865674Skris#ifndef __ASSEMBLER__
1965674Skris
2065674Skris#include <stdint.h>
2165674Skris#include <errors/errno.h>
2265674Skris
2365674Skris/// return type from a system call: two words
2465674Skrisstruct sysret {
2565674Skris    errval_t  error;
2665674Skris    uintptr_t value;
2765674Skris};
2865674Skris
2965674Skris/// Macro used for constructing return values from single-value syscalls
3065674Skris#define SYSRET(x) (struct sysret){ /*error*/ x, /*value*/ 0 }
3165674Skris#endif // __ASSEMBLER__
3265674Skris
3365674Skris/*
3465674Skris * These are the system call ordinals. Please keep the space contiguous
3565674Skris * as far as possible and make sure SYSCALL_COUNT is the number of system
3657429Smarkm * calls. Lower layers may build direct-mapped syscall tables and so
3757429Smarkm * compactness is a virtue.
3857429Smarkm */
3957429Smarkm
40162856Sdes/* Proper Barrelfish system calls */
41162856Sdes#define SYSCALL_INVOKE              0       ///< Invoke a cap
42162856Sdes#define SYSCALL_YIELD               1       ///< Yield the CPU
43162856Sdes#define SYSCALL_LRPC                2       ///< Fast LRPC
44262566Sdes
45162856Sdes
46295367Sdes/* Debug/Benchmarking system calls */
47262566Sdes#define SYSCALL_DEBUG               3     ///< Benchmarking and debug syscalls
48295367Sdes#define SYSCALL_REBOOT              4     ///< Reboot the machine
49295367Sdes#define SYSCALL_NOP                 5     ///< No operation
50264377Sdes#define SYSCALL_PRINT               6     ///< Write to console
5157429Smarkm#define SYSCALL_GETCHAR             7     ///< Read from console
52149753Sdes
5398941Sdes/* Architecture-specific syscalls - X86
54295367Sdes * FIXME: shouldn't these be in an arch-specific header? -AB */
55124211Sdes#define SYSCALL_X86_RELOAD_LDT       9    ///< Reload the LDT register (x86_64)
56124211Sdes#define SYSCALL_SUSPEND             10    ///< Suspend the CPU
57295367Sdes
58295367Sdes/* Architecture-specific syscalls - ARMv7 */
5957429Smarkm#define SYSCALL_ARMv7_CACHE_CLEAN    8    ///< Clean (write back) by VA
60295367Sdes#define SYSCALL_ARMv7_CACHE_INVAL    9    ///< Invalidate (discard) by VA
6192559Sdes
6292559Sdes#define SYSCALL_COUNT               10     ///< Number of syscalls [0..SYSCALL_COUNT - 1]
6392559Sdes
6492559Sdes/*
65248619Sdes * To understand system calls it might be helpful to know that there
66248619Sdes * are four different levels of abstraction with multiplexing
67149753Sdes * performed at three of them (compare with Tennenhouse: Layered
68262566Sdes * Multiplexing Considered Harmful).
69262566Sdes *
70262566Sdes * At the bottom two levels of abstraction are the system call number
71295367Sdes * as defined in this file.  This is one point of multiplexing and two
72295367Sdes * levels of abstraction; the second one comes about because the
73295367Sdes * system calls defined here use non primitive C types such as
7498684Sdes * "struct sysret" which have to be converted and dealt with by a
75295367Sdes * level of abstraction to deal with the encoding used over the
76295367Sdes * protection boundary.  For example, on some architectures
77295367Sdes * structures, including output structures, are passed by reference in
78255767Sdes * the argument list.  Therefore below the C abstraction of the system
79255767Sdes * call there must be a translation to an abstraction which can cross
80295367Sdes * the protection boundary.
81295367Sdes *
82248619Sdes * Above this is the invoke system call.  It deals with two different
83248619Sdes * ways of doing additional multiplexing, based on the type of the
84323124Sdes * capability being invoked, and the command being invoked on the
85248619Sdes * capability.  This defines which kernel system call implementation
86323124Sdes * is to be run.  An aspect of this is that the arguments to the
87295367Sdes * intended kernel code have to multiplexed up in user space onto the
88295367Sdes * invoke system call and demultiplexed by the kernel, thus preventing
89295367Sdes * direct dispatch to the intended implementation.
90248619Sdes *
91323124Sdes * Above this is the endpoint invocation in which the above system
92248619Sdes * invocation system call is performed and demultiplexed, but the
93248619Sdes * target capability is a special type in which the implementation
94323124Sdes * code being called is not in the kernel; in this the arguments to
95323124Sdes * the desired functionality must be marshalled in such a way that
96248619Sdes * they can be delivered to the desired domain instead of the kernel.
97248619Sdes *
98323124Sdes * Knowing this will help the reader understand the various different
99323124Sdes * marshalling and unmarshalling code found variously in
100248619Sdes * monitor_invocations.h, invocations.h, syscalls.c, syscall_arch.h,
101248619Sdes * syscall.c and related assembler.
102248619Sdes */
103323124Sdes
104248619Sdes#endif // BARRELFISH_SYSCALLS_H
105248619Sdes