18 #ifdef POK_NEEDS_ARINC653_EVENT
19 #include <arinc653/types.h>
20 #include <arinc653/event.h>
22 #include <core/event.h>
24 #include <libc/string.h>
28 #define CHECK_EVENTS_INIT if (pok_arinc653_events_initialized == 0) \
31 for (bla = 0 ; bla < POK_CONFIG_ARINC653_NB_EVENTS ; bla++) \
33 pok_arinc653_events_layers[bla].ready = 0;\
36 pok_arinc653_events_initialized = 1;
41 bool_t pok_arinc653_events_initialized = 0;
45 pok_event_id_t core_id;
49 extern char* pok_arinc653_events_names[POK_CONFIG_ARINC653_NB_EVENTS];
52 void CREATE_EVENT (EVENT_NAME_TYPE EVENT_NAME,
53 EVENT_ID_TYPE *EVENT_ID,
54 RETURN_CODE_TYPE *RETURN_CODE)
56 RETURN_CODE_TYPE return_code_name;
57 pok_event_id_t core_id;
60 *RETURN_CODE = INVALID_CONFIG;
64 GET_EVENT_ID (EVENT_NAME, EVENT_ID, &return_code_name);
66 if (return_code_name == INVALID_CONFIG)
68 *RETURN_CODE = INVALID_CONFIG;
72 if (*EVENT_ID >= POK_CONFIG_ARINC653_NB_EVENTS)
74 *RETURN_CODE = INVALID_CONFIG;
78 if (pok_arinc653_events_layers[*EVENT_ID].ready)
80 *RETURN_CODE = NO_ACTION;
84 core_ret = pok_event_create (&core_id);
90 if (core_ret != POK_ERRNO_OK)
92 *RETURN_CODE = INVALID_PARAM;
96 pok_arinc653_events_layers[*EVENT_ID].ready = 1;
97 pok_arinc653_events_layers[*EVENT_ID].core_id = core_id;
98 *RETURN_CODE = NO_ERROR;
101 void SET_EVENT (EVENT_ID_TYPE EVENT_ID,
102 RETURN_CODE_TYPE *RETURN_CODE)
106 *RETURN_CODE = INVALID_PARAM;
111 if (EVENT_ID >= POK_CONFIG_ARINC653_NB_EVENTS)
113 *RETURN_CODE = INVALID_CONFIG;
117 if (pok_arinc653_events_layers[EVENT_ID].ready == 0)
119 *RETURN_CODE = NOT_AVAILABLE;
123 core_ret = pok_event_signal (pok_arinc653_events_layers[EVENT_ID].core_id);
124 if (core_ret == POK_ERRNO_OK)
126 *RETURN_CODE = NO_ERROR;
131 *RETURN_CODE = INVALID_PARAM;
136 void RESET_EVENT (EVENT_ID_TYPE EVENT_ID,
137 RETURN_CODE_TYPE *RETURN_CODE)
145 void WAIT_EVENT (EVENT_ID_TYPE EVENT_ID,
146 SYSTEM_TIME_TYPE TIME_OUT,
147 RETURN_CODE_TYPE *RETURN_CODE)
151 *RETURN_CODE = INVALID_PARAM;
155 if (EVENT_ID >= POK_CONFIG_ARINC653_NB_EVENTS)
157 *RETURN_CODE = INVALID_CONFIG;
161 if (pok_arinc653_events_layers[EVENT_ID].ready == 0)
163 *RETURN_CODE = NOT_AVAILABLE;
167 core_ret = pok_event_wait (pok_arinc653_events_layers[EVENT_ID].core_id, TIME_OUT);
172 *RETURN_CODE = NO_ERROR;
175 case POK_ERRNO_TIMEOUT:
176 *RETURN_CODE = TIMED_OUT;
180 *RETURN_CODE = INVALID_PARAM;
185 void GET_EVENT_ID (EVENT_NAME_TYPE EVENT_NAME,
186 EVENT_ID_TYPE *EVENT_ID,
187 RETURN_CODE_TYPE *RETURN_CODE)
192 *RETURN_CODE = INVALID_CONFIG;
194 len = strlen (EVENT_NAME);
198 for (i = 0 ; i < POK_CONFIG_ARINC653_NB_EVENTS ; i++)
200 if (strncmp (EVENT_NAME, pok_arinc653_events_names[i], len) == 0)
203 *RETURN_CODE = NO_ERROR;
209 void GET_EVENT_STATUS (EVENT_ID_TYPE EVENT_ID,
211 RETURN_CODE_TYPE *RETURN_CODE)