POK(kernelpart)
portqueueingcreate.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 Thu Jan 15 23:34:13 2009
15  */
16 
17 #ifdef POK_NEEDS_PORTS_QUEUEING
18 
19 #include <errno.h>
20 #include <types.h>
21 #include <core/lockobj.h>
22 #include <middleware/port.h>
23 #include <middleware/queue.h>
24 
25 extern pok_port_t pok_ports[POK_CONFIG_NB_PORTS];
26 
27 pok_ret_t pok_port_queueing_create (char* name,
28  const pok_port_size_t size,
29  const pok_port_direction_t direction,
30  const pok_port_queueing_discipline_t discipline,
31  pok_port_id_t* id)
32 {
33  pok_ret_t ret;
34  pok_lockobj_attr_t lockattr;
35  if (discipline != POK_PORT_QUEUEING_DISCIPLINE_FIFO)
36  {
37  return POK_ERRNO_DISCIPLINE;
38  }
39 
40  ret = pok_port_create (name, size, direction, POK_PORT_KIND_QUEUEING, id);
41 
42  /*
43  * FIXME: should be done using another way by reinitializing
44  * ports when a partition is restarted. At this time, when
45  * a partition is restarted, the ports are not reinitialized
46  * so that when the partition restart, it tries to reopen
47  * ports already created. We pass over actually and keep
48  * the port in the previous step, but we should reinitialize
49  * the port while reinitializing the partition AND also
50  * does not report an OK return code (see below) when trying to re
51  * create a port that was already created.
52  */
53  if (ret == POK_ERRNO_EXISTS)
54  {
55  return POK_ERRNO_OK;
56  }
57 
58  if (ret != POK_ERRNO_OK)
59  {
60  return ret;
61  }
62 
63  pok_ports[*id].discipline = discipline;
64 
65  lockattr.kind = POK_LOCKOBJ_KIND_EVENT;
67  ret = pok_lockobj_create (&pok_ports[*id].lock, &lockattr);
68 
69  return (ret);
70 }
71 
72 #endif