/**************************************************************************** * F i l e D a t a * * Module : RTEMSInterface * C.I. No. : * $Revision: 1.17 $ * $Date: 2005/02/21 08:58:29 $ * Belonging to : * * $RCSFile$ * Program Type : * Sub-modules : * **************************************************************************** * S W D e v e l o p m e n t E n v i r o n m e n t * * Host system : * SW Compiler : * $Author: sebastiani $ * : **************************************************************************** * U p d a t i n g * * $Log: OS_rtems_INFN_p.c,v $ * Revision 1.17 2005/02/21 08:58:29 sebastiani * all log comments completed * * Revision 1.16 2004/12/21 14:16:23 sebastiani * OS_piSuspendUnlessEvent bugfix if timeout is zero * * Revision 1.15 2004/11/10 17:00:00 sebastiani * - GS_COMPILE directive introduced and be undef by default * - automatic flush mechanism by run manager mailbox timeout * * Revision 1.14 2004/09/17 15:01:00 faber * LU_INFN_LOG flags fixing * * Revision 1.13 2004/09/09 14:52:55 sebastiani * using PreparePage to send cmd to idaq/FE * added some test * added trigger param * added/tested Force Send KHB_to_FE * added/tested Send Cmd to IDAQ/FE * * Revision 1.12 2004/08/26 16:54:34 sebastiani * version work fine * * Revision 1.11 2004/06/01 16:41:19 sebastiani * EventReceive ANY * * Revision 1.10 2004/05/26 15:31:54 sebastiani * some fixing on CAL/TRK/ACQ * * Revision 1.9 2004/05/26 11:15:16 sebastiani * SentTrigger() introduced; RM_TaskSuspendUnlessSINT() introduced * * Revision 1.8 2004/03/09 16:41:51 sebastiani * introduced LU_TRACE in OS_rtems_INFN_p * check in LU_TRACE of interrupt mode * * Revision 1.7 2004/03/09 09:39:27 faber * LU_TRACE system introduced * * Revision 1.6 2003/11/20 10:24:46 faber * - interrupt_is_in_progress check inside the OS_Obtain * - CM_RETURN_CODE type starting from RTEMS_STATUS_CODES_LAST, in order to have a unique error space coding * * Revision 1.5 2003/10/21 16:09:12 alfarano * LU_LOG_INFN replacement for all remaining original log functions * * Revision 1.4 2003/08/27 09:49:17 wizard * Fix last sector in donwload. * Set Sector size to 1024*1015 * Fix Donwload procedure... ( set size set lastsector flag.....) * bye * * Revision 1.3 2003/08/26 07:41:20 faber * Events macros introduced * * Revision 1.2 2003/08/07 08:44:40 wizard * *** empty log message *** * * Revision 1.1.1.1 2003/08/04 09:40:22 sebastiani * Imported sources laben rel. 19.06.2003 integrated with pam2 * * Revision 1.5 2003/07/25 10:31:23 sebastiani * bug fix semaphore creation and mailbox creation * * Revision 1.4 2003/07/10 15:56:27 sebastiani * *** empty log message *** * * Revision 1.3 2003/07/03 12:39:29 sebastiani * *** empty log message *** * * Revision 1.2 2003/06/09 17:04:28 sebastiani * Added handling of partition to manage INFN MCMD. * * Revision 1.1.1.1 2003/05/27 08:13:24 wizard * Import of the Official Laben CD Release Software as the pamela-EM_delivery_20030521_1454.tar.bz2 * * Revision 1.6 2002/04/24 17:15:51 ale * added MessageQueueGetNumberPending * * Revision 1.5 2002/04/24 12:15:16 ale * Fixed start task * * Revision 1.4 2002/04/24 09:45:57 ale * added new task (HK) * * Revision 1.3 2002/04/23 14:31:09 zulia * converted to unix format * * Revision 1.2 2002/04/23 14:22:07 zulia * Modified header file * * * *****************************************************************************/ /*============================= Include File ================================*/ #include #include #include #include #include #define __FILEID__ _OS_rtems_INFN_p__c #include #include #include LU_DECL_MASK(); LU_DECL_TRACE(); #include /*****************************************************************************/ /*==================== RTEMS configuration variables ========================*/ /*****************************************************************************/ /* @Variable: Task_id */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS tasks identification. */ /* @@ */ /*****************************************************************************/ static rtems_id Task_INFN_id [MAX_INFN_TASKS]; /*****************************************************************************/ /* @Variable: Task_name */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS tasks name. */ /* @@ */ /*****************************************************************************/ static rtems_name Task_INFN_name [MAX_INFN_TASKS]; /*****************************************************************************/ /* @Variable: Msg_id */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS mailboxes identification. */ /* @@ */ /*****************************************************************************/ static rtems_id Msg_INFN_id [MAX_INFN_MBOX]; /*****************************************************************************/ /* @Variable: Msg_name */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS mailboxes name. */ /* @@ */ /*****************************************************************************/ static rtems_name Msg_INFN_name [MAX_INFN_MBOX]; /*****************************************************************************/ /* @Variable: Sem_id */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS semaphores identification. */ /* @@ */ /*****************************************************************************/ static rtems_id Sem_INFN_id [MAX_INFN_RES]; /*****************************************************************************/ /* @Variable: Sem_name */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS semaphores name. */ /* @@ */ /*****************************************************************************/ static rtems_name Sem_INFN_name [MAX_INFN_RES]; /*****************************************************************************/ /* @Variable: Part_id */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS patitios identification. */ /* @@ */ /*****************************************************************************/ static rtems_id Part_INFN_id [MAX_INFN_PART]; /*****************************************************************************/ /* @Variable: Part_name */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS patitios name. */ /* @@ */ /*****************************************************************************/ static rtems_name Part_INFN_name [MAX_INFN_PART]; /*****************************************************************************/ /* @Variable: Tim_id */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS timers identification. */ /* @@ */ /*****************************************************************************/ static rtems_id Tim_INFN_id [MAX_INFN_TIM]; /*****************************************************************************/ /* @Variable: Tim_name */ /* @Purpose : */ /* Array of retems_id */ /* RTEMS timers name. */ /* @@ */ /*****************************************************************************/ static rtems_name Tim_INFN_name [MAX_INFN_TIM]; /*****************************************************************************/ /* @Variable: MA_Partition */ /* @Purpose : */ /* Array of rtems_unsigned32 */ /* MCMD area patition. */ /* @@ */ /*****************************************************************************/ static rtems_unsigned32 MCMD_INFN_Partition [MCMD_INFN_PART_SIZE]; /*****************************************************************************/ /*============ R T E M S P R O V I D E D I N T E R F A C E =============*/ /*****************************************************************************/ /* @Function: OS_piInitOS */ /* @Purpose : */ /* Initialization of the Operating System global resources. */ /* All Task, mailboxes, semaphores, partitons, timers are created and */ /* allocated. RTEMS directives are called for resources creation. */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* IN */ /* status_code OUT Return code */ /* @@ */ /*****************************************************************************/ status_code OS_piInitOS_INFN(void) { rtems_status_code status; rtems_time_of_day time; rtems_unsigned32 tmpPart; rtems_unsigned32 trashPart; unsigned long statusRc; unsigned int i; unsigned char c; status =SUCCESSFUL; statusRc =SUCCESSFUL; /*===========================================================================*/ /*==== TASKS CREATION ========================*/ for (i=1,c=49; i NULL_INFN_PART && Part < MAX_INFN_PART) { status = rtems_partition_get_buffer(Part_INFN_id[Part],pBuf); }else status = RTEMS_INVALID_ID; return status; } /*****************************************************************************/ /* @Function: OS_piPartReturnBuffer */ /* @Purpose : */ /* The function returns the buffer specified to the partition. */ /* The RTEMS directive is called to performs the return buffer to a */ /* partition. */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* Part IN Partition ID */ /* pBuf IN Partition buffer pointer released */ /* status_code OUT Return code (RTEMS directive status code) */ /* @@ */ /*****************************************************************************/ status_code OS_piPartReturnBuffer_INFN ( unsigned int Part, void* pBuf) { status_code status; if(Part > NULL_INFN_PART && Part < MAX_INFN_PART) { status = rtems_partition_return_buffer(Part_INFN_id[Part],pBuf); }else status = RTEMS_INVALID_ID; return status; } /*****************************************************************************/ /* @Function: OS_pEventSend */ /* @Purpose : */ /* Send an event to a task */ /* @@ */ /* @Parameter Name @Mode @Description */ /*****************************************************************************/ status_code OS_piEventSend(unsigned int Task,rtems_event_set event_in) { /* Check Task ID validity */ status_code status; LU_TRACE(__FILEID__,__LINE__); if(Task < MAX_INFN_TASK_2) status = rtems_event_send(Task_INFN_id[Task],event_in); else status =RTEMS_INVALID_ID; LU_TRACE(__FILEID__,__LINE__); return (status); } status_code OS_piEventReceive(rtems_event_set event_in, rtems_option option_set,rtems_interval timeout,rtems_event_set *event_out) { status_code status; LU_TRACE(__FILEID__,__LINE__); status = rtems_event_receive(event_in,option_set,timeout,event_out); LU_TRACE(__FILEID__,__LINE__); return status; } status_code OS_piSuspendUnlessEvent(rtems_event_set event_in, rtems_interval timeout, rtems_event_set *event_out) { rtems_event_set local_event_out; status_code s; s = OS_piEventReceive(event_in,timeout?RTEMS_WAIT:RTEMS_NO_WAIT,timeout,&local_event_out); if(event_out != NULL) *event_out = local_event_out; return s; } /* the proceduce clean an event or an event set. If the event flag(s) is zero ignore this, otherwise receives the event and clear it. the function always return successful */ status_code OS_piEventClear(rtems_event_set event_in) { rtems_event_set unused; return rtems_event_receive(event_in,RTEMS_EVENT_ANY|RTEMS_NO_WAIT,0,&unused); }