POK
syscall.h
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 #ifndef __LIBPOK_SYSCALL_H__
18 #define __LIBPOK_SYSCALL_H__
19 
20 #include <types.h>
21 #include <errno.h>
22 
23 typedef enum
24 {
25  POK_SYSCALL_CONSWRITE = 10,
26  POK_SYSCALL_GETTICK = 20,
27  POK_SYSCALL_INT_NUMBER = 42,
28  POK_SYSCALL_THREAD_CREATE = 50,
29  POK_SYSCALL_THREAD_SLEEP_UNTIL = 51,
30  POK_SYSCALL_THREAD_SLEEP = 52,
31  POK_SYSCALL_THREAD_SUSPEND = 53,
32  POK_SYSCALL_THREAD_RESTART = 54,
33  POK_SYSCALL_THREAD_STOP = 55,
34  POK_SYSCALL_THREAD_PERIOD = 56,
35  POK_SYSCALL_THREAD_STOPSELF = 57,
36  POK_SYSCALL_THREAD_ID = 58,
37  POK_SYSCALL_THREAD_STATUS = 59,
38  POK_SYSCALL_THREAD_DEADLINE = 60,
39  POK_SYSCALL_THREAD_STATE = 61,
40 
41 #ifdef POK_NEEDS_PORTS_SAMPLING
42  POK_SYSCALL_MIDDLEWARE_SAMPLING_ID = 101,
43  POK_SYSCALL_MIDDLEWARE_SAMPLING_READ = 102,
44  POK_SYSCALL_MIDDLEWARE_SAMPLING_STATUS = 103,
45  POK_SYSCALL_MIDDLEWARE_SAMPLING_WRITE = 104,
46  POK_SYSCALL_MIDDLEWARE_SAMPLING_CREATE = 105,
47 #endif
48 #ifdef POK_NEEDS_PORTS_QUEUEING
49  POK_SYSCALL_MIDDLEWARE_QUEUEING_CREATE = 110,
50  POK_SYSCALL_MIDDLEWARE_QUEUEING_SEND = 111,
51  POK_SYSCALL_MIDDLEWARE_QUEUEING_RECEIVE = 112,
52  POK_SYSCALL_MIDDLEWARE_QUEUEING_ID = 113,
53  POK_SYSCALL_MIDDLEWARE_QUEUEING_STATUS = 114,
54 #endif
55 #ifdef POK_NEEDS_PORTS_VIRTUAL
56  POK_SYSCALL_MIDDLEWARE_VIRTUAL_CREATE = 150,
57  POK_SYSCALL_MIDDLEWARE_VIRTUAL_NB_DESTINATIONS = 151,
58  POK_SYSCALL_MIDDLEWARE_VIRTUAL_DESTINATION = 152,
59  POK_SYSCALL_MIDDLEWARE_VIRTUAL_GET_GLOBAL = 153,
60 #endif
61 #if defined (POK_NEEDS_LOCKOBJECTS) || defined (POK_NEEDS_MUTEXES) || defined (POK_NEEDS_SEMAPHORES) || defined (POK_NEEDS_EVENTS) || defined (POK_NEEDS_BUFFERS) || defined (POK_NEEDS_BLACKBOARDS)
62  POK_SYSCALL_LOCKOBJ_CREATE = 201,
63  POK_SYSCALL_LOCKOBJ_OPERATION = 202,
64 #endif
65 #ifdef POK_NEEDS_ERROR_HANDLING
66  POK_SYSCALL_ERROR_HANDLER_CREATE = 301,
67  POK_SYSCALL_ERROR_HANDLER_SET_READY = 302,
68  POK_SYSCALL_ERROR_RAISE_APPLICATION_ERROR = 303,
69  POK_SYSCALL_ERROR_GET = 304,
70 #endif
71 #ifdef POK_NEEDS_PARTITIONS
72  POK_SYSCALL_PARTITION_SET_MODE = 404,
73  POK_SYSCALL_PARTITION_GET_ID = 405,
74  POK_SYSCALL_PARTITION_GET_PERIOD = 406,
75  POK_SYSCALL_PARTITION_GET_DURATION = 407,
76  POK_SYSCALL_PARTITION_GET_LOCK_LEVEL = 408,
77  POK_SYSCALL_PARTITION_GET_OPERATING_MODE = 409,
78  POK_SYSCALL_PARTITION_GET_START_CONDITION = 410,
79 #endif
80 #ifdef POK_NEEDS_IO
81  POK_SYSCALL_INB = 501,
82  POK_SYSCALL_OUTB = 502,
83 #endif
84 #ifdef POK_NEEDS_PCI
85  POK_SYSCALL_PCI_REGISTER = 601,
86 #endif
87 } pok_syscall_id_t;
88 
89 typedef struct
90 {
91  uint32_t nargs;
92  uint32_t arg1;
93  uint32_t arg2;
94  uint32_t arg3;
95  uint32_t arg4;
96  uint32_t arg5;
98 
99 
100 #ifdef POK_ARCH_X86
101 /*
102  * To reduce the number of functions and improve code coverage, we define
103  * only one function to perform the syscall, the other are just maccro
104  * This optimization was done only for x86 architecture.
105  */
106  pok_ret_t pok_do_syscall (pok_syscall_id_t syscall_id, pok_syscall_args_t* args);
107 
108  #define pok_syscall1(sid,arg1) \
109  pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,0,0,0,0}))
110 
111  #define pok_syscall2(sid,arg1,arg2) \
112  pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,0,0,0}))
113 
114  #define pok_syscall3(sid,arg1,arg2,arg3) \
115  pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,arg3,0,0}))
116 
117  #define pok_syscall4(sid,arg1,arg2,arg3,arg4) \
118  pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,arg3,arg4,0}))
119 
120  #define pok_syscall5(sid,arg1,arg2,arg3,arg4,arg5) \
121  pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,arg3,arg4,arg5}))
122 #else
123 
124 pok_ret_t pok_syscall1 (pok_syscall_id_t syscall_id,
125  uint32_t arg1);
126 
127 pok_ret_t pok_syscall2 (pok_syscall_id_t syscall_id,
128  uint32_t arg1,
129  uint32_t arg2);
130 
131 pok_ret_t pok_syscall3 (pok_syscall_id_t syscall_id,
132  uint32_t arg1,
133  uint32_t arg2,
134  uint32_t arg3);
135 
136 pok_ret_t pok_syscall4 (pok_syscall_id_t syscall_id,
137  uint32_t arg1,
138  uint32_t arg2,
139  uint32_t arg3,
140  uint32_t arg4);
141 
142 pok_ret_t pok_syscall5 (pok_syscall_id_t syscall_id,
143  uint32_t arg1,
144  uint32_t arg2,
145  uint32_t arg3,
146  uint32_t arg4,
147  uint32_t arg5);
148 #endif
149 #endif /* __LIBPOK_SYSCALL_H__ */