POK
/home/jaouen/pok_official/pok/trunk/libpok/include/core/syscall.h
00001 /*
00002  *                               POK header
00003  *
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009
00015  */
00016 
00017 #ifndef __LIBPOK_SYSCALL_H__
00018 #define __LIBPOK_SYSCALL_H__
00019 
00020 #include <types.h>
00021 #include <errno.h>
00022 
00023 typedef enum
00024 {
00025          POK_SYSCALL_CONSWRITE                           =  10,
00026          POK_SYSCALL_GETTICK                             =  20,
00027          POK_SYSCALL_INT_NUMBER                          =  42,
00028          POK_SYSCALL_THREAD_CREATE                       =  50,
00029          POK_SYSCALL_THREAD_SLEEP_UNTIL                  =  51,
00030          POK_SYSCALL_THREAD_SLEEP                        =  52,
00031          POK_SYSCALL_THREAD_SUSPEND                      =  53,
00032          POK_SYSCALL_THREAD_RESTART                      =  54,
00033          POK_SYSCALL_THREAD_STOP                         =  55,
00034          POK_SYSCALL_THREAD_PERIOD                       =  56,
00035          POK_SYSCALL_THREAD_STOPSELF                     =  57,
00036          POK_SYSCALL_THREAD_ID                           =  58,
00037          POK_SYSCALL_THREAD_STATUS                       =  59,
00038          POK_SYSCALL_THREAD_SET_PRIORITY                                                                 =  60,
00039          POK_SYSCALL_THREAD_RESUME                       =  61,
00040          POK_SYSCALL_THREAD_SUSPEND_TARGET               =  62,
00041    POK_SYSCALL_THREAD_DEADLINE                     =  63,
00042    POK_SYSCALL_THREAD_STATE                        =  64,
00043    POK_SYSCALL_THREAD_DELAYED_START                =  65,
00044 #ifdef POK_NEEDS_PORTS_SAMPLING
00045          POK_SYSCALL_MIDDLEWARE_SAMPLING_ID              = 101,
00046          POK_SYSCALL_MIDDLEWARE_SAMPLING_READ            = 102,
00047          POK_SYSCALL_MIDDLEWARE_SAMPLING_STATUS          = 103,
00048          POK_SYSCALL_MIDDLEWARE_SAMPLING_WRITE           = 104,
00049          POK_SYSCALL_MIDDLEWARE_SAMPLING_CREATE          = 105,
00050 #endif
00051 #ifdef POK_NEEDS_PORTS_QUEUEING
00052          POK_SYSCALL_MIDDLEWARE_QUEUEING_CREATE          = 110,
00053          POK_SYSCALL_MIDDLEWARE_QUEUEING_SEND            = 111,
00054          POK_SYSCALL_MIDDLEWARE_QUEUEING_RECEIVE         = 112,
00055          POK_SYSCALL_MIDDLEWARE_QUEUEING_ID              = 113,
00056          POK_SYSCALL_MIDDLEWARE_QUEUEING_STATUS          = 114,
00057 #endif
00058 #ifdef POK_NEEDS_PORTS_VIRTUAL
00059          POK_SYSCALL_MIDDLEWARE_VIRTUAL_CREATE           = 150,
00060          POK_SYSCALL_MIDDLEWARE_VIRTUAL_NB_DESTINATIONS  = 151,
00061          POK_SYSCALL_MIDDLEWARE_VIRTUAL_DESTINATION      = 152,
00062          POK_SYSCALL_MIDDLEWARE_VIRTUAL_GET_GLOBAL       = 153,
00063 #endif
00064 #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)
00065          POK_SYSCALL_LOCKOBJ_CREATE                      = 201,
00066          POK_SYSCALL_LOCKOBJ_OPERATION                   = 202,
00067 #endif
00068 #ifdef POK_NEEDS_ERROR_HANDLING
00069          POK_SYSCALL_ERROR_HANDLER_CREATE                = 301,
00070          POK_SYSCALL_ERROR_HANDLER_SET_READY             = 302,
00071          POK_SYSCALL_ERROR_RAISE_APPLICATION_ERROR       = 303,
00072          POK_SYSCALL_ERROR_GET                           = 304,
00073 #endif
00074 #ifdef POK_NEEDS_PARTITIONS
00075          POK_SYSCALL_PARTITION_SET_MODE                  = 404,
00076          POK_SYSCALL_PARTITION_GET_ID                                                                            = 405,
00077          POK_SYSCALL_PARTITION_GET_PERIOD                = 406,
00078          POK_SYSCALL_PARTITION_GET_DURATION              = 407,
00079          POK_SYSCALL_PARTITION_GET_LOCK_LEVEL            = 408,
00080          POK_SYSCALL_PARTITION_GET_OPERATING_MODE        = 409,
00081          POK_SYSCALL_PARTITION_GET_START_CONDITION       = 410,
00082 #endif
00083 #ifdef POK_NEEDS_IO
00084          POK_SYSCALL_INB                                 = 501,
00085          POK_SYSCALL_OUTB                                = 502,
00086 #endif
00087 #ifdef POK_NEEDS_PCI
00088          POK_SYSCALL_PCI_REGISTER                        = 601,
00089 #endif
00090 } pok_syscall_id_t;
00091 
00092 typedef struct
00093 {
00094          uint32_t             nargs;
00095          uint32_t             arg1;
00096          uint32_t             arg2;
00097          uint32_t             arg3;
00098          uint32_t             arg4;
00099          uint32_t             arg5;
00100 } pok_syscall_args_t;
00101 
00102 
00103 #ifdef POK_ARCH_X86
00104 /*
00105  * To reduce the number of functions and improve code coverage, we define
00106  * only one function to perform the syscall, the other are just maccro
00107  * This optimization was done only for x86 architecture.
00108  */
00109          pok_ret_t pok_do_syscall (pok_syscall_id_t syscall_id, pok_syscall_args_t* args);
00110 
00111          #define pok_syscall1(sid,arg1) \
00112                                          pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,0,0,0,0}))
00113 
00114          #define pok_syscall2(sid,arg1,arg2) \
00115                                          pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,0,0,0}))
00116 
00117          #define pok_syscall3(sid,arg1,arg2,arg3) \
00118                                          pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,arg3,0,0}))
00119 
00120          #define pok_syscall4(sid,arg1,arg2,arg3,arg4) \
00121                                          pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,arg3,arg4,0}))
00122 
00123          #define pok_syscall5(sid,arg1,arg2,arg3,arg4,arg5) \
00124                                          pok_do_syscall(sid,&((pok_syscall_args_t){2,arg1,arg2,arg3,arg4,arg5}))
00125 #else
00126 
00127 pok_ret_t pok_syscall1  (pok_syscall_id_t syscall_id,
00128                                                                                                  uint32_t arg1);
00129 
00130 pok_ret_t pok_syscall2  (pok_syscall_id_t syscall_id,
00131                                                                                                  uint32_t         arg1,
00132                                                                                                  uint32_t         arg2);
00133 
00134 pok_ret_t pok_syscall3 (pok_syscall_id_t  syscall_id,
00135                                                                                                 uint32_t          arg1,
00136                                                                                                 uint32_t          arg2,
00137                                                                                                 uint32_t          arg3);
00138 
00139 pok_ret_t pok_syscall4 (pok_syscall_id_t  syscall_id,
00140                                                                                                 uint32_t          arg1,
00141                                                                                                 uint32_t          arg2,
00142                                                                                                 uint32_t          arg3,
00143                                                                                                 uint32_t          arg4);
00144 
00145 pok_ret_t pok_syscall5 (pok_syscall_id_t  syscall_id,
00146                                                                                                 uint32_t arg1,
00147                                                                                                 uint32_t arg2,
00148                                                                                                 uint32_t arg3,
00149                                                                                                 uint32_t arg4,
00150                                                                                                 uint32_t arg5);
00151 #endif
00152 #endif /* __LIBPOK_SYSCALL_H__ */