POK
queueing.c
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 #include <core/dependencies.h>
18 
19 #ifdef POK_NEEDS_ARINC653_QUEUEING
20 
21 #include <types.h>
22 #include <middleware/port.h>
23 #include <arinc653/types.h>
24 #include <arinc653/queueing.h>
25 
26 void CREATE_QUEUING_PORT (
27  /*in */ QUEUING_PORT_NAME_TYPE QUEUING_PORT_NAME,
28  /*in */ MESSAGE_SIZE_TYPE MAX_MESSAGE_SIZE,
29  /*in */ MESSAGE_RANGE_TYPE MAX_NB_MESSAGE,
30  /*in */ PORT_DIRECTION_TYPE PORT_DIRECTION,
31  /*in */ QUEUING_DISCIPLINE_TYPE QUEUING_DISCIPLINE,
32  /*out*/ QUEUING_PORT_ID_TYPE *QUEUING_PORT_ID,
33  /*out*/ RETURN_CODE_TYPE *return_code)
34 {
35  pok_ret_t core_ret;
36  pok_port_direction_t core_direction;
37  pok_port_queueing_discipline_t core_discipline;
38  pok_port_id_t core_id;
39 
40  switch (QUEUING_DISCIPLINE)
41  {
42  case PRIORITY:
43  core_discipline = POK_PORT_QUEUEING_DISCIPLINE_PRIORITY;
44  break;
45 
46  case FIFO:
47  core_discipline = POK_PORT_QUEUEING_DISCIPLINE_FIFO;
48  break;
49 
50  default:
51  *return_code = INVALID_PARAM;
52  return;
53  }
54 
55  switch (PORT_DIRECTION)
56  {
57  case SOURCE:
58  core_direction = POK_PORT_DIRECTION_OUT;
59  break;
60 
61  case DESTINATION:
62  core_direction = POK_PORT_DIRECTION_IN;
63  break;
64 
65  default:
66  *return_code = INVALID_PARAM;
67  return;
68  }
69 
70  core_ret = pok_port_queueing_create (QUEUING_PORT_NAME, MAX_MESSAGE_SIZE * MAX_NB_MESSAGE, core_direction, core_discipline, &core_id);
71 
72  *QUEUING_PORT_ID = core_id;
73  *return_code = core_ret;
74 }
75 
76 void SEND_QUEUING_MESSAGE (
77  /*in */ QUEUING_PORT_ID_TYPE QUEUING_PORT_ID,
78  /*in */ MESSAGE_ADDR_TYPE MESSAGE_ADDR, /* by reference */
79  /*in */ MESSAGE_SIZE_TYPE LENGTH,
80  /*in */ SYSTEM_TIME_TYPE TIME_OUT,
81  /*out*/ RETURN_CODE_TYPE *return_code)
82 {
83  pok_ret_t core_ret;
84 
85  core_ret = pok_port_queueing_send (QUEUING_PORT_ID, MESSAGE_ADDR, LENGTH, TIME_OUT);
86 
87  *return_code = core_ret;
88 }
89 
90 void RECEIVE_QUEUING_MESSAGE (
91  /*in */ QUEUING_PORT_ID_TYPE QUEUING_PORT_ID,
92  /*in */ SYSTEM_TIME_TYPE TIME_OUT,
93  /*out*/ MESSAGE_ADDR_TYPE MESSAGE_ADDR,
94  /*out*/ MESSAGE_SIZE_TYPE *LENGTH,
95  /*out*/ RETURN_CODE_TYPE *return_code )
96 {
97  pok_ret_t core_ret;
98 
99  core_ret = pok_port_queueing_receive (QUEUING_PORT_ID, TIME_OUT, *LENGTH, MESSAGE_ADDR, (pok_port_size_t*)LENGTH);
100 
101  *return_code = core_ret;
102 }
103 
104 void GET_QUEUING_PORT_ID (
105  /*in */ QUEUING_PORT_NAME_TYPE QUEUING_PORT_NAME,
106  /*out*/ QUEUING_PORT_ID_TYPE *QUEUING_PORT_ID,
107  /*out*/ RETURN_CODE_TYPE *return_code)
108 {
109  (void) QUEUING_PORT_NAME;
110  (void) QUEUING_PORT_ID;
111  *return_code = NOT_AVAILABLE;
112 }
113 
114 void GET_QUEUING_PORT_STATUS (
115  /*in */ QUEUING_PORT_ID_TYPE QUEUING_PORT_ID,
116  /*out*/ QUEUING_PORT_STATUS_TYPE *QUEUING_PORT_STATUS,
117  /*out*/ RETURN_CODE_TYPE *return_code)
118 {
119  (void) QUEUING_PORT_ID;
120  (void) QUEUING_PORT_STATUS;
121  *return_code = NOT_AVAILABLE;
122 }
123 
124 #endif