The Pedigree Project  0.1
hosted/syscall-stubs.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef SERVICE
21 #error syscall-stubs.h requires SERVICE to be defined
22 #endif
23 #ifndef SERVICE_ERROR
24 #error syscall-stubs.h requires SERVICE_ERROR to be defined
25 #endif
26 #ifndef SERVICE_INIT
27 #error syscall-stubs.h requires SERVICE_INIT to be defined
28 #endif
29 
30 typedef long (*syscall_caller_t)(
31  long service, long function, void *error, long p1, long p2, long p3,
32  long p4, long p5);
33 
34 static syscall_caller_t __hosted_syscall = (syscall_caller_t) 0x399000;
35 
36 static long syscall0(long function)
37 {
38  SERVICE_INIT;
39  return __hosted_syscall(SERVICE, function, &SERVICE_ERROR, 0, 0, 0, 0, 0);
40 }
41 
42 static long syscall1(long function, long p1)
43 {
44  SERVICE_INIT;
45  return __hosted_syscall(SERVICE, function, &SERVICE_ERROR, p1, 0, 0, 0, 0);
46 }
47 
48 static long syscall2(long function, long p1, long p2)
49 {
50  SERVICE_INIT;
51  return __hosted_syscall(SERVICE, function, &SERVICE_ERROR, p1, p2, 0, 0, 0);
52 }
53 
54 static long syscall3(long function, long p1, long p2, long p3)
55 {
56  SERVICE_INIT;
57  return __hosted_syscall(
58  SERVICE, function, &SERVICE_ERROR, p1, p2, p3, 0, 0);
59 }
60 
61 static long syscall4(long function, long p1, long p2, long p3, long p4)
62 {
63  SERVICE_INIT;
64  return __hosted_syscall(
65  SERVICE, function, &SERVICE_ERROR, p1, p2, p3, p4, 0);
66 }
67 
68 static long syscall5(long function, long p1, long p2, long p3, long p4, long p5)
69 {
70  SERVICE_INIT;
71  return __hosted_syscall(
72  SERVICE, function, &SERVICE_ERROR, p1, p2, p3, p4, p5);
73 }