POK
port.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 #include <core/dependencies.h>
18 
19 #ifndef __POK_LIBPOK_PORTS_H__
20 #define __POK_LIBPOK_PORTS_H__
21 
22 #include <types.h>
23 #include <errno.h>
24 #include <core/syscall.h>
25 
26 typedef enum
27 {
28  POK_PORT_QUEUEING_DISCIPLINE_FIFO = 1,
29  POK_PORT_QUEUEING_DISCIPLINE_PRIORITY = 2
30 } pok_port_queueing_disciplines_t;
31 
32 typedef enum
33 {
34  POK_PORT_DIRECTION_IN = 1,
35  POK_PORT_DIRECTION_OUT = 2
36 } pok_port_directions_t;
37 
38 typedef pok_queueing_discipline_t pok_port_queueing_discipline_t;
39 
40 typedef enum
41 {
42  POK_PORT_KIND_QUEUEING = 1,
43  POK_PORT_KIND_SAMPLING = 2,
44  POK_PORT_KIND_VIRTUAL = 2,
45  POK_PORT_KIND_INVALID = 10
46 } pok_port_kinds_t;
47 
48 #ifdef POK_NEEDS_PORTS_VIRTUAL
49 pok_ret_t pok_port_virtual_create (char* name, pok_port_id_t* id);
50 
51 pok_ret_t pok_port_virtual_destination (const pok_port_id_t id, const uint32_t n, uint32_t* result);
52 
53 pok_ret_t pok_port_virtual_nb_destinations (const pok_port_id_t id, uint32_t* result);
54 
55 pok_ret_t pok_port_virtual_get_global (const pok_port_id_t local, pok_port_id_t* global);
56 #endif
57 
58 #ifdef POK_NEEDS_PORTS_QUEUEING
59 /* Queueing port functions */
60 typedef struct
61 {
62  pok_port_size_t size;
63  pok_port_direction_t direction;
64  uint8_t nb_messages;
65  uint8_t waiting_processes;
67 
68 
69 pok_ret_t pok_port_queueing_create (char* name,
70  const pok_port_size_t size,
71  const pok_port_direction_t direction,
72  const pok_port_queueing_discipline_t discipline,
73  pok_port_id_t* id);
74 
75 pok_ret_t pok_port_queueing_receive (const pok_port_id_t id,
76  const uint64_t timeout,
77  const pok_port_size_t maxlen,
78  void* data,
79  pok_port_size_t* len);
80 
81 pok_ret_t pok_port_queueing_send (const pok_port_id_t id,
82  const void* data,
83  const pok_port_size_t len,
84  const uint64_t timeout);
85 
86 #define pok_port_queueing_status(id,status) \
87  pok_syscall2(POK_SYSCALL_MIDDLEWARE_QUEUEING_STATUS,(uint32_t)id,(uint32_t)status)
88 /*
89  * Similar to:
90  * pok_ret_t pok_port_queueing_status (const pok_port_id_t id,
91  * const pok_port_queueing_status_t* status);
92  */
93 
94 
95 #define pok_port_queueing_id(name,id) \
96  pok_syscall2(POK_SYSCALL_MIDDLEWARE_QUEUEING_ID,(uint32_t)name,(uint32_t)id)
97 /*
98  * Similar to:
99  * pok_ret_t pok_port_queueing_id (char* name,
100  * pok_port_id_t* id);
101  */
102 #endif
103 
104 #ifdef POK_NEEDS_PORTS_SAMPLING
105 /* Sampling port functions */
106 
107 typedef struct
108 {
109  pok_port_size_t size;
110  pok_port_direction_t direction;
111  uint64_t refresh;
112  bool_t validity;
114 
115 
116 pok_ret_t pok_port_sampling_create (char* name,
117  const pok_port_size_t size,
118  const pok_port_direction_t direction,
119  const uint64_t refresh,
120  pok_port_id_t* id);
121 
122 pok_ret_t pok_port_sampling_write (const pok_port_id_t id,
123  const void* data,
124  const pok_port_size_t len);
125 
126 pok_ret_t pok_port_sampling_read (const pok_port_id_t id,
127  void* message,
128  pok_port_size_t* len,
129  bool_t* valid);
130 
131 #define pok_port_sampling_id(name,id) \
132  pok_syscall2(POK_SYSCALL_MIDDLEWARE_SAMPLING_ID,(uint32_t)name,(uint32_t)id)
133 /*
134  * Similar to
135  * pok_ret_t pok_port_sampling_id (char* name,
136  * pok_port_id_t* id);
137  */
138 
139 #define pok_port_sampling_status(id,status) \
140  pok_syscall2(POK_SYSCALL_MIDDLEWARE_SAMPLING_STATUS,(uint32_t)id,(uint32_t)status)
141 /*
142  * Similar to:
143  * pok_ret_t pok_port_sampling_status (const pok_port_id_t id,
144  * const pok_port_sampling_status_t* status);
145  */
146 #endif
147 
148 #endif