/[PAMELA software]/quicklook/dataToXML/Data/compilationInfo/src/INFN/OS_rtems_INFN_p.c
ViewVC logotype

Contents of /quicklook/dataToXML/Data/compilationInfo/src/INFN/OS_rtems_INFN_p.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Apr 25 09:00:20 2006 UTC (19 years, 2 months ago) by kusanagi
Branch: MAIN
CVS Tags: dataToXML1_02/01, dataToXML1_02/00, dataToXML1_03/00, dataToXML1_03/01, dataToXML1_00/00, firstRelease, dataToXML1_01/00, dataToXML1_03_02, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
These program extract in an XML format the info contained into the ROOT files generated by YODA from the PAMELA data. To visualize the XML files in a more human readable format a collection of XSL files are given in the Data subfolder.

1 /****************************************************************************
2 * F i l e D a t a
3 *
4 * Module : RTEMSInterface
5 * C.I. No. :
6 * $Revision: 1.17 $
7 * $Date: 2005/02/21 08:58:29 $
8 * Belonging to :
9 *
10 * $RCSFile$
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: OS_rtems_INFN_p.c,v $
25 * Revision 1.17 2005/02/21 08:58:29 sebastiani
26 * all log comments completed
27 *
28 * Revision 1.16 2004/12/21 14:16:23 sebastiani
29 * OS_piSuspendUnlessEvent bugfix if timeout is zero
30 *
31 * Revision 1.15 2004/11/10 17:00:00 sebastiani
32 * - GS_COMPILE directive introduced and be undef by default
33 * - automatic flush mechanism by run manager mailbox timeout
34 *
35 * Revision 1.14 2004/09/17 15:01:00 faber
36 * LU_INFN_LOG flags fixing
37 *
38 * Revision 1.13 2004/09/09 14:52:55 sebastiani
39 * using PreparePage to send cmd to idaq/FE
40 * added some test
41 * added trigger param
42 * added/tested Force Send KHB_to_FE
43 * added/tested Send Cmd to IDAQ/FE
44 *
45 * Revision 1.12 2004/08/26 16:54:34 sebastiani
46 * version work fine
47 *
48 * Revision 1.11 2004/06/01 16:41:19 sebastiani
49 * EventReceive ANY
50 *
51 * Revision 1.10 2004/05/26 15:31:54 sebastiani
52 * some fixing on CAL/TRK/ACQ
53 *
54 * Revision 1.9 2004/05/26 11:15:16 sebastiani
55 * SentTrigger() introduced; RM_TaskSuspendUnlessSINT() introduced
56 *
57 * Revision 1.8 2004/03/09 16:41:51 sebastiani
58 * introduced LU_TRACE in OS_rtems_INFN_p
59 * check in LU_TRACE of interrupt mode
60 *
61 * Revision 1.7 2004/03/09 09:39:27 faber
62 * LU_TRACE system introduced
63 *
64 * Revision 1.6 2003/11/20 10:24:46 faber
65 * - interrupt_is_in_progress check inside the OS_Obtain
66 * - CM_RETURN_CODE type starting from RTEMS_STATUS_CODES_LAST, in order to have a unique error space coding
67 *
68 * Revision 1.5 2003/10/21 16:09:12 alfarano
69 * LU_LOG_INFN replacement for all remaining original log functions
70 *
71 * Revision 1.4 2003/08/27 09:49:17 wizard
72 * Fix last sector in donwload.
73 * Set Sector size to 1024*1015
74 * Fix Donwload procedure... ( set size set lastsector flag.....)
75 * bye
76 *
77 * Revision 1.3 2003/08/26 07:41:20 faber
78 * Events macros introduced
79 *
80 * Revision 1.2 2003/08/07 08:44:40 wizard
81 * *** empty log message ***
82 *
83 * Revision 1.1.1.1 2003/08/04 09:40:22 sebastiani
84 * Imported sources laben rel. 19.06.2003 integrated with pam2
85 *
86 * Revision 1.5 2003/07/25 10:31:23 sebastiani
87 * bug fix semaphore creation and mailbox creation
88 *
89 * Revision 1.4 2003/07/10 15:56:27 sebastiani
90 * *** empty log message ***
91 *
92 * Revision 1.3 2003/07/03 12:39:29 sebastiani
93 * *** empty log message ***
94 *
95 * Revision 1.2 2003/06/09 17:04:28 sebastiani
96 * Added handling of partition to manage INFN MCMD.
97 *
98 * Revision 1.1.1.1 2003/05/27 08:13:24 wizard
99 * Import of the Official Laben CD Release Software as the pamela-EM_delivery_20030521_1454.tar.bz2
100 *
101 * Revision 1.6 2002/04/24 17:15:51 ale
102 * added MessageQueueGetNumberPending
103 *
104 * Revision 1.5 2002/04/24 12:15:16 ale
105 * Fixed start task
106 *
107 * Revision 1.4 2002/04/24 09:45:57 ale
108 * added new task (HK)
109 *
110 * Revision 1.3 2002/04/23 14:31:09 zulia
111 * converted to unix format
112 *
113 * Revision 1.2 2002/04/23 14:22:07 zulia
114 * Modified header file
115 *
116 *
117 *
118 *****************************************************************************/
119
120 /*============================= Include File ================================*/
121
122 #include <tmacros.h>
123 #include <src/INFN/OS_rtems_INFN_p.h>
124 #include <src/INFN/OS_rtems_INFN_op.h>
125 #include <src/HKManager/HistoryArea/HA_HistoryArea_p.h>
126
127 #include <src/INFN/LU_SourceFileID_INFN.h>
128 #define __FILEID__ _OS_rtems_INFN_p__c
129 #include <src/INFN/PRH_ParamHandler_INFN.h>
130 #include <src/INFN/LU_LogUtility_INFN.h>
131 #include <src/INFN/PRH_ParamHandler_INFN_auto.h>
132 LU_DECL_MASK();
133 LU_DECL_TRACE();
134
135 #include <src/INFN/CM_Common_INFN.h>
136 /*****************************************************************************/
137 /*==================== RTEMS configuration variables ========================*/
138
139 /*****************************************************************************/
140 /* @Variable: Task_id */
141 /* @Purpose : */
142 /* Array of retems_id */
143 /* RTEMS tasks identification. */
144 /* @@ */
145 /*****************************************************************************/
146 static rtems_id Task_INFN_id [MAX_INFN_TASKS];
147
148 /*****************************************************************************/
149 /* @Variable: Task_name */
150 /* @Purpose : */
151 /* Array of retems_id */
152 /* RTEMS tasks name. */
153 /* @@ */
154 /*****************************************************************************/
155 static rtems_name Task_INFN_name [MAX_INFN_TASKS];
156
157 /*****************************************************************************/
158 /* @Variable: Msg_id */
159 /* @Purpose : */
160 /* Array of retems_id */
161 /* RTEMS mailboxes identification. */
162 /* @@ */
163 /*****************************************************************************/
164 static rtems_id Msg_INFN_id [MAX_INFN_MBOX];
165
166 /*****************************************************************************/
167 /* @Variable: Msg_name */
168 /* @Purpose : */
169 /* Array of retems_id */
170 /* RTEMS mailboxes name. */
171 /* @@ */
172 /*****************************************************************************/
173 static rtems_name Msg_INFN_name [MAX_INFN_MBOX];
174
175 /*****************************************************************************/
176 /* @Variable: Sem_id */
177 /* @Purpose : */
178 /* Array of retems_id */
179 /* RTEMS semaphores identification. */
180 /* @@ */
181 /*****************************************************************************/
182 static rtems_id Sem_INFN_id [MAX_INFN_RES];
183
184 /*****************************************************************************/
185 /* @Variable: Sem_name */
186 /* @Purpose : */
187 /* Array of retems_id */
188 /* RTEMS semaphores name. */
189 /* @@ */
190 /*****************************************************************************/
191 static rtems_name Sem_INFN_name [MAX_INFN_RES];
192
193 /*****************************************************************************/
194 /* @Variable: Part_id */
195 /* @Purpose : */
196 /* Array of retems_id */
197 /* RTEMS patitios identification. */
198 /* @@ */
199 /*****************************************************************************/
200 static rtems_id Part_INFN_id [MAX_INFN_PART];
201
202 /*****************************************************************************/
203 /* @Variable: Part_name */
204 /* @Purpose : */
205 /* Array of retems_id */
206 /* RTEMS patitios name. */
207 /* @@ */
208 /*****************************************************************************/
209 static rtems_name Part_INFN_name [MAX_INFN_PART];
210
211 /*****************************************************************************/
212 /* @Variable: Tim_id */
213 /* @Purpose : */
214 /* Array of retems_id */
215 /* RTEMS timers identification. */
216 /* @@ */
217 /*****************************************************************************/
218 static rtems_id Tim_INFN_id [MAX_INFN_TIM];
219
220 /*****************************************************************************/
221 /* @Variable: Tim_name */
222 /* @Purpose : */
223 /* Array of retems_id */
224 /* RTEMS timers name. */
225 /* @@ */
226 /*****************************************************************************/
227 static rtems_name Tim_INFN_name [MAX_INFN_TIM];
228
229 /*****************************************************************************/
230 /* @Variable: MA_Partition */
231 /* @Purpose : */
232 /* Array of rtems_unsigned32 */
233 /* MCMD area patition. */
234 /* @@ */
235 /*****************************************************************************/
236 static rtems_unsigned32 MCMD_INFN_Partition [MCMD_INFN_PART_SIZE];
237
238 /*****************************************************************************/
239
240 /*============ R T E M S P R O V I D E D I N T E R F A C E =============*/
241
242 /*****************************************************************************/
243 /* @Function: OS_piInitOS */
244 /* @Purpose : */
245 /* Initialization of the Operating System global resources. */
246 /* All Task, mailboxes, semaphores, partitons, timers are created and */
247 /* allocated. RTEMS directives are called for resources creation. */
248 /* */
249 /* @@ */
250 /* @Parameter Name @Mode @Description */
251 /* IN */
252 /* status_code OUT Return code */
253 /* @@ */
254 /*****************************************************************************/
255
256 status_code OS_piInitOS_INFN(void)
257 {
258 rtems_status_code status;
259 rtems_time_of_day time;
260 rtems_unsigned32 tmpPart;
261 rtems_unsigned32 trashPart;
262 unsigned long statusRc;
263 unsigned int i;
264 unsigned char c;
265
266 status =SUCCESSFUL;
267 statusRc =SUCCESSFUL;
268
269
270 /*===========================================================================*/
271 /*==== TASKS CREATION ========================*/
272 for (i=1,c=49; i<MAX_INFN_TASK_2; i++,c++)
273 {
274 Task_INFN_name[i] =rtems_build_name( 'T', 'S', 'K', c );
275 status =rtems_task_create(Task_INFN_name[i],255, RTEMS_MINIMUM_STACK_SIZE,
276 RTEMS_DEFAULT_MODES,RTEMS_DEFAULT_ATTRIBUTES,
277 &Task_INFN_id[i]);
278 if (status!=SUCCESSFUL)
279 {
280 /* Error during task resource creation, log in history area */
281 /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_OS,HA_E10_TSK_CREATION_ERR,status); */
282 LU_INFN_LOG(LU_FATAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
283 statusRc =HA_E2_INTERNAL_ERR;
284 } else
285 LU_TRACE_LOAD_TASK_INFO(i,Task_INFN_id[i]);
286 }
287
288
289
290
291 /*===========================================================================*/
292 /*==== TASKS MAILBOXES CREATION ===================*/
293 for (i=1,c=49; i<MAX_INFN_MESSAGE_QUEUES_2; i++,c++)
294 {
295
296 Msg_INFN_name[i] = rtems_build_name( 'M', 'B', 'X', c );
297 status =rtems_message_queue_create(Msg_INFN_name[i], MAX_INFN_MSG_MBOX_1,
298 MAX_INFN_MSG_MBOX_SIZE_1, RTEMS_PRIORITY,
299 &Msg_INFN_id[i]);
300 if (status!=SUCCESSFUL)
301 {
302 /* Error during mailbox resource creation, log in history area */
303 /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_OS,HA_E10_MBOX_CREATION_ERR,status); */
304 LU_INFN_LOG(LU_FATAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
305 statusRc =HA_E2_INTERNAL_ERR;
306 }
307 }
308 /*==== GENERIC MAILBOXES CREATION ================*/
309 for ( ; i<MAX_INFN_MBOX; i++,c++)
310 {
311
312 Msg_INFN_name[i] = rtems_build_name( 'M', 'B', 'X', c );
313 status =rtems_message_queue_create(Msg_INFN_name[i], MAX_INFN_MSG_MBOX_2,
314 MAX_INFN_MSG_MBOX_SIZE_2, RTEMS_PRIORITY,
315 &Msg_INFN_id[i]);
316 if (status!=SUCCESSFUL)
317 {
318 /* Error during mailbox resource creation, log in history area */
319 /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_OS,HA_E10_MBOX_CREATION_ERR,status); */
320 LU_INFN_LOG(LU_FATAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
321 statusRc =HA_E2_INTERNAL_ERR;
322 }
323 }
324
325
326 /*===========================================================================*/
327 /*==== SEMAPHORES CREATION ========================*/
328 for (i=1,c=49; i<MAX_INFN_RES; i++,c++)
329 {
330 Sem_INFN_name[i] =rtems_build_name( 'S', 'E', 'M', c );
331
332 /*
333 status =rtems_semaphore_create(Sem_INFN_name[i], 1,
334 RTEMS_FIFO | RTEMS_NO_INHERIT_PRIORITY |
335 RTEMS_BINARY_SEMAPHORE | RTEMS_LOCAL,
336 RTEMS_NO_PRIORITY_CEILING,&Sem_INFN_id[i]);
337
338 */
339
340 status =rtems_semaphore_create(Sem_INFN_name[i], 1,RTEMS_DEFAULT_ATTRIBUTES,
341 RTEMS_NO_PRIORITY_CEILING,&Sem_INFN_id[i]);
342
343 /*
344 status =rtems_semaphore_create(Sem_INFN_name[i], 1,
345 RTEMS_FIFO | RTEMS_INHERIT_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_LOCAL ,
346 RTEMS_NO_PRIORITY_CEILING,&Sem_INFN_id[i]);
347 */
348 if (status!=SUCCESSFUL)
349 {
350 /* Error during semaphore resource creation, log in history area */
351 /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_OS,HA_E10_SEM_CREATION_ERR,status); */
352 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
353 statusRc =HA_E2_INTERNAL_ERR;
354 }
355 }
356
357 /*===========================================================================*/
358 /*==== PARTITIONS CREATION ========================*/
359
360 for (i=1,c=1; i<MAX_INFN_PART; i++,c++)
361 {
362 Part_INFN_name[i] =rtems_build_name( 'P', 'I', 'N',c);
363 }
364
365 for (i=0 ; i < MCMD_INFN_PART_SIZE; i++)
366 MCMD_INFN_Partition[i] =0;
367
368 // MCMD partion creation
369 tmpPart = (rtems_unsigned32) &MCMD_INFN_Partition;
370 tmpPart &= 0xfffffff0;
371 status =rtems_partition_create(Part_INFN_name[MCMD_INFN_PART],
372 MCMD_INFN_Partition,
373 MCMD_INFN_PART_SIZE-4,
374 MCMD_INFN_PART_BUFFER_SIZE,
375 RTEMS_LOCAL,
376 &Part_INFN_id[MCMD_INFN_PART]
377 );
378 if(status != RTEMS_SUCCESSFUL) {
379 /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_OS,HA_E10_PAR_CREATION_ERR,status); */
380 LU_INFN_LOG(LU_FATAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
381 statusRc =HA_E2_INTERNAL_ERR;
382 }
383
384 /*===========================================================================*/
385 /*==== TIMERS CREATION ========================*/
386 for (i=1,c=49; i<MAX_INFN_TIM; i++,c++)
387 {
388 Tim_INFN_name[i] = rtems_build_name( 'T', 'I', c, ' ' );
389 status =rtems_timer_create(Tim_INFN_name[i], &Tim_INFN_id[i]);
390 if (status!=SUCCESSFUL)
391 {
392 /* Error during timer resource creation, log in history area */
393 /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_OS,HA_E10_TIM_CREATION_ERR,status); */
394 LU_INFN_LOG(LU_FATAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
395 statusRc =HA_E2_INTERNAL_ERR;
396 }
397 }
398
399 /*===========================================================================*/
400
401 return (statusRc);
402
403 }
404
405
406
407 /*****************************************************************************/
408 /* @Function: OS_piSWReset */
409 /* @Purpose : */
410 /* Reset the software. Destroys all obects created during the initialization */
411 /* of the INFN initialization. */
412 /* @@ */
413 /* @Parameter Name @Mode @Description */
414 /* IN */
415 /* return OUT */
416 /* @@ */
417 /*****************************************************************************/
418
419 #ifdef TEST_I
420 status_code OS_piSWReset_INFN() {
421 /*==== INFN TASKS DELETION ========================*/
422 int i;
423 status_code status;
424 for (i=1; i<MAX_INFN_TASK_2; i++)
425 {
426 status =rtems_task_delete(Task_INFN_id[i]);
427 if (status!=SUCCESSFUL)
428 {
429 /* Error during task resource creation, log in history area */
430 /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_OS,HA_E10_TSK_CREATION_ERR,status); */
431 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
432 return HA_E2_INTERNAL_ERR;
433 }
434 }
435 return SUCCESSFUL;
436 }
437 #endif // TEST_I
438
439 /*****************************************************************************/
440 /* @Function: OS_piTaskReady */
441 /* @Purpose : */
442 /* The function readies the task specified (Task param.). The starting */
443 /* address of the task is given Entry parameter. */
444 /* The RTEMS directive is called to performs the start task. */
445 /* */
446 /* @@ */
447 /* @Parameter Name @Mode @Description */
448 /* Task IN Task ID */
449 /* Entry IN Function entry point */
450 /* status_code OUT Return code (RTEMS directive status code) */
451 /* @@ */
452 /*****************************************************************************/
453
454 status_code OS_piTaskReady_INFN ( unsigned int Task,
455 void* Entry)
456 {
457 rtems_status_code status;
458
459 /* Check Task ID validity */
460 if(Task < MAX_INFN_TASK_2)
461 {
462 /* Start task */
463 status =rtems_task_start(Task_INFN_id[Task],(rtems_task_entry)Entry,Task);
464 }
465 else
466 {
467 status =RTEMS_INVALID_ID;
468 }
469 return (status);
470 }
471
472
473
474 /*****************************************************************************/
475 /* @Function: OS_piTaskPriority */
476 /* @Purpose : */
477 /* The function manipulates the task priority. The parameters -Task- and */
478 /* and -NewPriority_ identifies respectively the task ID and the new */
479 /* priority. The RTEMS directive is called to performs priority setting. */
480 /* */
481 /* @@ */
482 /* @Parameter Name @Mode @Description */
483 /* Task IN Task ID */
484 /* NewPriority IN Priority value */
485 /* status_code OUT Return code (RTEMS directive status code) */
486 /* OldPriority OUT Current priority */
487 /* @@ */
488 /*****************************************************************************/
489
490 status_code OS_piTaskPriority_INFN ( unsigned int Task,
491 unsigned int NewPriority,
492 unsigned int* OldPriority)
493 {
494 rtems_status_code status;
495
496 /* Check Task ID validity and Priority parameters range */
497 if(Task < MAX_INFN_TASK_2 && NewPriority < MAX_INFN_PRIORITY_RANGE)
498 {
499 /* Call RTEMS directive for priority setting */
500 status =rtems_task_set_priority(Task_INFN_id[Task],NewPriority,
501 (rtems_task_priority*)OldPriority);
502 }
503 else
504 {
505 status =RTEMS_INVALID_ID;
506 }
507 return (status);
508 }
509
510
511
512
513
514 /*****************************************************************************/
515 /* @Function: OS_piMsgQueueSend */
516 /* @Purpose : */
517 /* The function interface performs the send masssge to a mail box queue */
518 /* addressed. */
519 /* The RTEMS directive is called to performs the mailbox send message. */
520 /* */
521 /* @@ */
522 /* @Parameter Name @Mode @Description */
523 /* mBox IN Mailbox ID */
524 /* MsgToSend IN Poniter to message information */
525 /* MsgLenght IN Message lenght */
526 /* status_code OUT Return code (RTEMS directive status code) */
527 /* @@ */
528 /*****************************************************************************/
529
530 status_code OS_piMsgQueueSend_INFN(unsigned int mBox,
531 void* MsgToSend,
532 unsigned int MsgLenght)
533 {
534 rtems_status_code status;
535 LU_TRACE(__FILEID__,__LINE__);
536 /* Check Mailbox queue address validity */
537 if(mBox < MAX_INFN_MBOX)
538 {
539 /* RTEMS directive to send message to mailbox */
540 status =rtems_message_queue_send(Msg_INFN_id[mBox],MsgToSend,
541 (rtems_unsigned32)MsgLenght);
542 }
543 else
544 {
545 status =RTEMS_INVALID_ID;
546 }
547 LU_TRACE(__FILEID__,__LINE__);
548 return (status);
549
550 }
551
552
553
554 /*****************************************************************************/
555 /* @Function: OS_piMsgQueueReceive */
556 /* @Purpose : */
557 /* The function receives a message from the message queue specified in mBox */
558 /* parameter. The WAIT and NO_WAIT options of the -OptionSet- parameter */
559 /* allow the calling task to specify whether to wait for a message to become*/
560 /* available o return immediately. The -Timeout- parameter specifies the */
561 /* timeout value for WAIT option. If NO_TIMEOUT value is set the calling */
562 /* task wait forever. */
563 /* The RTEMS directive is called to performs the receive message. */
564 /* */
565 /* @@ */
566 /* @Parameter Name @Mode @Description */
567 /* mBox IN Mailbox ID */
568 /* OptionSet IN WAITt and NO_WAIT option */
569 /* Timeout IN Timeout value for Wait option */
570 /* status_code OUT Return code (RTEMS directive status code) */
571 /* MsgToRx OUT Buffer pointer where message is returned */
572 /* MsgSize OUT Size pointer where message size is returned */
573 /* @@ */
574 /*****************************************************************************/
575
576 status_code OS_piMsgQueueReceive_INFN ( unsigned int mBox,
577 void* MsgToRx,
578 unsigned int* MsgSize,
579 unsigned int OptionSet,
580 unsigned int Timeout)
581 {
582 rtems_status_code status;
583 LU_TRACE(__FILEID__,__LINE__);
584 /* Check Mailbox queue address validity */
585 if(mBox < MAX_INFN_MBOX)
586
587 /* RTEMS directive to receive message from the message queue */
588 status =rtems_message_queue_receive(Msg_INFN_id[mBox],MsgToRx,
589 (rtems_unsigned32 *)MsgSize,
590 OptionSet,Timeout);
591
592 else
593 status =RTEMS_INVALID_ID;
594
595 LU_TRACE(__FILEID__,__LINE__);
596 return (status);
597 }
598
599
600
601
602
603
604 /*****************************************************************************/
605 /* @Function: OS_piResourceObtain */
606 /* @Purpose : */
607 /* The function acquires the semaphore specified in the -Res- parameter. */
608 /* The WAIT and NO_WAIT options of the -OptionSet- parameter allow */
609 /* the calling task to specify whether to wait for a message to become */
610 /* available o return immediately. The -Timeout- parameter specifies the */
611 /* timeout value for WAIT option. If NO_TIMEOUT value is set the calling */
612 /* task wait forever. */
613 /* The RTEMS directive is called to performs the semaphore acquisition. */
614 /* */
615 /* @@ */
616 /* @Parameter Name @Mode @Description */
617 /* Res IN Semaphore ID */
618 /* OptionSet IN WAIT and NO_WAIT option */
619 /* Timeout IN Timeout value for Wait option */
620 /* status_code OUT Return code (RTEMS directive status code) */
621 /* @@ */
622 /*****************************************************************************/
623
624 status_code OS_piResourceObtain_INFN ( unsigned int Res,
625 unsigned int OptionSet,
626 unsigned int Timeout)
627 {
628 rtems_status_code status;
629 if(rtems_interrupt_is_in_progress()) {
630 /*@LOG OS_piResourceObtain_INFN: during interrupt. Bug !!*/
631 LU_INFN_LOG(LU_INTERNAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,0xffff);
632 return CM_RC_INTERRUPT_IS_IN_PROGRESS;
633 }
634 LU_TRACE(__FILEID__,__LINE__);
635 /* Check semaphore ID validity */
636 if(Res < MAX_INFN_RES)
637 /* RTEMS directive to obtain semaphore resource */
638 status =rtems_semaphore_obtain(Sem_INFN_id[Res], OptionSet, Timeout);
639 else
640 status =RTEMS_INVALID_ID;
641 LU_TRACE(__FILEID__,__LINE__);
642 return (status);
643
644 }
645
646
647
648 /*****************************************************************************/
649 /* @Function: OS_piResourceRelease */
650 /* @Purpose : */
651 /* The function releases the semaphore specified in the -Res- parameter. */
652 /* The RTEMS directive is called to performs the semaphore release. */
653 /* */
654 /* @@ */
655 /* @Parameter Name @Mode @Description */
656 /* Res IN Semaphore ID */
657 /* status_code OUT Return code (RTEMS directive status code) */
658 /* @@ */
659 /*****************************************************************************/
660
661 status_code OS_piResourceRelease_INFN ( unsigned int Res )
662 {
663 rtems_status_code status;
664 LU_TRACE(__FILEID__,__LINE__);
665 /* Check semaphore ID validity */
666 if(Res < MAX_INFN_RES)
667 /* RTEMS directive to release semaphore resource */
668 status =rtems_semaphore_release (Sem_INFN_id[Res]);
669 else
670 status =RTEMS_INVALID_ID;
671 LU_TRACE(__FILEID__,__LINE__);
672 return (status);
673
674 }
675
676
677
678 /*****************************************************************************/
679 /* @Function: OS_piStartTimer */
680 /* @Purpose : */
681 /* The function initiates the timer specified by -Tim- parameter. */
682 /* The timer is scheduled to fire after a time interval expressed in system */
683 /* ticks into -Time- parameter. When the timer fires, the timer service */
684 /* routine will be invoked with user data. */
685 /* The RTEMS directive is called to performs the start timer after interval.*/
686 /* */
687 /* @@ */
688 /* @Parameter Name @Mode @Description */
689 /* Tim IN Timer ID */
690 /* Time IN Interval time */
691 /* Routine IN Pointer to timer service routine */
692 /* UserData IN Pointer to user data */
693 /* status_code OUT Return code (RTEMS directive status code) */
694 /* @@ */
695 /*****************************************************************************/
696
697 status_code OS_piStartTimer_INFN ( unsigned int Tim,
698 unsigned int Time,
699 void* Routine,
700 void* UserData)
701 {
702 rtems_status_code status;
703 LU_TRACE(__FILEID__,__LINE__);
704 /* Check timer ID validity */
705 if (Tim < MAX_INFN_TIM)
706 /* RTEMS directive to start timeer */
707 status =rtems_timer_fire_after(Tim_INFN_id[Tim],Time,Routine,UserData);
708 else
709 status =RTEMS_INVALID_ID;
710 LU_TRACE(__FILEID__,__LINE__);
711 return (status);
712
713 }
714
715
716
717 /*****************************************************************************/
718 /* @Function: OS_piCancelTimer */
719 /* @Purpose : */
720 /* The function cancels the timer specified by -Tim- parameter. */
721 /* The RTEMS directive is called to performs the timer cancelation */
722 /* */
723 /* @@ */
724 /* @Parameter Name @Mode @Description */
725 /* Tim IN Timer ID */
726 /* status_code OUT Return code (RTEMS directive status code) */
727 /* @@ */
728 /*****************************************************************************/
729
730 status_code OS_piCancelTimer_INFN ( unsigned int Tim)
731 {
732 rtems_status_code status;
733 LU_TRACE(__FILEID__,__LINE__);
734 /* Check timer ID validity */
735 if (Tim < MAX_INFN_TIM)
736 /* RTEMS directive to cancel timer */
737 status =rtems_timer_cancel(Tim_INFN_id[Tim]);
738 else
739 status =RTEMS_INVALID_ID;
740 LU_TRACE(__FILEID__,__LINE__);
741 return (status);
742 }
743
744
745 /*****************************************************************************/
746 /* @Function: */
747 /* @Purpose : */
748 /* The function cancels the timer specified by -Tim- parameter. */
749 /* The RTEMS directive is called to performs the timer cancelation */
750 /* */
751 /* @@ */
752 /* @Parameter Name @Mode @Description */
753 /* Tim IN Timer ID */
754 /* status_code OUT Return code (RTEMS directive status code) */
755 /* @@ */
756 /*****************************************************************************/
757
758 status_code OS_piMessageQueueGetNumberPending_INFN (unsigned int mBox,
759 unsigned int* Count)
760 {
761 rtems_status_code status;
762 LU_TRACE(__FILEID__,__LINE__);
763 /* Check Task ID validity */
764 if(mBox < MAX_INFN_MBOX )
765 /* Call RTEMS directive for get the number of msgs pending on a queue */
766 status = rtems_message_queue_get_number_pending(Msg_INFN_id[mBox], Count);
767 else
768 status =RTEMS_INVALID_ID;
769 LU_TRACE(__FILEID__,__LINE__);
770 return (status);
771 }
772
773
774 /*****************************************************************************/
775 /* @Function: OS_piPartGetBuffer */
776 /* @Purpose : */
777 /* The function allows a buffer to be obtained from the partition specified */
778 /* in -Part- parameter. */
779 /* The RTEMS directive is called to performs the get buffer from a */
780 /* partition. */
781 /* */
782 /* @@ */
783 /* @Parameter Name @Mode @Description */
784 /* Part IN Partition ID */
785 /* status_code OUT Return code (RTEMS directive status code) */
786 /* pBuf OUT Partition buffer pointer returned */
787 /* @@ */
788 /*****************************************************************************/
789
790 status_code OS_piPartGetBuffer_INFN ( unsigned int Part,
791 void** pBuf) {
792 status_code status;
793 if(Part > NULL_INFN_PART &&
794 Part < MAX_INFN_PART) {
795 status = rtems_partition_get_buffer(Part_INFN_id[Part],pBuf);
796 }else
797 status = RTEMS_INVALID_ID;
798 return status;
799 }
800
801 /*****************************************************************************/
802 /* @Function: OS_piPartReturnBuffer */
803 /* @Purpose : */
804 /* The function returns the buffer specified to the partition. */
805 /* The RTEMS directive is called to performs the return buffer to a */
806 /* partition. */
807 /* */
808 /* @@ */
809 /* @Parameter Name @Mode @Description */
810 /* Part IN Partition ID */
811 /* pBuf IN Partition buffer pointer released */
812 /* status_code OUT Return code (RTEMS directive status code) */
813 /* @@ */
814 /*****************************************************************************/
815
816 status_code OS_piPartReturnBuffer_INFN ( unsigned int Part,
817 void* pBuf) {
818 status_code status;
819 if(Part > NULL_INFN_PART &&
820 Part < MAX_INFN_PART) {
821 status = rtems_partition_return_buffer(Part_INFN_id[Part],pBuf);
822 }else
823 status = RTEMS_INVALID_ID;
824 return status;
825 }
826
827
828 /*****************************************************************************/
829 /* @Function: OS_pEventSend */
830 /* @Purpose : */
831 /* Send an event to a task */
832 /* @@ */
833 /* @Parameter Name @Mode @Description */
834 /*****************************************************************************/
835
836 status_code OS_piEventSend(unsigned int Task,rtems_event_set event_in) {
837 /* Check Task ID validity */
838 status_code status;
839 LU_TRACE(__FILEID__,__LINE__);
840 if(Task < MAX_INFN_TASK_2)
841 status = rtems_event_send(Task_INFN_id[Task],event_in);
842 else
843 status =RTEMS_INVALID_ID;
844 LU_TRACE(__FILEID__,__LINE__);
845 return (status);
846 }
847
848
849 status_code OS_piEventReceive(rtems_event_set event_in, rtems_option option_set,rtems_interval timeout,rtems_event_set *event_out) {
850 status_code status;
851 LU_TRACE(__FILEID__,__LINE__);
852 status = rtems_event_receive(event_in,option_set,timeout,event_out);
853 LU_TRACE(__FILEID__,__LINE__);
854 return status;
855 }
856
857
858 status_code OS_piSuspendUnlessEvent(rtems_event_set event_in,
859 rtems_interval timeout,
860 rtems_event_set *event_out) {
861 rtems_event_set local_event_out;
862 status_code s;
863 s = OS_piEventReceive(event_in,timeout?RTEMS_WAIT:RTEMS_NO_WAIT,timeout,&local_event_out);
864 if(event_out != NULL)
865 *event_out = local_event_out;
866 return s;
867 }
868
869 /* the proceduce clean an event or an event set. If the event flag(s) is zero
870 ignore this, otherwise receives the event and clear it.
871 the function always return successful */
872 status_code OS_piEventClear(rtems_event_set event_in) {
873 rtems_event_set unused;
874 return rtems_event_receive(event_in,RTEMS_EVENT_ANY|RTEMS_NO_WAIT,0,&unused);
875 }

  ViewVC Help
Powered by ViewVC 1.1.23