POK
buffer.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 
18 #ifdef POK_NEEDS_ARINC653_BUFFER
19 #include <arinc653/types.h>
20 #include <arinc653/buffer.h>
21 #include <types.h>
22 #include <middleware/port.h>
23 #include <middleware/buffer.h>
24 
25 void CREATE_BUFFER (
26  /*in */ BUFFER_NAME_TYPE BUFFER_NAME,
27  /*in */ MESSAGE_SIZE_TYPE MAX_MESSAGE_SIZE,
28  /*in */ MESSAGE_RANGE_TYPE MAX_NB_MESSAGE,
29  /*in */ QUEUING_DISCIPLINE_TYPE QUEUING_DISCIPLINE,
30  /*out*/ BUFFER_ID_TYPE *BUFFER_ID,
31  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
32 {
33  pok_ret_t core_ret;
34  pok_buffer_id_t core_id;
35  pok_queueing_discipline_t core_discipline;
36 
37  switch (QUEUING_DISCIPLINE)
38  {
39  case PRIORITY:
40  core_discipline = POK_PORT_QUEUEING_DISCIPLINE_PRIORITY;
41  break;
42 
43  case FIFO:
44  core_discipline = POK_PORT_QUEUEING_DISCIPLINE_FIFO;
45  break;
46 
47  default:
48  *RETURN_CODE = INVALID_PARAM;
49  return;
50  }
51 
52  core_ret = pok_buffer_create (BUFFER_NAME, MAX_MESSAGE_SIZE * MAX_NB_MESSAGE, MAX_MESSAGE_SIZE, core_discipline, &core_id);
53 
54  *BUFFER_ID = core_id;
55 
56  *RETURN_CODE = core_ret;
57 }
58 
59 void SEND_BUFFER (
60  /*in */ BUFFER_ID_TYPE BUFFER_ID,
61  /*in */ MESSAGE_ADDR_TYPE MESSAGE_ADDR, /* by reference */
62  /*in */ MESSAGE_SIZE_TYPE LENGTH,
63  /*in */ SYSTEM_TIME_TYPE TIME_OUT,
64  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
65 {
66  pok_ret_t core_ret;
67  core_ret = pok_buffer_send (BUFFER_ID, MESSAGE_ADDR, LENGTH, TIME_OUT);
68  *RETURN_CODE = core_ret;
69 }
70 
71 void RECEIVE_BUFFER (
72  /*in */ BUFFER_ID_TYPE BUFFER_ID,
73  /*in */ SYSTEM_TIME_TYPE TIME_OUT,
74  /*out*/ MESSAGE_ADDR_TYPE MESSAGE_ADDR,
75  /*out*/ MESSAGE_SIZE_TYPE *LENGTH,
76  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
77 {
78  pok_ret_t core_ret;
79  pok_port_size_t core_size;
80  core_ret = pok_buffer_receive (BUFFER_ID, TIME_OUT, MESSAGE_ADDR, &core_size);
81  *LENGTH = (APEX_INTEGER) core_size;
82  *RETURN_CODE = core_ret;
83 }
84 
85 void GET_BUFFER_ID (
86  /*in */ BUFFER_NAME_TYPE BUFFER_NAME,
87  /*out*/ BUFFER_ID_TYPE *BUFFER_ID,
88  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
89 {
90  (void) BUFFER_NAME;
91  (void) BUFFER_ID;
92  *RETURN_CODE = NOT_AVAILABLE;
93 }
94 
95 void GET_BUFFER_STATUS (
96  /*in */ BUFFER_ID_TYPE BUFFER_ID,
97  /*out*/ BUFFER_STATUS_TYPE *BUFFER_STATUS,
98  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
99 {
100  (void) BUFFER_ID;
101  (void) BUFFER_STATUS;
102  *RETURN_CODE = NOT_AVAILABLE;
103 }
104 
105 #endif