1 |
/**************************************************************************** |
2 |
/* F i l e D a t a |
3 |
/* |
4 |
/* Module : MCMDManager |
5 |
/* C.I. No. : |
6 |
/* $Revision: 1.12 $ |
7 |
/* $Date: 2005/02/21 08:58:29 $ |
8 |
/* Belonging to : |
9 |
/* : |
10 |
/* $RCSfile: MA_MCMDArea_op.c,v $ |
11 |
/* Program Type : |
12 |
/* Sub-modules : |
13 |
/* |
14 |
/**************************************************************************** |
15 |
/* S W D e v e l o p m e n t E n v i r o n m e n t |
16 |
/* |
17 |
/* Host system : |
18 |
/* SW Compiler : |
19 |
/* $Author: sebastiani $ |
20 |
/* : |
21 |
/**************************************************************************** |
22 |
/* U p d a t i n g |
23 |
/* |
24 |
/* $Log: MA_MCMDArea_op.c,v $ |
25 |
/* Revision 1.12 2005/02/21 08:58:29 sebastiani |
26 |
/* all log comments completed |
27 |
/* |
28 |
/* Revision 1.11 2004/09/17 15:01:00 faber |
29 |
/* LU_INFN_LOG flags fixing |
30 |
/* |
31 |
/* Revision 1.10 2004/07/27 17:30:17 faber |
32 |
/* OBT can be now in second or milliseconds, depending of the situazion. |
33 |
/* OBT_s is used for FM compatibility, OBT_ms basically for MM infos |
34 |
/* |
35 |
/* Revision 1.9 2004/05/10 12:59:17 faber |
36 |
/* __FILEID__ right value fixed: many .c files had the wrong value! |
37 |
/* |
38 |
/* Revision 1.8 2004/02/26 11:23:09 faber |
39 |
/* SELECT_MODE min length is 8-only comment modified |
40 |
/* |
41 |
/* Revision 1.7 2003/12/15 10:57:16 sebastiani |
42 |
/* last changes for the acceptance of TM tests in Rome of 9-12/Dec/2003 |
43 |
/* |
44 |
/* Revision 1.6 2003/12/07 15:07:11 sebastiani |
45 |
/* GAS_TEST renamed to GAS_CONTAINER_PURGE |
46 |
/* |
47 |
/* Revision 1.5 2003/11/21 11:15:55 faber |
48 |
/* bugfixes: |
49 |
/* SELECT_MODE min length is 8, not 7 |
50 |
/* CALIBRATE length is 6, not 15 |
51 |
/* |
52 |
/* Revision 1.4 2003/11/18 17:13:15 sebastiani |
53 |
/* GPT enabled to print a "\n" every 60s directly on UART, only to check if the CPU is |
54 |
/* alive |
55 |
/* |
56 |
/* Revision 1.3 2003/11/18 09:01:14 alfarano |
57 |
/* laben patch fixes some problems |
58 |
/* |
59 |
/* Revision 1.2 2003/10/21 16:09:12 alfarano |
60 |
/* LU_LOG_INFN replacement for all remaining original log functions |
61 |
/* |
62 |
/* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani |
63 |
/* Imported sources laben rel. 19.06.2003 integrated with pam2 |
64 |
/* |
65 |
/* Revision 1.13 2002/11/14 09:50:19 zulia |
66 |
/* removed unsed status variable |
67 |
/* |
68 |
/* Revision 1.12 2002/08/05 14:26:56 zulia |
69 |
/* Fixed max len of Patch MCMD to 504 and select mode to 504 |
70 |
/* |
71 |
/* Revision 1.11 2002/08/01 09:48:04 zulia |
72 |
/* set length downlink to 0x0a |
73 |
/* |
74 |
/* Revision 1.10 2002/07/22 08:15:00 zulia |
75 |
/* correct the min length of MCMD SELECT_OPERATIVE_MODE from 9 to 7 |
76 |
/* |
77 |
/* Revision 1.9 2002/06/11 13:16:48 zulia |
78 |
/* changed lenght of DIRECT from 9 to 8 |
79 |
/* |
80 |
/* Revision 1.8 2002/05/15 13:46:34 zulia |
81 |
/* check of MCMD Lenght improved |
82 |
/* |
83 |
/* Revision 1.7 2002/05/09 08:16:34 zulia |
84 |
/* * acceptance release |
85 |
/* |
86 |
/* |
87 |
/*****************************************************************************/ |
88 |
|
89 |
|
90 |
/*============================= Include File ================================*/ |
91 |
|
92 |
#include <src/MCMDManager/MCMDArea/MA_MCMDArea_op.h> |
93 |
#include <src/MCMDManager/MCMDArea/MA_MCMDArea_int.h> |
94 |
|
95 |
#include <src/INFN/LU_SourceFileID_INFN.h> |
96 |
#define __FILEID__ _MA_MCMDArea_op__c |
97 |
#include <src/INFN/PRH_ParamHandler_INFN.h> |
98 |
#include <src/INFN/LU_LogUtility_INFN.h> |
99 |
#include <src/INFN/PRH_ParamHandler_INFN_auto.h> |
100 |
LU_DECL_MASK(); |
101 |
|
102 |
/*============================== Local Variables ============================*/ |
103 |
|
104 |
/*****************************************************************************/ |
105 |
/* @Constant: MA_McmdId */ |
106 |
/* @Purpose : */ |
107 |
/* Array of unsigned int. */ |
108 |
/* Array whose content is the MCMDs identifier, and the index is MCMDs type */ |
109 |
/* @@ */ |
110 |
/*****************************************************************************/ |
111 |
const unsigned int MA_McmdId [] = {ID_NULL_MCMD, |
112 |
ID_DOWN_LINK, |
113 |
ID_BITE, |
114 |
ID_TEST, |
115 |
ID_PATCH, |
116 |
ID_DUMP, |
117 |
ID_REBOOT, |
118 |
ID_DIRECT, |
119 |
ID_RESET_HISTORY, |
120 |
ID_DEL_MCMD_QUEUE, |
121 |
ID_EXE_MEM_CONF, |
122 |
ID_ABORT, |
123 |
ID_PURGE_TRD, |
124 |
ID_GAS_CONTAINER_PURGE, |
125 |
ID_CALIBRATE, |
126 |
ID_SELECT_MODE, |
127 |
ID_NEUTRON_DETECTOR, |
128 |
ID_TIME_SYNCHRONISE, |
129 |
ID_ORBITAL_INFORMATION, |
130 |
ID_INCLINATION_INFORMATION}; |
131 |
|
132 |
/**********************************************************************************/ |
133 |
/* @Constant: MA_McmdType */ |
134 |
/* @Purpose : */ |
135 |
/* Array of unsigned int. */ |
136 |
/* Array whose content is the MCMDs type, and the index is MCMDs identifier */ |
137 |
/* @@ */ |
138 |
/*****************************************************************************/ |
139 |
const unsigned int MA_McmdType [] ={ |
140 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//000 |
141 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//008 |
142 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//016 |
143 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//024 |
144 |
|
145 |
PATCH,DUMP,RESET_HISTORY,DEL_MCMD_QUEUE,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//032 |
146 |
REBOOT, EXE_MEM_CONF, NULL_MCMD ,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD ,ABORT,//040 |
147 |
PURGE_TRD,GAS_CONTAINER_PURGE,CALIBRATE,SELECT_MODE,NULL_MCMD,NEUTRON_DETECTOR,NULL_MCMD, //048 |
148 |
NULL_MCMD, |
149 |
|
150 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//056 |
151 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//064 |
152 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//072 |
153 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//080 |
154 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//088 |
155 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//096 |
156 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//104 |
157 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//112 |
158 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//120 |
159 |
|
160 |
BITE,NULL_MCMD, DOWN_LINK, NULL_MCMD, NULL_MCMD, NULL_MCMD, NULL_MCMD,NULL_MCMD,//128 |
161 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,TEST, //136 |
162 |
NULL_MCMD,NULL_MCMD, NULL_MCMD, NULL_MCMD, NULL_MCMD, NULL_MCMD,NULL_MCMD,NULL_MCMD,//144 |
163 |
|
164 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//152 |
165 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//160 |
166 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//168 |
167 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//176 |
168 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//184 |
169 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//192 |
170 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//200 |
171 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//208 |
172 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//216 |
173 |
|
174 |
TIME_SYNCHRONISE,ORBITAL_INFORMATION,INCLINATION_INFORMATION,NULL_MCMD,NULL_MCMD,//224 |
175 |
NULL_MCMD,NULL_MCMD,NULL_MCMD, |
176 |
|
177 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//232 |
178 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,//240 |
179 |
NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,NULL_MCMD,DIRECT//248 |
180 |
}; |
181 |
|
182 |
/*****************************************************************************/ |
183 |
/* @Constant: MA_McmdLenght */ |
184 |
/* @Purpose : */ |
185 |
/* Array of unsigned int. */ |
186 |
/* Array whose content is the MCMDs lenght, and the index is MCMDs type */ |
187 |
/* @@ */ |
188 |
/*****************************************************************************/ |
189 |
#define MIN_SELECT_MODE_LEN 8 |
190 |
#define MIN_PATCH_LEN 10 |
191 |
const unsigned int MA_McmdLenght [] = { |
192 |
0x00, /* NULL_MCMD, */ |
193 |
0x09, /* DOWN_LINK, */ // changed since test for TM in Rome |
194 |
0x07, /* BITE, */ |
195 |
0x07, /* TEST, */ |
196 |
0x1f8, /* PATCH, 10 - 504 */ |
197 |
0x09, /* DUMP, */ |
198 |
0x06, /* REBOOT, */ |
199 |
0x08, /* DIRECT, */ |
200 |
0x06, /* RESET_HISTORY, */ |
201 |
0x09, /* DEL_MCMD_QUEUE, */ |
202 |
0x07, /* EXE_MEM_CONF, */ |
203 |
0x07, /* ABORT, */ |
204 |
0x07, /* PURGE_TRD, */ |
205 |
0x07, /* GAS_CONTAINTER_PURGE, */ |
206 |
0x06, /* CALIBRATE, 6 */ |
207 |
0x1f8, /* SELECT_MODE, 8 - 504 */ |
208 |
0x07, /* NEUTRON_DETECTOR, */ |
209 |
0x08, /* TIME_SYNCHRONISE, */ |
210 |
0x14, /* ORBITAL_INFORMATION, 20 */ |
211 |
0x42 /* INCLINATION_INFORMATION 66 */ |
212 |
}; |
213 |
|
214 |
|
215 |
/*****************************************************************************/ |
216 |
/* @Variable: MA_HeaderMcmd */ |
217 |
/* @Purpose : */ |
218 |
/* MA_HEADER_MCMD type */ |
219 |
/* Pointer to timetag MCMD in top to the list */ |
220 |
/* @@ */ |
221 |
/*****************************************************************************/ |
222 |
static MA_HEADER_MCMD* MA_HeaderMcmd; |
223 |
|
224 |
/*****************************************************************************/ |
225 |
/* @Variable: MA_TimetagCounter */ |
226 |
/* @Purpose : */ |
227 |
/* unsigned int type */ |
228 |
/* Counter of the timetag MCMD storend in the list */ |
229 |
/* @@ */ |
230 |
/*****************************************************************************/ |
231 |
static unsigned int MA_TimetagCounter; |
232 |
|
233 |
/*****************************************************************************/ |
234 |
/* @Variable: MA_TimetagBufFullFlag */ |
235 |
/* @Purpose : */ |
236 |
/* unsigned int type */ |
237 |
/* Flag of timetag MCMD list full */ |
238 |
/* @@ */ |
239 |
/*****************************************************************************/ |
240 |
static unsigned int MA_TimetagBufFullFlag; |
241 |
|
242 |
/*****************************************************************************/ |
243 |
/* @Variable: MA_1553IsLocked */ |
244 |
/* @Purpose : */ |
245 |
/* unsigned int type */ |
246 |
/* arbiter of 1553 MCMD Buffer */ |
247 |
/* @@ */ |
248 |
/*****************************************************************************/ |
249 |
static unsigned int MA_1553IsLocked; |
250 |
|
251 |
/*****************************************************************************/ |
252 |
|
253 |
/*====== M C M D A r e a O P E R A T I O N A L F U N C T I O N S ========*/ |
254 |
|
255 |
/*****************************************************************************/ |
256 |
/* @Function: MA_opInit */ |
257 |
/* @Purpose : */ |
258 |
/* Inialialization function of the MCMDArea object. */ |
259 |
/* The following initialization are performed: */ |
260 |
/* To get from a OS partition a pointer to a buffer for storing the timetag */ |
261 |
/* MCMD header list. */ |
262 |
/* Initialize object variable. */ |
263 |
/* */ |
264 |
/* @@ */ |
265 |
/* @Parameter Name @Mode @Description */ |
266 |
/* status_code OUT Return code */ |
267 |
/* @@ */ |
268 |
/*****************************************************************************/ |
269 |
|
270 |
status_code MA_opInitMCMDArea (void) |
271 |
{ |
272 |
status_code status; |
273 |
|
274 |
/* Get partition buffer for the timetag MCMD header list */ |
275 |
status =OS_piPartGetBuffer(MA_TAB_PART,(void*)&MA_HeaderMcmd); |
276 |
/* Initialize object variable */ |
277 |
MA_TimetagCounter =0; |
278 |
MA_TimetagBufFullFlag =FALSE; |
279 |
MA_opRelease1553(); |
280 |
return (status); |
281 |
|
282 |
} |
283 |
|
284 |
|
285 |
|
286 |
/*****************************************************************************/ |
287 |
/* @Function: MA_opGetMCMDType */ |
288 |
/* @Purpose : */ |
289 |
/* The function converts the MCMD code in the MCMD type (enumarate). */ |
290 |
/* If MCMD type is not found an internal error HA_E10_MCMD_ERR is returned. */ |
291 |
/* */ |
292 |
/* @@ */ |
293 |
/* @Parameter Name @Mode @Description */ |
294 |
/* McmdId IN MCMD code identifier */ |
295 |
/* McmdType OUT MCMD type (enumerate) */ |
296 |
/* status_code OUT Return code */ |
297 |
/* @@ */ |
298 |
/*****************************************************************************/ |
299 |
|
300 |
status_code MA_opGetMCMDType (unsigned int McmdId, unsigned int* McmdType) |
301 |
{ |
302 |
status_code status; |
303 |
|
304 |
/* Check MCMD identification validity */ |
305 |
if (McmdId <= MAX_MCMD_ID) |
306 |
{ |
307 |
/* Get MCMD type */ |
308 |
*McmdType =MA_McmdType[McmdId]; |
309 |
} |
310 |
else |
311 |
{ |
312 |
/* MCMD type not identified */ |
313 |
*McmdType =NULL_MCMD; |
314 |
} |
315 |
/* Check if MCMD type has been found */ |
316 |
if (*McmdType != NULL_MCMD) |
317 |
{ |
318 |
status =SUCCESSFUL; |
319 |
} |
320 |
else |
321 |
{ |
322 |
status =HA_E10_MCMD_ERR; |
323 |
} |
324 |
|
325 |
return (status); |
326 |
|
327 |
} |
328 |
|
329 |
|
330 |
|
331 |
/*****************************************************************************/ |
332 |
/* @Function: MA_opGetMCMDId */ |
333 |
/* @Purpose : */ |
334 |
/* The function converts the MCMD type (enumarate) in the MCMD code. */ |
335 |
/* If MCMD type is not a valid enumerate an internal error HA_E10_MCMD_ERR */ |
336 |
/* is returned. */ |
337 |
/* */ |
338 |
/* @@ */ |
339 |
/* @Parameter Name @Mode @Description */ |
340 |
/* McmdType IN MCMD type (enumerate) */ |
341 |
/* McmdId OUT MCMD code identifier */ |
342 |
/* status_code OUT Return code */ |
343 |
/* @@ */ |
344 |
/*****************************************************************************/ |
345 |
|
346 |
status_code MA_opGetMCMDId (unsigned int McmdType,unsigned int* McmdId) |
347 |
{ |
348 |
status_code status; |
349 |
|
350 |
/* Check MCMD type identification validity */ |
351 |
if (McmdType <= MAX_MCMD) |
352 |
{ |
353 |
/* Get MCMD identification */ |
354 |
*McmdId =MA_McmdId[McmdType]; |
355 |
status =SUCCESSFUL; |
356 |
} |
357 |
else |
358 |
{ |
359 |
/* MCMD not identified */ |
360 |
*McmdId =NULL_MCMD; |
361 |
status =HA_E10_MCMD_ERR; |
362 |
} |
363 |
return (status); |
364 |
|
365 |
} |
366 |
|
367 |
/*****************************************************************************/ |
368 |
/* @Function: MA_opGetMCMDLenght */ |
369 |
/* @Purpose : */ |
370 |
/* The function checks the MCMD lenght. */ |
371 |
/* */ |
372 |
/* @@ */ |
373 |
/* @Parameter Name @Mode @Description */ |
374 |
/* McmdType IN MCMD type (enumerate) */ |
375 |
/* McmdLen OUT MCMD lenght */ |
376 |
/* status_code OUT Return code */ |
377 |
/* @@ */ |
378 |
/*****************************************************************************/ |
379 |
|
380 |
status_code MA_opGetMCMDLenght (unsigned int McmdType, |
381 |
unsigned int McmdLen) |
382 |
{ |
383 |
status_code status; |
384 |
unsigned int len; |
385 |
|
386 |
/* Check MCMD type identification validity */ |
387 |
if (McmdType <= MAX_MCMD) |
388 |
{ |
389 |
/* Get MCMD lenght */ |
390 |
status =UNSATISFIED; |
391 |
len =MA_McmdLenght[McmdType]; |
392 |
if (McmdType == SELECT_MODE) |
393 |
{ |
394 |
if (McmdLen >= MIN_SELECT_MODE_LEN && McmdLen<=len) |
395 |
{ |
396 |
status =SUCCESSFUL; |
397 |
} |
398 |
} |
399 |
else if (McmdType == PATCH) |
400 |
{ |
401 |
if (McmdLen >= MIN_PATCH_LEN && McmdLen<=len) |
402 |
{ |
403 |
status =SUCCESSFUL; |
404 |
} |
405 |
} |
406 |
else |
407 |
{ |
408 |
if (McmdLen==len) |
409 |
{ |
410 |
status =SUCCESSFUL; |
411 |
} |
412 |
} |
413 |
} |
414 |
else |
415 |
{ |
416 |
/* MCMD not identified */ |
417 |
status =HA_E10_MCMD_ERR; |
418 |
} |
419 |
|
420 |
return (status); |
421 |
|
422 |
} |
423 |
|
424 |
|
425 |
/*****************************************************************************/ |
426 |
/* @Function: MA_opPutMCMDtimetag */ |
427 |
/* @Purpose : */ |
428 |
/* The function inserts a MCMD with timetag in the timetag MCMD list. */ |
429 |
/* The MCMD is not inserted in the list if his timetag already exists. */ |
430 |
/* After having searched for the first free position in the list, if the */ |
431 |
/* MCMD timetag in top to the list is older than the MCMD timetag to insert,*/ |
432 |
/* is moved in the free position and the new MCMD is inserted in his */ |
433 |
/* position. Otherwise the new MCMD is inserted in the free position. */ |
434 |
/* During checks between timetag and OBT, for times close to the threshold */ |
435 |
/* overflow (2^ 32 bit), it is managed the cases in which one of the times */ |
436 |
/* exceeds the values limit of the variable. */ |
437 |
/* */ |
438 |
/* @@ */ |
439 |
/* @Parameter Name @Mode @Description */ |
440 |
/* Mcmd IN Pointer to MCMD header structure */ |
441 |
/* Obt IN On Board Time */ |
442 |
/* Option IN Flag which defines if await or no the */ |
443 |
/* resource availability (WAIT, NO_WAIT) */ |
444 |
/* Timeout IN Timeout value for WAIT option */ |
445 |
/* status_code OUT Return code */ |
446 |
/* @@ */ |
447 |
/*****************************************************************************/ |
448 |
|
449 |
status_code MA_opPutMCMDtimetag (MA_HEADER_MCMD* Mcmd, TI_TIME Obt, |
450 |
unsigned int Option, unsigned int Timeout) |
451 |
{ |
452 |
status_code status; |
453 |
status_code statusOper; |
454 |
MA_HEADER_MCMD* pt; |
455 |
MA_HEADER_MCMD* pFreePos; |
456 |
unsigned int swapFlag; |
457 |
unsigned int sameTimetagFlag; |
458 |
unsigned short i; |
459 |
|
460 |
if ((status =OS_piResourceObtain (MA_RES,Option,Timeout))==SUCCESSFUL) |
461 |
{ |
462 |
/* Search a free position, and check if the */ |
463 |
/* new timetag already exists */ |
464 |
sameTimetagFlag =FALSE; |
465 |
pFreePos =NULL; |
466 |
for (i=0, pt =MA_HeaderMcmd;(!sameTimetagFlag)&&(i<MAX_MCMD_TIMETAG); i++,pt++) |
467 |
{ |
468 |
if(pt->Type == NULL_MCMD) |
469 |
{ |
470 |
if (!pFreePos) |
471 |
{ |
472 |
/* Found fFree position */ |
473 |
pFreePos =pt; |
474 |
} |
475 |
} |
476 |
else |
477 |
{ |
478 |
if (pt->TimeTag == Mcmd->TimeTag) |
479 |
{ |
480 |
/* Same timetag found, the Mcmd must be refused */ |
481 |
sameTimetagFlag =TRUE; |
482 |
statusOper =HA_E2_TIMETAG_ALREADY_EXIST; |
483 |
} |
484 |
} |
485 |
} |
486 |
|
487 |
if (pFreePos && !sameTimetagFlag) |
488 |
{ |
489 |
/* The Mcmd must be inserted into timetag queue. Check if */ |
490 |
/* must be inserted in the header or in the free position */ |
491 |
swapFlag =FALSE; |
492 |
if (MA_HeaderMcmd->TimeTag < Obt) |
493 |
{ |
494 |
/* Timetag which expires after the obt counter overflow */ |
495 |
if (Mcmd->TimeTag < Obt) |
496 |
{ |
497 |
if(MA_HeaderMcmd->TimeTag > Mcmd->TimeTag) |
498 |
{ |
499 |
swapFlag =TRUE; |
500 |
} |
501 |
} |
502 |
else |
503 |
{ |
504 |
swapFlag =TRUE; |
505 |
} |
506 |
} |
507 |
else |
508 |
{ |
509 |
/* Timetag which expires before the obt counter overflow */ |
510 |
if (Mcmd->TimeTag > Obt) |
511 |
{ |
512 |
if(MA_HeaderMcmd->TimeTag > Mcmd->TimeTag) |
513 |
{ |
514 |
swapFlag =TRUE; |
515 |
} |
516 |
} |
517 |
} |
518 |
/* Check if the header MCMD must be replaced with the new MCMD */ |
519 |
if (swapFlag) |
520 |
{ |
521 |
/* The new MCMD is more recent, then is put in the header */ |
522 |
/* position and the less recent is put in the free position */ |
523 |
*pFreePos =*MA_HeaderMcmd; |
524 |
*MA_HeaderMcmd =*Mcmd; |
525 |
Mcmd->Type =NULL_MCMD; |
526 |
} |
527 |
else |
528 |
{ |
529 |
/* The new MCMD is put in the free position */ |
530 |
*pFreePos =*Mcmd; |
531 |
Mcmd->Type =NULL_MCMD; |
532 |
} |
533 |
statusOper =SUCCESSFUL; |
534 |
/* Increment timetag counter */ |
535 |
MA_TimetagCounter++; |
536 |
if (MA_TimetagCounter >= MAX_MCMD_TIMETAG) |
537 |
{ |
538 |
/* MCMD timetag list full */ |
539 |
MA_TimetagBufFullFlag =TRUE; |
540 |
} |
541 |
} |
542 |
else |
543 |
{ |
544 |
if (!pFreePos && !sameTimetagFlag) |
545 |
{ |
546 |
/* MCMD timetag list full */ |
547 |
MA_TimetagBufFullFlag =TRUE; |
548 |
statusOper =HA_E2_MCMD_QUEUE_FULL; |
549 |
} |
550 |
} |
551 |
/* Release MCMDArea resource */ |
552 |
status =OS_piResourceRelease (MA_RES); |
553 |
} |
554 |
else |
555 |
{ |
556 |
if (status==UNSATISFIED || status==INVALID_ID) |
557 |
{ |
558 |
/* Semaphore error */ |
559 |
/*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_SEMAPHORE_ERR,status); */ |
560 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
561 |
status =HA_E10_SEMAPHORE_ERR; |
562 |
} |
563 |
} |
564 |
|
565 |
/* If resource is correctly obtaneid return operation status */ |
566 |
if(status == SUCCESSFUL) |
567 |
{ |
568 |
status =statusOper; |
569 |
} |
570 |
return (status); |
571 |
} |
572 |
|
573 |
|
574 |
|
575 |
|
576 |
/*****************************************************************************/ |
577 |
/* @Function: MA_opGetMCMDtimetag */ |
578 |
/* @Purpose : */ |
579 |
/* The function returns the MCMD with the most recent timetag into the list.*/ |
580 |
/* The MCMD with most recent timetag of the list is always located in the */ |
581 |
/* header position. */ |
582 |
/* */ |
583 |
/* @@ */ |
584 |
/* @Parameter Name @Mode @Description */ |
585 |
/* Mcmd IN Pointer to MCMD header structure */ |
586 |
/* Option IN Flag which defines if await or no the */ |
587 |
/* resource availability (WAIT, NO_WAIT) */ |
588 |
/* Timeout IN Timeout value for WAIT option */ |
589 |
/* status_code OUT Return code */ |
590 |
/* @@ */ |
591 |
/*****************************************************************************/ |
592 |
|
593 |
status_code MA_opGetMCMDtimetag (MA_HEADER_MCMD* Mcmd, unsigned int Option, |
594 |
unsigned int Timeout) |
595 |
{ |
596 |
status_code status; |
597 |
|
598 |
if ((status =OS_piResourceObtain (MA_RES,Option,Timeout))==SUCCESSFUL) |
599 |
{ |
600 |
/* Get the MCMD in the header position (most recent) */ |
601 |
*Mcmd =*MA_HeaderMcmd; |
602 |
/* Release MCMDArea resource */ |
603 |
status =OS_piResourceRelease (MA_RES); |
604 |
} |
605 |
else |
606 |
{ |
607 |
/* Check if there is a resource error */ |
608 |
if (status==UNSATISFIED || status==INVALID_ID) |
609 |
{ |
610 |
/* Semaphore error */ |
611 |
/*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_SEMAPHORE_ERR,status); */ |
612 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
613 |
status =HA_E10_SEMAPHORE_ERR; |
614 |
} |
615 |
} |
616 |
return (status); |
617 |
|
618 |
} |
619 |
|
620 |
|
621 |
|
622 |
/*****************************************************************************/ |
623 |
/* @Function: MA_opUpdateMCMDtimetag */ |
624 |
/* @Purpose : */ |
625 |
/* The function first takes a MCMDArea resource then call a function that */ |
626 |
/* updates the header position in the timetag MCMD list with most recent */ |
627 |
/* MCMD. At the end it releases the MCMDArea resource. */ |
628 |
/* */ |
629 |
/* @@ */ |
630 |
/* @Parameter Name @Mode @Description */ |
631 |
/* Obt IN On Board Time */ |
632 |
/* Option IN Flag which defines if await or no the */ |
633 |
/* resource availability (WAIT, NO_WAIT) */ |
634 |
/* Timeout IN Timeout value for WAIT option */ |
635 |
/* status_code OUT Return code */ |
636 |
/* @@ */ |
637 |
/*****************************************************************************/ |
638 |
|
639 |
status_code MA_opUpdateMCMDtimetag (TI_TIME Obt, unsigned int Option, |
640 |
unsigned int Timeout) |
641 |
{ |
642 |
status_code status; |
643 |
|
644 |
if ((status =OS_piResourceObtain (MA_RES,Option,Timeout))==SUCCESSFUL) |
645 |
{ |
646 |
/* Update the MCMD in the header position (most recent) */ |
647 |
MA_ifUpdateMcmdHeader(MA_HeaderMcmd,Obt); |
648 |
|
649 |
/* Release MCMDArea resource */ |
650 |
status =OS_piResourceRelease (MA_RES); |
651 |
} |
652 |
else |
653 |
{ |
654 |
/* Check if there is a resource error */ |
655 |
if (status==UNSATISFIED || status==INVALID_ID) |
656 |
{ |
657 |
/*@LOG Semaphore error LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_SEMAPHORE_ERR,status); */ |
658 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
659 |
status =HA_E10_SEMAPHORE_ERR; |
660 |
} |
661 |
} |
662 |
|
663 |
return (status); |
664 |
|
665 |
} |
666 |
|
667 |
|
668 |
|
669 |
/*****************************************************************************/ |
670 |
/* @Function: MA_opDelMCMDtimetag */ |
671 |
/* @Purpose : */ |
672 |
/* The function searches and deletes the MCMD in the timetag MCMD list. */ |
673 |
/* If MCMD deleted was in the header position call the function to update */ |
674 |
/* the header position with the most recent MCMD. */ |
675 |
/* */ |
676 |
/* @@ */ |
677 |
/* @Parameter Name @Mode @Description */ |
678 |
/* Mcmd IN Pointer to MCMD header structure */ |
679 |
/* Obt IN On Board Time */ |
680 |
/* Option IN Flag which defines if await or no the */ |
681 |
/* resource availability (WAIT, NO_WAIT) */ |
682 |
/* Timeout IN Timeout value for WAIT option */ |
683 |
/* status_code OUT Return code */ |
684 |
/* @@ */ |
685 |
/*****************************************************************************/ |
686 |
|
687 |
status_code MA_opDelMCMDtimetag (MA_HEADER_MCMD* Mcmd, TI_TIME Obt, |
688 |
unsigned int Option, unsigned int Timeout) |
689 |
{ |
690 |
status_code status; |
691 |
status_code statusOper; |
692 |
MA_HEADER_MCMD* pt; |
693 |
MA_HEADER_MCMD* pHOverObt; |
694 |
MA_HEADER_MCMD* pHUnderObt; |
695 |
unsigned int ttOverObt,ttUnderObt; |
696 |
unsigned int ttOverFlag,ttUnderFlag; |
697 |
unsigned int mcmdFoundFlag; |
698 |
unsigned short i; |
699 |
|
700 |
if ((status =OS_piResourceObtain (MA_RES,Option,Timeout))==SUCCESSFUL) |
701 |
{ |
702 |
/* Search the MCMD into timetag list */ |
703 |
mcmdFoundFlag =FALSE; |
704 |
for (i=0, pt =MA_HeaderMcmd; i < MAX_MCMD_TIMETAG; i++,pt++) |
705 |
{ |
706 |
if (Mcmd->PtrMCMD == pt->PtrMCMD) |
707 |
{ |
708 |
/* Delete the specify MCMD into Timetag queue */ |
709 |
pt->Type =NULL_MCMD; |
710 |
pt->TimeTag =0; |
711 |
pt->PtrMCMD =NULL; |
712 |
pt->Length =0; |
713 |
mcmdFoundFlag =TRUE; |
714 |
break; /* MCMD found, exit from the loop */ |
715 |
} |
716 |
} |
717 |
/* Check if deleted MCMD was the Header MCMD */ |
718 |
if(mcmdFoundFlag && MA_HeaderMcmd->Type==NULL_MCMD) |
719 |
{ |
720 |
/* Search the more recent MCMD to execute, */ |
721 |
/* and put it in the header position */ |
722 |
MA_ifUpdateMcmdHeader(MA_HeaderMcmd,Obt); |
723 |
} |
724 |
if(mcmdFoundFlag) |
725 |
{ |
726 |
/* MCMD found */ |
727 |
statusOper =SUCCESSFUL; |
728 |
/* Decrements the MCMD timetag counter */ |
729 |
MA_TimetagCounter--; |
730 |
/* MCMD timetag buffer not full */ |
731 |
MA_TimetagBufFullFlag =FALSE; |
732 |
} |
733 |
else |
734 |
{ |
735 |
statusOper =HA_E10_MCMD_ERR; |
736 |
} |
737 |
|
738 |
/* Release MCMDArea resource */ |
739 |
status =OS_piResourceRelease (MA_RES); |
740 |
} |
741 |
else |
742 |
{ |
743 |
if (status==UNSATISFIED || status==INVALID_ID) |
744 |
{ |
745 |
/*@LOG Semaphore error LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_SEMAPHORE_ERR,status); */ |
746 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
747 |
status =HA_E10_SEMAPHORE_ERR; |
748 |
} |
749 |
} |
750 |
/* If resource is correctly obtaneid return operation status */ |
751 |
if(status == SUCCESSFUL) |
752 |
{ |
753 |
status =statusOper; |
754 |
} |
755 |
return (status); |
756 |
|
757 |
} |
758 |
|
759 |
|
760 |
|
761 |
/*****************************************************************************/ |
762 |
/* @Function: MA_opDelAllMCMDtimetag */ |
763 |
/* @Purpose : */ |
764 |
/* Provided Interface to delete all or a specific MCMD in the list of the */ |
765 |
/* MCMD with timetag. DelAllMcmdFlag parameter establishes if must be */ |
766 |
/* deleted all the MCDM of the list or only the MCMD that has the same */ |
767 |
/* timetag value of the function parameter Timetag. In this case if MCMD */ |
768 |
/* deleted was in the header position is called the function to update the */ |
769 |
/* header position with the most recent MCMD. */ |
770 |
/* */ |
771 |
/* @@ */ |
772 |
/* DelAllMcmdFlag IN Flag to indicate delete all or a MCMD */ |
773 |
/* Timetag IN Timetag value */ |
774 |
/* Option IN Flag which defines if await or no the */ |
775 |
/* resource availability (WAIT, NO_WAIT) */ |
776 |
/* Timeout IN Timeout value for WAIT option */ |
777 |
/* status_code OUT Return code */ |
778 |
/* @@ */ |
779 |
/*****************************************************************************/ |
780 |
|
781 |
status_code MA_opDelAllMCMDtimetag (unsigned int DelAllMcmdFlag, |
782 |
unsigned int Timetag, |
783 |
unsigned int Option, |
784 |
unsigned int Timeout) |
785 |
{ |
786 |
status_code status; |
787 |
status_code statusOper; |
788 |
MA_HEADER_MCMD* pt; |
789 |
unsigned int mcdmDeleteFlag; |
790 |
TI_TIME obt; |
791 |
unsigned short i; |
792 |
|
793 |
if ((status =OS_piResourceObtain (MA_RES,Option,Timeout))==SUCCESSFUL) |
794 |
{ |
795 |
statusOper =SUCCESSFUL; |
796 |
mcdmDeleteFlag =FALSE; |
797 |
if (DelAllMcmdFlag) |
798 |
{ |
799 |
/* Search all timetag MCMDs and delete them */ |
800 |
for (i=0, pt =MA_HeaderMcmd; i < MAX_MCMD_TIMETAG; i++,pt++) |
801 |
{ |
802 |
if (pt->Type != NULL_MCMD) |
803 |
{ |
804 |
/* Release the buffer partition */ |
805 |
statusOper =OS_piPartReturnBuffer(MA_PART_TT,pt->PtrMCMD); |
806 |
if (statusOper != SUCCESSFUL) |
807 |
{ |
808 |
/*@LOG Error during MCMD buffer ereasing - LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_PARTITION_ERR,statusOper); */ |
809 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,statusOper); |
810 |
statusOper =HA_E10_PARTITION_ERR; |
811 |
break; |
812 |
} |
813 |
pt->Type =NULL_MCMD; |
814 |
pt->PtrMCMD =NULL; |
815 |
pt->TimeTag =0; |
816 |
pt->Length =0; |
817 |
MA_TimetagCounter--; |
818 |
mcdmDeleteFlag =TRUE; |
819 |
} |
820 |
} |
821 |
} |
822 |
else |
823 |
{ |
824 |
/* Search the timetag MCMD and delete it */ |
825 |
mcdmDeleteFlag =FALSE; |
826 |
#warning do we want OBT in s or in ms ? if ms, russian must be warned ? TM was in s |
827 |
TI_piGetTimeInfo_s(&obt); |
828 |
/* Check if timetag to delete is out the OBT window (6 timetag ticks) */ |
829 |
if (abs(obt - Timetag) > TT_WINDOW_REQUIREMENT) |
830 |
{ |
831 |
for (i=0,pt=MA_HeaderMcmd;(!mcdmDeleteFlag)&&(i<MAX_MCMD_TIMETAG);i++,pt++) |
832 |
{ |
833 |
/* Check if timetag is found */ |
834 |
if (pt->TimeTag == Timetag) |
835 |
{ |
836 |
/* MCMD found */ |
837 |
/* Release the buffer partition */ |
838 |
statusOper =OS_piPartReturnBuffer(MA_PART_TT,pt->PtrMCMD); |
839 |
if (statusOper != SUCCESSFUL) |
840 |
{ |
841 |
/*@LOG Error during MCMD buffer ereasing LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_PARTITION_ERR,statusOper); */ |
842 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,statusOper); |
843 |
statusOper =HA_E10_PARTITION_ERR; |
844 |
} |
845 |
pt->Type =NULL_MCMD; |
846 |
pt->PtrMCMD =NULL; |
847 |
pt->TimeTag =0; |
848 |
pt->Length =0; |
849 |
MA_TimetagCounter--; |
850 |
mcdmDeleteFlag =TRUE; |
851 |
} |
852 |
} |
853 |
} |
854 |
if (!mcdmDeleteFlag) |
855 |
{ |
856 |
/* MCMD not found, timetag not correct. */ |
857 |
statusOper =HA_E10_MCMD_ERR; |
858 |
} |
859 |
else |
860 |
{ |
861 |
/* Check if MCMD in header position has been deleted */ |
862 |
if(mcdmDeleteFlag && MA_HeaderMcmd->Type==NULL_MCMD) |
863 |
{ |
864 |
/* Search the more recent MCMD to execute, */ |
865 |
/* and put it in the header position */ |
866 |
MA_ifUpdateMcmdHeader(MA_HeaderMcmd,obt); |
867 |
} |
868 |
} |
869 |
} |
870 |
if (mcdmDeleteFlag) |
871 |
{ |
872 |
/* MCMD Timetag buffer not full */ |
873 |
MA_TimetagBufFullFlag =FALSE; |
874 |
} |
875 |
|
876 |
/* Release MCMDArea resource */ |
877 |
status =OS_piResourceRelease (MA_RES); |
878 |
} |
879 |
else |
880 |
{ |
881 |
if (status==UNSATISFIED || status==INVALID_ID) |
882 |
{ |
883 |
/*@LOG Semaphore error LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_SEMAPHORE_ERR,status); */ |
884 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
885 |
status =HA_E10_SEMAPHORE_ERR; |
886 |
} |
887 |
} |
888 |
/* If resource is correctly obtaneid return operation status */ |
889 |
if(status == SUCCESSFUL) |
890 |
{ |
891 |
status =statusOper; |
892 |
} |
893 |
return (status); |
894 |
|
895 |
} |
896 |
|
897 |
|
898 |
|
899 |
/*****************************************************************************/ |
900 |
/* @Function: MA_opGetTlmTimetagRTE */ |
901 |
/* @Purpose : */ |
902 |
/* The function returns the MCMD identifier and timetag in the RTE */ |
903 |
/* telemetry format. The maximum number of returned MCMD is defined by the */ |
904 |
/* constant MAX_TLM_MCMD_TIMETAG and is the first met in the list. */ |
905 |
/* */ |
906 |
/* @@ */ |
907 |
/* @Parameter Name @Mode @Description */ |
908 |
/* McmdBuffer OUT Buffer where MCMD are stored */ |
909 |
/* status_code OUT Return code */ |
910 |
/* @@ */ |
911 |
/*****************************************************************************/ |
912 |
|
913 |
status_code MA_opGetTlmTimetagRTE (MA_TLM_TIMETAG_RTE* McmdBuffer) |
914 |
{ |
915 |
MA_HEADER_MCMD* pH; |
916 |
MA_TLM_MCMD* pB; |
917 |
unsigned short i; |
918 |
unsigned int tt; |
919 |
|
920 |
/* Initialize buffer area */ |
921 |
for (i=0, pB =&McmdBuffer->Mcmd[0]; i<MAX_TLM_MCMD_TIMETAG; i++,pB++) |
922 |
{ |
923 |
pB->Id =0; |
924 |
pB->TimetagMsw =0; |
925 |
pB->TimetagLsw =0; |
926 |
} |
927 |
|
928 |
/* Copy in Telemetry buffer area the MCMDs */ |
929 |
for (i=0,pH =MA_HeaderMcmd,pB =&McmdBuffer->Mcmd[0],tt=0; |
930 |
(tt<MA_TimetagCounter)&&(i<MAX_TLM_MCMD_TIMETAG); i++,pH++,pB++) |
931 |
{ |
932 |
/* Check if valid MCMD */ |
933 |
if(pH->Type) |
934 |
{ |
935 |
/* Put MCMD ID and timetag in telemetry area */ |
936 |
pB->Id =(unsigned short)(MA_McmdId[pH->Type]); |
937 |
pB->TimetagMsw =(unsigned short)(pH->TimeTag>>16); |
938 |
pB->TimetagLsw =(unsigned short)(pH->TimeTag&0xffff); |
939 |
tt++; |
940 |
} |
941 |
} |
942 |
|
943 |
return (SUCCESSFUL); |
944 |
} |
945 |
|
946 |
|
947 |
|
948 |
/*****************************************************************************/ |
949 |
/* @Function: MA_opGetMcmdTimetagQueueFull */ |
950 |
/* @Purpose : */ |
951 |
/* The function returns the timetag MCMD queue full flag. */ |
952 |
/* */ |
953 |
/* @@ */ |
954 |
/* @Parameter Name @Mode @Description */ |
955 |
/* QueueFullFlag OUT Variable where flag is stored */ |
956 |
/* status_code OUT Return code */ |
957 |
/* @@ */ |
958 |
/*****************************************************************************/ |
959 |
|
960 |
status_code MA_opGetMcmdTimetagQueueFull (unsigned int* QueueFullFlag) |
961 |
{ |
962 |
|
963 |
*QueueFullFlag =MA_TimetagBufFullFlag; |
964 |
return (SUCCESSFUL); |
965 |
|
966 |
} |
967 |
|
968 |
|
969 |
|
970 |
/*****************************************************************************/ |
971 |
/* @Function: MA_opGetBufferMCMD */ |
972 |
/* @Purpose : */ |
973 |
/* The function returns a MCMD buffer from partition resource. */ |
974 |
/* In the TimetagFlag parameter is specified if the buffer to obtain */ |
975 |
/* belongs to the partition of the immediate MCMD or with timetag */ |
976 |
/* */ |
977 |
/* @@ */ |
978 |
/* @Parameter Name @Mode @Description */ |
979 |
/* TimetagFlag IN Flag to indicate which partition use */ |
980 |
/* Option IN Flag which defines if await or no the */ |
981 |
/* resource availability (WAIT, NO_WAIT) */ |
982 |
/* Timeout IN Timeout value for WAIT option */ |
983 |
/* BufMCMD OUT Pointer to partition buffer */ |
984 |
/* status_code OUT Return code */ |
985 |
/* @@ */ |
986 |
/*****************************************************************************/ |
987 |
|
988 |
status_code MA_opGetBufferMCMD (void** BufMCMD, |
989 |
unsigned int TimeTagFalg) |
990 |
{ |
991 |
status_code status; |
992 |
status_code statusOper; |
993 |
|
994 |
if (((status = MA_opLock1553())==SUCCESSFUL)) |
995 |
{ |
996 |
/* Check if immediate or timetag MCMD */ |
997 |
if (TimeTagFalg == IMMEDIATE_MCMD) |
998 |
{ |
999 |
/* Get the Immadiate MCMDs buffer */ |
1000 |
statusOper =OS_piPartGetBuffer(MA_PART_IM,BufMCMD); |
1001 |
if (statusOper != SUCCESSFUL) |
1002 |
{ |
1003 |
/*@LOG Partition not obtained LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_PARTITION_ERR,statusOper); */ |
1004 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,statusOper); |
1005 |
statusOper =HA_E10_PARTITION_ERR; |
1006 |
} |
1007 |
} |
1008 |
else if (TimeTagFalg == TIMETAG_MCMD) |
1009 |
{ |
1010 |
/* Get the Timetag MCMD buffer */ |
1011 |
statusOper =OS_piPartGetBuffer(MA_PART_TT,BufMCMD); |
1012 |
if (statusOper != SUCCESSFUL) |
1013 |
{ |
1014 |
/*@LOG Partition not obtained LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_PARTITION_ERR,statusOper); */ |
1015 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,statusOper); |
1016 |
statusOper =HA_E10_PARTITION_ERR; |
1017 |
} |
1018 |
} |
1019 |
else |
1020 |
{ |
1021 |
statusOper =HA_E10_PARTITION_ERR; |
1022 |
} |
1023 |
|
1024 |
/* Release MCMDArea resource */ |
1025 |
MA_opRelease1553(); |
1026 |
} |
1027 |
else |
1028 |
{ |
1029 |
if (status==UNSATISFIED || status==INVALID_ID) |
1030 |
{ |
1031 |
/*@LOG Semaphore error LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_SEMAPHORE_ERR,status); */ |
1032 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1033 |
status =HA_E10_SEMAPHORE_ERR; |
1034 |
} |
1035 |
} |
1036 |
/* If resource is correctly obtaneid return operation status */ |
1037 |
if(status == SUCCESSFUL) |
1038 |
{ |
1039 |
status =statusOper; |
1040 |
} |
1041 |
return (status); |
1042 |
|
1043 |
|
1044 |
|
1045 |
} |
1046 |
|
1047 |
|
1048 |
|
1049 |
/*****************************************************************************/ |
1050 |
/* @Function: MA_opDelBufferMCMD */ |
1051 |
/* @Purpose : */ |
1052 |
/* The function releases a MCMD buffer from partition resource. */ |
1053 |
/* In the TimetagFlag parameter is specified if the buffer to release */ |
1054 |
/* belongs to the partition of the immediate MCMD or with timetag. */ |
1055 |
/* */ |
1056 |
/* @@ */ |
1057 |
/* @Parameter Name @Mode @Description */ |
1058 |
/* BufMCMD IN Pointer to the buffer that must be released */ |
1059 |
/* TimetagFlag IN Flag to indicate which partition use */ |
1060 |
/* Option IN Flag which defines if await or no the */ |
1061 |
/* resource availability (WAIT, NO_WAIT) */ |
1062 |
/* Timeout IN Timeout value for WAIT option */ |
1063 |
/* status_code OUT Return code */ |
1064 |
/* @@ */ |
1065 |
/*****************************************************************************/ |
1066 |
|
1067 |
status_code MA_opDelBufferMCMD (void* BufMCMD, |
1068 |
unsigned int TimetagFalg) |
1069 |
{ |
1070 |
status_code status; |
1071 |
status_code statusOper; |
1072 |
|
1073 |
|
1074 |
if (((status = MA_opLock1553())==SUCCESSFUL)) |
1075 |
{ |
1076 |
/* Checks if immediate or timetag MCMD */ |
1077 |
if (TimetagFalg == IMMEDIATE_MCMD) |
1078 |
{ |
1079 |
/* Deletes the Immadiate MCMDs buffer */ |
1080 |
statusOper =OS_piPartReturnBuffer(MA_PART_IM,BufMCMD); |
1081 |
if (statusOper != SUCCESSFUL) |
1082 |
{ |
1083 |
/*@LOG Partition not released LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_PARTITION_ERR,statusOper); */ |
1084 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,statusOper); |
1085 |
statusOper =HA_E10_PARTITION_ERR; |
1086 |
} |
1087 |
} |
1088 |
else if (TimetagFalg == TIMETAG_MCMD) |
1089 |
{ |
1090 |
/* Delete the Timetag MCMDs buffer */ |
1091 |
statusOper =OS_piPartReturnBuffer(MA_PART_TT,BufMCMD); |
1092 |
if(statusOper != SUCCESSFUL) |
1093 |
{ |
1094 |
|
1095 |
/*@LOG Partition not released LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_PARTITION_ERR,statusOper); */ |
1096 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,statusOper); |
1097 |
statusOper =HA_E10_PARTITION_ERR; |
1098 |
} |
1099 |
} |
1100 |
else |
1101 |
{ |
1102 |
statusOper =HA_E10_PARTITION_ERR; |
1103 |
} |
1104 |
|
1105 |
/* Release MCMDArea resource */ |
1106 |
MA_opRelease1553(); |
1107 |
} |
1108 |
else |
1109 |
{ |
1110 |
/*@LOG Semaphore error LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MA,HA_E10_SEMAPHORE_ERR,status); */ |
1111 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1112 |
status =HA_E10_SEMAPHORE_ERR; |
1113 |
} |
1114 |
/* If resource is correctly obtaneid return operation status */ |
1115 |
if(status == SUCCESSFUL) |
1116 |
{ |
1117 |
status =statusOper; |
1118 |
} |
1119 |
return (status); |
1120 |
|
1121 |
} |
1122 |
|
1123 |
/*****************************************************************************/ |
1124 |
/* @Function: MA_opLock1553 */ |
1125 |
/* @Purpose : */ |
1126 |
/* This function lock the 1553 Buffer shared resource */ |
1127 |
/* */ |
1128 |
/* @@ */ |
1129 |
/* @Parameter Name @Mode @Description */ |
1130 |
/* SM_EXITCODE OUT Lock HBUS request result */ |
1131 |
/* @@ */ |
1132 |
/*****************************************************************************/ |
1133 |
status_code MA_opLock1553() |
1134 |
{ |
1135 |
status_code status = SUCCESSFUL; |
1136 |
unsigned int intLevel; |
1137 |
|
1138 |
OS_piInterDisable(&intLevel); |
1139 |
if (MA_1553IsLocked) |
1140 |
status = UNSATISFIED; |
1141 |
else |
1142 |
MA_1553IsLocked = TRUE; |
1143 |
OS_piInterEnable(intLevel); |
1144 |
return status; |
1145 |
} |
1146 |
|
1147 |
/*****************************************************************************/ |
1148 |
/* @Function: MA_opRelease1553 */ |
1149 |
/* @Purpose : */ |
1150 |
/* This function release the 1553 Buffer shared resource */ |
1151 |
/* */ |
1152 |
/* @@ */ |
1153 |
/* @Parameter Name @Mode @Description */ |
1154 |
/* @@ */ |
1155 |
/*****************************************************************************/ |
1156 |
void MA_opRelease1553() |
1157 |
{ |
1158 |
unsigned int intLevel; |
1159 |
|
1160 |
OS_piInterDisable(&intLevel); |
1161 |
MA_1553IsLocked = FALSE; |
1162 |
OS_piInterEnable(intLevel); |
1163 |
} |
1164 |
|