24 #if defined (POK_NEEDS_PORTS_SAMPLING) || defined (POK_NEEDS_PORTS_QUEUEING)
31 extern pok_port_t pok_ports[POK_CONFIG_NB_PORTS];
32 extern pok_queue_t pok_queue;
33 extern uint8_t pok_current_partition;
37 if (pok_ports[pid].full ==
TRUE)
42 if (pok_ports[pid].off_b < pok_ports[pid].off_e)
44 return (pok_ports[pid].off_b - pok_ports[pid].off_e);
48 return (pok_ports[pid].size - pok_ports[pid].off_e + pok_ports[pid].off_b);
54 if (pok_ports[pid].empty ==
TRUE)
59 if (pok_ports[pid].off_b < pok_ports[pid].off_e )
61 return (pok_ports[pid].off_e - pok_ports[pid].off_b);
65 return (pok_ports[pid].size - pok_ports[pid].off_b + pok_ports[pid].off_e);
73 #ifdef POK_NEEDS_PORTS_QUEUEING
78 switch (pok_ports[pid].kind)
81 #ifdef POK_NEEDS_PORTS_QUEUEING
83 if (pok_ports[pid].empty ==
TRUE)
88 if (pok_ports[pid].size < size)
93 if ((pok_ports[pid].off_b + size) > pok_ports[pid].size)
95 tmp_size = pok_ports[pid].
size - pok_ports[pid].
off_b;
96 memcpy (data, &pok_queue.data[pok_ports[pid].
index + pok_ports[pid].
off_b], tmp_size);
97 tmp_size2 = size - tmp_size;
98 memcpy (data + tmp_size, &pok_queue.data[pok_ports[pid].
index], tmp_size2);
102 memcpy (data, &pok_queue.data[pok_ports[pid].
index + pok_ports[pid].
off_b], size);
105 pok_ports[pid].
off_b = (pok_ports[pid].
off_b + size) % pok_ports[pid].size;
107 if (pok_ports[pid].off_b == pok_ports[pid].off_e)
117 #ifdef POK_NEEDS_PORTS_SAMPLING
119 if (pok_ports[pid].empty ==
TRUE)
124 if (size > pok_ports[pid].size)
129 memcpy (data, &pok_queue.data[pok_ports[pid].
index + pok_ports[pid].
off_b], size);
142 #ifdef POK_NEEDS_PORTS_QUEUEING
147 switch (pok_ports[pid].kind)
149 #ifdef POK_NEEDS_PORTS_QUEUEING
151 if (pok_ports[pid].full ==
TRUE)
156 if (size > pok_ports[pid].size)
161 if ((pok_ports[pid].off_e + size) > pok_ports[pid].size)
163 tmp_size = pok_ports[pid].
size - pok_ports[pid].
off_e;
164 memcpy (&pok_queue.data[pok_ports[pid].
index + pok_ports[pid].
off_e], data, tmp_size);
166 tmp_size2 = size - tmp_size;
167 memcpy (&pok_queue.data[pok_ports[pid].
index], data + tmp_size, tmp_size2);
171 memcpy (&pok_queue.data[pok_ports[pid].
index + pok_ports[pid].
off_e], data, size);
174 pok_ports[pid].
off_e = (pok_ports[pid].
off_e + size) % pok_ports[pid].size;
176 if (pok_ports[pid].off_e == pok_ports[pid].off_b)
188 #ifdef POK_NEEDS_PORTS_SAMPLING
191 if (size > pok_ports[pid].size)
196 memcpy (&pok_queue.data[pok_ports[pid].
index + pok_ports[pid].
off_e], data, size);
222 if (pok_ports[pid_src].empty ==
TRUE)
229 len = pok_port_available_size (pid_dst);
233 if (pok_ports[pid_src].size != pok_ports[pid_dst].size)
238 len = pok_ports[pid_src].
size;
243 src_len_consumed = pok_port_consumed_size (pid_src);
245 if (src_len_consumed == 0)
250 if (len > src_len_consumed)
252 len = src_len_consumed;
270 memcpy (&pok_queue.data[pok_ports[pid_dst].
index + pok_ports[pid_dst].
off_e], &pok_queue.data[pok_ports[pid_src].
index + pok_ports[pid_src].
off_b], len);
274 pok_ports[pid_dst].
off_e = (pok_ports[pid_dst].
off_e + len) % pok_ports[pid_dst].size;
275 pok_ports[pid_src].
off_b = (pok_ports[pid_src].
off_b + len) % pok_ports[pid_src].size;
277 if (pok_ports[pid_src].off_b == pok_ports[pid_src].off_e)
296 if (port > POK_CONFIG_NB_PORTS)
301 #ifdef POK_CONFIG_PARTITIONS_PORTS
302 if ((((
uint8_t[]) POK_CONFIG_PARTITIONS_PORTS)[port]) == partition)