POK(kernelpart)
portvirtualnbdestinations.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_kind[POK_CONFIG_NB_PORTS];
30 
31 pok_ret_t pok_port_virtual_nb_destinations (const pok_port_id_t id, uint32_t* result)
32 {
33  if (id >= POK_CONFIG_NB_PORTS)
34  {
35  return POK_ERRNO_PORT;
36  }
37 
38  if (! pok_own_port (POK_SCHED_CURRENT_PARTITION, id))
39  {
40  return POK_ERRNO_PORT;
41  }
42 
43  if (pok_ports_kind[id] != POK_PORT_KIND_VIRTUAL)
44  {
45  return POK_ERRNO_PORT;
46  }
47 
48  *result = pok_ports_nb_destinations[id];
49 
50  return POK_ERRNO_OK;
51 }
52 
53 #endif