POK(kernelpart)
portvirtualgetglobal.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 extern uint8_t pok_local_ports_to_global_ports[POK_CONFIG_NB_PORTS];
32 
33 pok_ret_t pok_port_virtual_get_global (const pok_port_id_t local, pok_port_id_t* global)
34 {
35  if (local >= POK_CONFIG_NB_PORTS)
36  {
37  return POK_ERRNO_PORT;
38  }
39 
40  if (! pok_own_port (POK_SCHED_CURRENT_PARTITION, local))
41  {
42  return POK_ERRNO_PORT;
43  }
44 
45  if (pok_ports_kind[local] != POK_PORT_KIND_VIRTUAL)
46  {
47  return POK_ERRNO_PORT;
48  }
49 
50  *global = (pok_port_id_t) pok_local_ports_to_global_ports[local];
51 
52  return POK_ERRNO_OK;
53 }
54 
55 #endif