POK(kernelpart)
portvirtualdestination.c
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 Tue Sep 8 07:39:08 2009
15  */
16 
17 #ifdef POK_NEEDS_PORTS_VIRTUAL
18 
19 #include <errno.h>
20 #include <types.h>
21 #include <core/sched.h>
22 #include <core/lockobj.h>
23 #include <middleware/port.h>
24 #include <middleware/queue.h>
25 #include <libc.h>
26 
27 extern uint8_t pok_ports_nb_destinations[POK_CONFIG_NB_PORTS];
28 extern uint8_t pok_ports_nb_ports_by_partition[POK_CONFIG_NB_PARTITIONS];
29 extern uint8_t* pok_ports_destinations[POK_CONFIG_NB_PORTS];
30 extern uint8_t pok_ports_kind[POK_CONFIG_NB_PORTS];
31 
32 pok_ret_t pok_port_virtual_destination (const pok_port_id_t id, const uint32_t n, uint32_t* result)
33 {
34  uint32_t val;
35 
36  if (id >= POK_CONFIG_NB_PORTS)
37  {
38  return POK_ERRNO_PORT;
39  }
40 
41  if (! pok_own_port (POK_SCHED_CURRENT_PARTITION, id))
42  {
43  return POK_ERRNO_PORT;
44  }
45 
46  if (pok_ports_kind[id] != POK_PORT_KIND_VIRTUAL)
47  {
48  return POK_ERRNO_PORT;
49  }
50 
51  if (n > pok_ports_nb_destinations[id])
52  {
53  return POK_ERRNO_PORT;
54  }
55 
56  val = (uint32_t) pok_ports_destinations[id][n];
57  *result = val;
58 
59  return POK_ERRNO_OK;
60 }
61 
62 #endif