POK(kernelpart)
portvirtualid.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 pok_port_t pok_ports[POK_CONFIG_NB_PORTS];
28 extern char* pok_ports_names[POK_CONFIG_NB_PORTS];
29 extern uint8_t pok_ports_kind[POK_CONFIG_NB_PORTS];
30 
31 pok_ret_t pok_port_virtual_id (char* name,
32  pok_port_id_t* id)
33 {
34  uint8_t i;
35 
36  for (i = 0; i < POK_CONFIG_NB_PORTS ; i++)
37  {
38  if ( (strcmp (name, pok_ports_names[i]) == 0) && (pok_ports_kind[i] == POK_PORT_KIND_VIRTUAL))
39  {
40  if (! pok_own_port (POK_SCHED_CURRENT_PARTITION, i))
41  {
42  return POK_ERRNO_PORT;
43  }
44 
45  *id = i;
46 
47  return POK_ERRNO_OK;
48  }
49 
50  }
51 
52  return POK_ERRNO_NOTFOUND;
53 }
54 
55 #endif