1/**
2 * \file
3 * \brief User-side system call implementation
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 ARCH_ARM_BARRELFISH_SYSCALL_H
16#define ARCH_ARM_BARRELFISH_SYSCALL_H
17
18//
19// This is the actual system call function. Because the return
20// value is a structure, r0 is setup point to the return
21// structure.  The first system call argument supplied at end of
22// argument list and moved to r0 before use in syscall. This
23// simplifies the amount of swizzling involved therein as r1 =
24// arg1, r2 = arg2, r3 = arg3, and the remaining args including
25// arg0 are on the stack.
26//
27extern struct sysret
28syscall(uintptr_t b, uintptr_t c, uintptr_t d, uintptr_t e,
29        uintptr_t f, uintptr_t g, uintptr_t h, uintptr_t i,
30        uintptr_t j, uintptr_t k, uintptr_t l, uintptr_t a);
31
32#define syscallx(a,b,c,d,e,f,g,h,i,j,k,l)                               \
33    syscall(b,c,d,e,f,g,h,i,j,k,l,a)
34
35//
36// System call argument 0 is encoded thus:
37//
38// arg[3:0]  = syscall ordinal (e.g. SYSCALL_YIELD)
39// arg[7:4]  = number of system call arguments (for sanity checking)
40// arg[31:8] = SYSCALL_INVOKE arguments | do_not_care
41//
42
43//C_ASSERT(SYSCALL_COUNT <= 0xf);
44#define sysord(a,n) (a) | ((n) << 4)
45
46// The following macros add the argument count to arg0
47
48#define syscall12(a,b,c,d,e,f,g,h,i,j,k,l)                              \
49    syscallx(sysord(a,12),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l))
50
51#define syscall11(a,b,c,d,e,f,g,h,i,j,k)                                \
52    syscallx(sysord(a,11),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),0)
53
54#define syscall10(a,b,c,d,e,f,g,h,i,j)                                  \
55    syscallx(sysord(a,10),(b),(c),(d),(e),(f),(g),(h),(i),(j),0,0)
56
57#define syscall9(a,b,c,d,e,f,g,h,i)                                     \
58    syscallx(sysord(a,9),(b),(c),(d),(e),(f),(g),(h),(i),0,0,0)
59
60#define syscall8(a,b,c,d,e,f,g,h)                                       \
61    syscallx(sysord(a,8),(b),(c),(d),(e),(f),(g),(h),0,0,0,0)
62
63#define syscall7(a,b,c,d,e,f,g)                                         \
64    syscallx(sysord(a,7),(b),(c),(d),(e),(f),(g),0,0,0,0,0)
65
66#define syscall6(a,b,c,d,e,f)                                           \
67    syscallx(sysord(a,6),(b),(c),(d),(e),(f),0,0,0,0,0,0)
68
69#define syscall5(a,b,c,d,e)                                             \
70    syscallx(sysord(a,5),(b),(c),(d),(e),0,0,0,0,0,0,0)
71
72#define syscall4(a,b,c,d)                                               \
73    syscallx(sysord(a,4),(b),(c),(d),0,0,0,0,0,0,0,0)
74
75#define syscall3(a,b,c)                                                 \
76    syscallx(sysord(a,3),(b),(c),0,0,0,0,0,0,0,0,0)
77
78#define syscall2(a,b)                                                   \
79    syscallx(sysord(a,2),(b),0,0,0,0,0,0,0,0,0,0)
80
81#define syscall1(a)                                                     \
82    syscallx(sysord(a,1),0,0,0,0,0,0,0,0,0,0,0)
83
84/* ARMv7-specific system calls. */
85
86void sys_armv7_cache_clean_pou(void *start, void *end);
87void sys_armv7_cache_clean_poc(void *start, void *end);
88void sys_armv7_cache_invalidate(void *start, void *end);
89
90#endif
91