POK
/home/jaouen/pok_official/pok/trunk/libpok/include/middleware/port.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 #include <core/dependencies.h>
00018 
00019 #ifndef __POK_LIBPOK_PORTS_H__
00020 #define __POK_LIBPOK_PORTS_H__
00021 
00022 #include <types.h>
00023 #include <errno.h>
00024 #include <core/syscall.h>
00025 
00026 typedef enum
00027 {
00028    POK_PORT_QUEUEING_DISCIPLINE_FIFO      = 1,
00029    POK_PORT_QUEUEING_DISCIPLINE_PRIORITY  = 2
00030 } pok_port_queueing_disciplines_t;
00031 
00032 typedef enum
00033 {
00034    POK_PORT_DIRECTION_IN   = 1,
00035    POK_PORT_DIRECTION_OUT  = 2
00036 } pok_port_directions_t;
00037 
00038 typedef pok_queueing_discipline_t pok_port_queueing_discipline_t;
00039 
00040 typedef enum
00041 {
00042    POK_PORT_KIND_QUEUEING  = 1,
00043    POK_PORT_KIND_SAMPLING  = 2,
00044    POK_PORT_KIND_VIRTUAL   = 2,
00045    POK_PORT_KIND_INVALID   = 10
00046 } pok_port_kinds_t;
00047 
00048 #ifdef POK_NEEDS_PORTS_VIRTUAL
00049 pok_ret_t pok_port_virtual_create (char* name, pok_port_id_t* id);
00050 
00051 pok_ret_t pok_port_virtual_destination (const pok_port_id_t id, const uint32_t n, uint32_t* result);
00052 
00053 pok_ret_t pok_port_virtual_nb_destinations (const pok_port_id_t id, uint32_t* result);
00054 
00055 pok_ret_t pok_port_virtual_get_global (const pok_port_id_t local, pok_port_id_t* global);
00056 #endif
00057 
00058 #ifdef POK_NEEDS_PORTS_QUEUEING
00059 /* Queueing port functions */
00060 typedef struct
00061 {
00062    pok_port_size_t      size;
00063    pok_port_direction_t direction;
00064    uint8_t              nb_messages;
00065    uint8_t              waiting_processes;
00066 }pok_port_queueing_status_t;
00067 
00068 
00069 pok_ret_t pok_port_queueing_create (char*                                     name, 
00070                                     const pok_port_size_t                     size, 
00071                                     const pok_port_direction_t                direction, 
00072                                     const pok_port_queueing_discipline_t      discipline,
00073                                     pok_port_id_t*                            id);
00074 
00075 pok_ret_t pok_port_queueing_receive (const pok_port_id_t                      id, 
00076                                      const uint64_t                           timeout, 
00077                                      const pok_port_size_t                    maxlen, 
00078                                      void*                                    data, 
00079                                      pok_port_size_t*                         len);
00080 
00081 pok_ret_t pok_port_queueing_send (const pok_port_id_t                         id, 
00082                                   const void*                                 data, 
00083                                   const pok_port_size_t                       len, 
00084                                   const uint64_t                              timeout);
00085 
00086 #define pok_port_queueing_status(id,status) \
00087         pok_syscall2(POK_SYSCALL_MIDDLEWARE_QUEUEING_STATUS,(uint32_t)id,(uint32_t)status)
00088 /*
00089  * Similar to:
00090  * pok_ret_t pok_port_queueing_status (const pok_port_id_t                    id,
00091  *                                     const pok_port_queueing_status_t*      status);
00092  */
00093 
00094 
00095 #define pok_port_queueing_id(name,id) \
00096         pok_syscall2(POK_SYSCALL_MIDDLEWARE_QUEUEING_ID,(uint32_t)name,(uint32_t)id)
00097 /*
00098  * Similar to:
00099  * pok_ret_t pok_port_queueing_id     (char*                                     name,
00100  *                                     pok_port_id_t*                            id);
00101  */
00102 #endif
00103 
00104 #ifdef POK_NEEDS_PORTS_SAMPLING
00105 /* Sampling port functions */
00106 
00107 typedef struct
00108 {
00109    pok_port_size_t      size;
00110    pok_port_direction_t direction;
00111    uint64_t             refresh;
00112    bool_t               validity;
00113 }pok_port_sampling_status_t;
00114 
00115 
00116 pok_ret_t pok_port_sampling_create (char*                                     name,
00117                                     const pok_port_size_t                     size,
00118                                     const pok_port_direction_t                direction, 
00119                                     const uint64_t                            refresh,
00120                                     pok_port_id_t*                            id);
00121 
00122 pok_ret_t pok_port_sampling_write (const pok_port_id_t                        id,
00123                                    const void*                                data,
00124                                    const pok_port_size_t                      len);
00125 
00126 pok_ret_t pok_port_sampling_read (const pok_port_id_t                      id,
00127                                   void*                                    message,
00128                                   pok_port_size_t*                         len,
00129                                   bool_t*                                  valid);
00130 
00131 #define pok_port_sampling_id(name,id) \
00132         pok_syscall2(POK_SYSCALL_MIDDLEWARE_SAMPLING_ID,(uint32_t)name,(uint32_t)id)
00133 /*
00134  *    Similar to
00135  *  pok_ret_t pok_port_sampling_id     (char*                                     name,
00136  *                                      pok_port_id_t*                            id);
00137  */
00138 
00139 #define pok_port_sampling_status(id,status) \
00140         pok_syscall2(POK_SYSCALL_MIDDLEWARE_SAMPLING_STATUS,(uint32_t)id,(uint32_t)status)
00141 /*
00142  * Similar to:
00143  * pok_ret_t pok_port_sampling_status (const pok_port_id_t                       id,
00144  *                                     const pok_port_sampling_status_t*               status);
00145  */
00146 #endif
00147 
00148 #endif