POK(kernelpart)
port.h
Go to the documentation of this file.
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 
24 #ifndef __POK_KERNEL_PORTS_H__
25 #define __POK_KERNEL_PORTS_H__
26 
27 #include <types.h>
28 #include <errno.h>
29 #include <core/lockobj.h>
30 
31 #define POK_PORT_MAX_SIZE 512
32 
33 typedef enum
34 {
38 
39 typedef enum
40 {
44 
46 
47 typedef enum
48 {
51 #ifdef POK_NEEDS_PORTS_VIRTUAL
52  POK_PORT_KIND_VIRTUAL = 2,
53 #endif
56 
57 typedef struct
58 {
64  pok_port_size_t off_b; /* Offset of the beginning of the buffer */
65  pok_port_size_t off_e; /* Offset of the end of the buffer */
75 }pok_port_t;
76 
77 #ifdef POK_NEEDS_PORTS_QUEUEING
78 /* Queueing port functions */
79 typedef struct
80 {
81  pok_port_size_t size;
82  pok_port_direction_t direction;
83  uint8_t waiting_processes;
84 }pok_port_queueing_status_t;
85 
86 
87 pok_ret_t pok_port_queueing_create (char* name,
88  const pok_port_size_t size,
89  const pok_port_direction_t direction,
90  const pok_port_queueing_discipline_t discipline,
91  pok_port_id_t* id);
92 
93 pok_ret_t pok_port_queueing_receive (const pok_port_id_t id,
94  uint64_t timeout,
95  const pok_port_size_t maxlen,
96  void* data,
97  pok_port_size_t* len);
98 
99 pok_ret_t pok_port_queueing_send (const pok_port_id_t id,
100  const void* data,
101  const pok_port_size_t len,
102  uint64_t timeout);
103 
104 pok_ret_t pok_port_queueing_status (const pok_port_id_t id,
105  pok_port_queueing_status_t* status);
106 
107 pok_ret_t pok_port_queueing_id (char* name,
108  pok_port_id_t* id);
109 #endif
110 
111 #ifdef POK_NEEDS_PORTS_SAMPLING
112 /* Sampling port functions */
113 
114 typedef struct
115 {
116  pok_port_size_t size;
117  pok_port_direction_t direction;
118  uint64_t refresh;
119  bool_t validity;
120 }pok_port_sampling_status_t;
121 
122 
123 pok_ret_t pok_port_sampling_create (char* name,
124  const pok_port_size_t size,
125  const pok_port_direction_t direction,
126  const uint64_t refresh,
127  pok_port_id_t* id);
128 
129 pok_ret_t pok_port_sampling_write (const pok_port_id_t id,
130  const void* data,
131  const pok_port_size_t len);
132 
133 pok_ret_t pok_port_sampling_read (const pok_port_id_t id,
134  void* message,
135  pok_port_size_t* len,
136  bool_t* valid);
137 
138 pok_ret_t pok_port_sampling_id (char* name,
139  pok_port_id_t* id);
140 
141 pok_ret_t pok_port_sampling_status (const pok_port_id_t id,
142  pok_port_sampling_status_t* status);
143 #endif
144 
145 #if defined (POK_NEEDS_PORTS_SAMPLING) || defined (POK_NEEDS_PORTS_QUEUEING)
146 /* Generic functions */
147 pok_ret_t pok_port_create (char* name,
148  const pok_port_size_t size,
149  const pok_port_direction_t direction,
150  uint8_t kind,
151  pok_port_id_t* id);
152 
153 pok_ret_t pok_port_transfer (const uint8_t gid_dst,
154  const uint8_t gid_src);
155 
156 void pok_port_init(void);
157 void pok_port_queueing_flushall (void);
158 uint8_t pok_port_lid_to_gid (uint8_t lid);
159 pok_port_size_t pok_port_available_size (uint8_t gid);
160 pok_port_size_t pok_port_consumed_size (uint8_t gid);
161 pok_ret_t pok_port_get (const uint32_t gid, void *data, const pok_port_size_t size);
162 pok_ret_t pok_port_write (const uint8_t gid, const void *data, const pok_port_size_t size);
163 bool_t pok_own_port (const uint8_t partition, const uint8_t port);
164 #endif
165 
166 
167 #ifdef POK_NEEDS_PORTS_VIRTUAL
168 pok_ret_t pok_port_virtual_id (char* name,
169  pok_port_id_t* id);
170 
171 pok_ret_t pok_port_virtual_nb_destinations (const pok_port_id_t id, uint32_t* result);
172 pok_ret_t pok_port_virtual_destination (const pok_port_id_t id, const uint32_t n, uint32_t* result);
173 pok_ret_t pok_port_virtual_get_global (const pok_port_id_t local, pok_port_id_t* global);
174 #endif
175 
176 #endif