/**************************************************************************** /* F i l e D a t a /* /* Module : FileManager /* C.I. No. : /* $Revision: 1.18 $ /* $Date: 2005/03/20 18:17:45 $ /* Belonging to : /* : /* $RCSfile: FT_MMSUManager_op.c,v $ /* 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: FT_MMSUManager_op.c,v $ /* Revision 1.18 2005/03/20 18:17:45 sebastiani /* PRH_VAR_TIM_MMSU_DMA_DELAY cancelled /* /* Revision 1.17 2005/03/06 14:54:16 sebastiani /* fix log /* /* Revision 1.16 2005/02/21 08:58:28 sebastiani /* all log comments completed /* /* Revision 1.15 2005/01/26 18:46:28 sebastiani /* *** empty log message *** /* /* Revision 1.14 2004/09/09 14:50:41 sebastiani /* add debug output console /* /* Revision 1.13 2004/08/26 16:54:07 sebastiani /* fix some bug /* /* Revision 1.12 2004/06/30 07:26:24 sebastiani /* *** empty log message *** /* /* Revision 1.11 2004/06/15 08:13:28 sebastiani /* FT_opPendingSaveRequests introduced /* /* Revision 1.10 2004/05/20 09:04:06 sebastiani /* ok /* /* Revision 1.9 2004/05/19 08:44:25 sebastiani /* fix bug /* /* Revision 1.8 2004/03/03 11:23:43 tassa /* Start downlink manager by timer+message /* /* Revision 1.7 2003/11/10 12:21:11 sebastiani /* FS_piInitFileSystem() not invoked any more inside the FT_opChangeOpMode. This fixes the bug that reinitialized the Mass Memory at every change to active/maintenance /* /* Revision 1.6 2003/10/21 16:09:12 alfarano /* LU_LOG_INFN replacement for all remaining original log functions /* /* Revision 1.5 2003/10/17 08:25:48 sebastiani /* FILE1 bugfixes, /* downlink various bugfixes, VRL switch on/off introduced, /* FT_ifStopDownLink_CallBack function introduced, /* "case" FT_STOP_DOWNLINK introduced for the MSSUManager task /* /* Revision 1.4 2003/09/10 13:44:00 laben /* New File System model: just one file used like a circular buffer. /* NEw donwlink procedure: downlink next sector until the timer expires. /* /* Revision 1.3 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.2 2003/08/07 08:44:14 wizard /* SIMULATOR bugs ifdef/ifndef corrected /* laben bug "GetFileInfo" for FS_ERC32 id accepted in order to fix SM_pi_GetPacket /* /* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani /* Imported sources laben rel. 19.06.2003 integrated with pam2 /* /* Revision 1.15 2003/06/09 10:23:22 aurora /* improved the management of data acquisition /* /* Revision 1.14 2003/05/06 15:43:28 aurora /* deleted the check of CMD I/F register on ISR WriteEOT. /* The transfer on CMD I/F doesn't rise any interrupt /* /* Revision 1.13 2003/04/11 08:24:55 aurora /* Fixed Memory Module TEST /* /* Revision 1.12 2003/03/12 10:53:49 aurora /* the channel for write on CMD is unlocked immediately after send /* /* Revision 1.11 2003/01/22 13:58:04 aurora /* removed bug in WriteEOT ISR /* /* Revision 1.10 2002/10/17 10:05:18 zulia /* fixed ON/OFF memory module /* optimised PIFReset /* /* Revision 1.9 2002/07/31 14:27:00 zulia /* Correct EXE_MEM_CONF and init memory module /* /* Revision 1.8 2002/05/09 13:44:26 aurora /* Column latchup recovery updated /* /* Revision 1.7 2002/05/09 08:16:34 zulia /* * acceptance release /* /* /*****************************************************************************/ /*============================= Include File ================================*/ #include #define __FILEID__ _FT_MMSUManager_op__c #include #include #include LU_DECL_MASK(); #include #include #include #include #include /*============================== local define ===============================*/ #define WPBEOT ERC32_INTERRUPT_EXTERNAL_4 #define RPBEOT ERC32_INTERRUPT_EXTERNAL_3 /*****************************************************************************/ /*======================== Object internal structure ========================*/ /*****************************************************************************/ /*======================== Object Internal variables ========================*/ /*****************************************************************************/ /* @Constant: FT_MemModTestDef */ /* @Purpose : */ /* Array of FT_MOD_TEST structures. */ /* Test pattern. */ /* @@ */ /*****************************************************************************/ const FT_MOD_TEST FT_MemModTestDef[]={ {FT_TEST_PATTERN_EN,FT_TEST_PATTERN_VAR,0x0000,FT_TEST_MOD_NOT_PERFORMED,0x0000}, {FT_TEST_PATTERN_EN,FT_TEST_PATTERN_FIX,0xaaaa,FT_TEST_MOD_NOT_PERFORMED,0x0000}, {FT_TEST_PATTERN_EN,FT_TEST_PATTERN_FIX,0x5555,FT_TEST_MOD_NOT_PERFORMED,0x0000}, {FT_TEST_PATTERN_EN,FT_TEST_PATTERN_FIX,0xffff,FT_TEST_MOD_NOT_PERFORMED,0x0000}, {FT_TEST_PATTERN_EN,FT_TEST_PATTERN_FIX,0x0000,FT_TEST_MOD_NOT_PERFORMED,0x0000}}; /*****************************************************************************/ /* @Variable: FT_MMSUStatus */ /* @Purpose : */ /* FT_ALL_MMSU_STATUS structure */ /* MMSU Local and Remote hardware status. */ /* @@ */ /*****************************************************************************/ static FT_MMSU_STATUS FT_MMSUStatus; /*****************************************************************************/ /* @Variable: FT_TestModuleStatus */ /* @Purpose : */ /* FT_TEST_MOD_STATUS structure */ /* Memory Module test status. */ /* @@ */ /*****************************************************************************/ static FT_TEST_MOD_STATUS FT_TestModuleStatus; /*****************************************************************************/ /* @Variable: FT_RWChannel */ /* @Purpose : */ /* FT_TEST_MOD_STATUS structure */ /* Info about the read channel: downlink status, file to be downlinked ... */ /* Info about the write channel: write enable/disable, store in progress ..*/ /* @@ */ /*****************************************************************************/ static FT_RW_CH FT_RWChannel; // XXXDEBUG MASSIMO BEGIN ------------------------------------------------------------------------------------------------------------------- // task a cui mandare la notifica di fine DOWNLOAD static UINT32 FT_task2notify_EOD; // XXXDEBUG MASSIMO END ------------------------------------------------------------------------------------------------------------------- /*****************************************************************************/ /*==== M M S U M a n a g e r O P E R A T I O N A L F U N C T I O N S ====*/ /*****************************************************************************/ /* @Function: FT_opInitMMSUManager */ /* @Purpose : */ /* The function initializes the MMSUManager object. The OS directive are */ /* called to set priority and to ready the MMSUManager task. */ /* The function also performs the following initializations: */ /* - PSCU status initalization */ /* - MMSU test running initialization */ /* - Last Bite filler word initialization */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* status_code OUT Return code */ /* @@ */ /*****************************************************************************/ status_code FT_opInitMMSUManager (void) { status_code status; unsigned int OldPriority; unsigned int i,c; status =SUCCESSFUL; /* Task initialization */ if (OS_piTaskReady(FT_TASK,FT_tkMMSUManager) != SUCCESSFUL) { /* Task is not correctly started */ /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_FT,HA_E10_TSK_READY_ERR,status); */ LU_INFN_LOG(LU_CRITICAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); status =UNSATISFIED; } if (OS_piTaskPriority(FT_TASK,MMSU_PRIORITY,&OldPriority) != SUCCESSFUL) { /* Task priority is not correctly updated */ /*@LOG LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_FT,HA_E10_TSK_PRIORITY_ERR,status); */ LU_INFN_LOG(LU_CRITICAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); status =UNSATISFIED; } /* DSHA status initalization */ FT_ifMMSUStatusInit(&FT_MMSUStatus,(void*)&FT_MemModTestDef[0]); /* MMSU test running initialization */ FT_TestModuleStatus.State =FT_TEST_NO_RUNNING; FT_TestModuleStatus.Module =0xffffffff; /* No Module index */ FT_TestModuleStatus.TestIdx =0xffffffff; /* No Pattern index */ /* Init the RWChannel */ FT_ifRWChannelInit(&FT_RWChannel, FT_MEM_MOD_1, &FT_MMSUStatus.Module[FT_MEM_MOD_1]); FT_RWChannel.CMDWriteFail = 0; return (status); } /*****************************************************************************/ /* @Function: FT_opSndMsgMMSUManager */ /* @Purpose : */ /* The function invokes the directive of the OS to send a message to the */ /* MMSUManager mailbox. */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* SndMsg IN Pointer to the message task information */ /* (MsgTsk type) */ /* status_code OUT Return code */ /* @@ */ /*****************************************************************************/ status_code FT_opSndMsgMMSUManager(MsgTsk* SndMsg) { status_code status; /* Call the OS directive to put a message into the task mailbox */ status =OS_piMsgQueueSend(FT_MAILBOX,SndMsg,sizeof(MsgTsk)); return (status); } /*****************************************************************************/ /* @Function: FT_tkMMSUManager */ /* @Purpose : */ /* The function is the task handler of the MMSUManager object. */ /* When a message is received into task mailbox it wakes up. */ /* The information contained in the message (MsgTsk structure) define */ /* parameters (Info field), and the operation type that the task performs */ /* (Code field). */ /* The MMSUManager task activity is to manage the MMSU operations. */ /* The operations performed by task are: */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* @@ */ /*****************************************************************************/ task FT_tkMMSUManager (task_argument unused) { MsgTsk RxMsg; unsigned int MsgSize; FT_SAVEREQUEST saveReq; unsigned int reqSize; while( FOREVER ) { RxMsg.Code =NULL_MSG_FT; /* Wait for a message to become available */ if ((OS_piMsgQueueReceive (FT_MAILBOX,(void*)&RxMsg, &MsgSize,NO_WAIT, 0)) == SUCCESSFUL) { /*@LOG MMSUManager Task: operation code received */ LU_INFN_LOG(LU_DEBUG_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,RxMsg.Code); switch (RxMsg.Code) { case FT_MCMD_DOWN_LINK : /*=== MCMD DOWN LINK management */ FT_ifMCMDDownLinkExec((MA_HEADER_MCMD*)RxMsg.Info, &FT_RWChannel); break; case FT_MCMD_BITE : /*=== MCMD BITE management */ FT_ifMCMDBiteExec((MA_HEADER_MCMD*)RxMsg.Info, &FT_MMSUStatus, &FT_TestModuleStatus, &FT_RWChannel); break; case FT_STOP_DOWNLINK: FT_ifStopDownLink(&FT_RWChannel); break; case FT_START_DOWNLINK: FT_ifStartDownLink(&FT_RWChannel); break; case FT_ABORT : /*=== MCMD ABORT management */ FT_ifMCMDAbordExec((MA_HEADER_MCMD*)RxMsg.Info, &FT_RWChannel, &FT_TestModuleStatus); break; case FT_MCMD_EXE_MEM_CONF :/*=== MCMD MEMERY.CONF.management */ FT_ifMCMDExeMemConf((MA_HEADER_MCMD*)RxMsg.Info, &FT_MMSUStatus, &FT_RWChannel); break; case FT_MEM_MODULE_TEST :/*=== Mem. Module TEST management */ FT_ifMemModuleTestExec(&FT_MMSUStatus, &FT_TestModuleStatus, (void*)&FT_MemModTestDef[0]); break; case FT_TEST_MODULE_END:/*=== End TEST module menagement */ FT_ifTestModuleEnd(*(unsigned int*)RxMsg.Info, &FT_MMSUStatus, &FT_TestModuleStatus); break; case FT_LATCHUP_RECOVERY:/*=== LatchUp recovery management */ FT_ifLatchUpRecovery(*(unsigned int*)RxMsg.Info, &FT_MMSUStatus, &FT_RWChannel); break; case FT_HW_ERROR_RECOVERY :/*=== HW error recovery management*/ FT_ifHwErrorRecovery(*(unsigned int*)RxMsg.Info, &FT_MMSUStatus, &FT_RWChannel); break; case FT_INIT_FS: FS_piInitFileSystem(); break; default: break; }; } if ( (OS_piMsgQueueReceive (SAVE_MBOX, &saveReq, &reqSize, WAIT, 20) == SUCCESSFUL)) { /* write pending save request on Memory Module */ FT_opPacket2MMSU (saveReq); } } } /*****************************************************************************/ /* @Function: FT_opMemBoardMod */ /* @Purpose : */ /* The function handles the Memory Module interrupt raised by the DRAMMA */ /* device due to an internal failure. The -MemModule- parameter */ /* specify the MMSU and Memory Module where the failure is matched. */ /* Different kinds of failure are managed: */ /* - Hardware OR and AND erorr. A message to MMSUManager is sent to */ /* manage HW error recovery. */ /* - Scrabbing Adrres Overflow error. This interrrupt normally disabled,*/ /* it is enabled only during the procedure of Memory Module scrabbing */ /* used in the Test or Bite operation. This interrupt goes active */ /* every time the scubber completes a cycle on the whole memory. */ /* At this time if the Bite operations are active, the Bite Down Link */ /* procedure is started. Otherwise if Memory Module Test operations */ /* are active is started the next Memory Module test. */ /* - Latch UP Monitor error. When this interrupt goes active, means */ /* that one or more columns of the memory have gone in Latch Up mode. */ /* The task invoked by the interrupt handler will provide to execute */ /* the Latch Up recovery procedure. */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ /* status_code OUT Return code */ /* @@ */ /*****************************************************************************/ status_code FT_opMemBoardMod (unsigned int MemModule) { #ifndef SIMULATOR status_code status; unsigned int pendingInt; unsigned int latchupBit; FT_MEM_MOD* pMemMod; unsigned int hwErr; unsigned int ch; /* Check parameters */ pMemMod =&FT_MMSUStatus.Module[MemModule]; /* Read all memory module interrupts */ FD_piDrammaRdRPBUSReg(MemModule,FD_PENDING_INT,&pendingInt); pendingInt =FD_MM_INTER_BIT(pendingInt); /* Check Memory Module interrupts */ if ((pendingInt & FD_MM_INT_HW_OR) || (pendingInt & FD_MM_INT_HW_AND)) { /*====== Hardware OR and AND erorr =============*/ /* Mask all memory module interrupts */ FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ALL); /* Read Hard Error Register */ FD_piDrammaRdRPBUSReg(MemModule,FD_HARD_ERROR_REG,&hwErr); /* HW error rocovery menagement */ FT_ifHwErrorInter(MemModule); /*======== Entry 11 Log in History Area ========*/ /*@LOG LOG_INFN HA_piLogHistoryEntry11(HA_E11_MEMORY_MODULE, HA_E11_MOD_INT_HW_ERR,MemModule, hwErr); */ LU_INFN_LOG(LU_CRITICAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,hwErr); } if (pendingInt & FD_MM_INT_SW_OVL) { /*====== Software Overflow error ===============*/ } if (pendingInt & FD_MM_INT_SA_OVL) { OS_piCancelTimer(FT_TIM); /*====== Scrabbing Adrres Overflow error =========*/ /* This function checks if Module is in TEST mode,*/ /* if is it Test Module procedure is managed */ FT_ifMemModuleTestInter (&FT_MMSUStatus,&FT_TestModuleStatus); /* Check if Module is in BITE mode */ if (pMemMod->Mode==FT_MODE_MEM_MOD_BITE) { /*========= Entry 0 Log in History Area ==========*/ /*@LOG LOG_INFN HA_piLogHistoryEntry0(HA_E0_EXITING,HA_E0_BITE,0); */ LU_INFN_LOG(LU_CRITICAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,0); /* Check if memory fill is OK */ if (pMemMod->State==FT_STATE_MOD_OK) { /* Interrupt unmask: LATCHUP_MONITOR,HW_OR,HW_AND */ /* Interrupt masked: SA_OVL ,SFT_OVL */ FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ABIL_ALL); /* Memory fill OK */ /* Start Down Link procedure */ pMemMod->Mode = FT_MODE_MEM_MOD_ON; } else { /* Memory fill not OK */ /* Close BITE operative mode */ pMemMod->Mode = FT_MODE_MEM_MOD_ON; } } } if (pendingInt & FD_MM_INT_LM_C_ALL) { /*=========== Latch UP Monitor error =============*/ FT_ifColLatchUpInter(MemModule,FD_MM_LTATCHUP_BIT(pendingInt)); /*======== Entry 11 Log in History Area ========*/ /*@LOG LOG_INFN HA_piLogHistoryEntry11(HA_E11_MEMORY_MODULE, HA_E11_MOD_INT_LATCHUP,MemModule, pendingInt); */ LU_INFN_LOG(LU_CRITICAL,LU_MASK(__FILEID__),__FILEID__,__LINE__,pendingInt); } /* Clear all Memory Module interrupts */ FD_piDrammaWrWPBUSReg(MemModule,FD_INTCLR,FD_MM_INT_ALL); #endif // SIMULATOR return (SUCCESSFUL); } /*****************************************************************************/ /* @Function: FT_opMemModuleON */ /* @Purpose : */ /* The function switches ON a Memory Module. */ /* The -MemModule- parameter specifies the Memory Module that must be */ /* switched ON. */ /* The Memory Module will be switched ON if module is OFF and his state is */ /* OK. The procedure to switch ON the 10 colums (8 columns date, 2 CRC */ /* columns) of th module is the following: */ /* - Clear and mask all Memory Module interrupts. */ /* - Program Dramma SCRUBBING and REFRESH register. */ /* - Switch ON the 10 columns programming ON a column at a time in */ /* the CONFIGURATION Register. One ms of delay is executed before */ /* activate the next column. */ /* - Check possible Latch Up monitor errors. */ /* - If Latch Up errors are found the recovery procedure is executed */ /* - If Memory Module switching is OK, a power-up memory sequence is */ /* started programmming DRAMMA INIT Register. Memory Module sectors */ /* are inserted into FAT. */ /* - Else Memory Module is put OFF and his state in FAIL. */ /* - Unmask all memory module interrupts. */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ /* status_code OUT Return code */ /* @@ */ /*****************************************************************************/ status_code FT_opMemModuleON (unsigned int MemModule) { #ifndef SIMULATOR status_code status; unsigned int retCode; FT_MEM_MOD* pMod; FT_MEM_MOD mod; unsigned int configRegVal; unsigned int memModule; unsigned int maskCol; unsigned int pendingVal; unsigned int colLatchup; unsigned int colEnable; unsigned int colError; unsigned int colOn; unsigned int i; /* Check parameters */ memModule =MemModule & FD_BOARD_ADDR_MASK; /* Get module pointer of the MMSU status structure */ pMod =&FT_MMSUStatus.Module[memModule]; /* Assign the Memory Module status structure to the local structure */ mod = *pMod; if (pMod->Mode==FT_MODE_MEM_MOD_OFF) { /* Memory Module OFF, try to switch ON */ status =FT_MEM_MOD_SW_ON_OK; /* Clear all Memory Module interrupts */ FD_piDrammaWrWPBUSReg (memModule,FD_INTCLR,FD_MM_INT_ALL); /* Mask all Memory Module interrupts */ FD_piDrammaWrWPBUSReg (memModule,FD_INTMSK,FD_MM_INT_ALL); /* Set Dramma SCRUBBING and REFRESH register */ FD_piDrammaWrWPBUSReg (memModule,FD_SCRUBBER_REFRESH,FD_SCRABBER_REFRESH_VALUE); /* Active the 10 Columns writing a CONFIGURATION REGISTER */ configRegVal =FD_CONFIG_REG_27_11_B | (MemModule << 22); for (i=0, maskCol =FD_CONFIG_REG_COL_01; iState==FT_STATE_MOD_OK) ? FT_MEM_MOD_ALREADY_ON: FT_MEM_MOD_STATE_FAIL; } return (status); #else return SUCCESSFUL; #endif // SIMULATOR } /*****************************************************************************/ /* @Function: FT_opMemModuleOFF */ /* @Purpose : */ /* The function switches OFF a Memory Module. */ /* The -MemModule- parameter specifies the Memory Module that */ /* must be switched OFF. */ /* The procedure to switch OFF all columns is the following: */ /* - Clear and mask all Memory Module interrupts. */ /* - Switch OFF all columns programming OFF a column at a time in */ /* the CONFIGURATION Register. One ms of delay is executed before */ /* activate the next column. */ /* - Unmask all memory module interrupts. */ /* */ /* @@ */ /* @Parameter Name @Mode @Description */ /* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ /* status_code OUT Return code */ /* @@ */ /*****************************************************************************/ status_code FT_opMemModuleOFF (unsigned int MemModule) { #ifndef SIMULATOR status_code status; unsigned int memModule; FT_MEM_MOD* pMod; FT_MEM_MOD mod; unsigned int configRegVal; unsigned int pendingVal; unsigned int maskCol; unsigned int i; /* Check parameters */ memModule =MemModule & FD_BOARD_ADDR_MASK; /* Initialization local variable */ pMod =&FT_MMSUStatus.Module[memModule]; /* Assign the Memory Module status structure to the */ /* local variable */ mod = *pMod; for (i=0; iState; /* Maintain the old state */ mod.Mode =FT_MODE_MEM_MOD_OFF; /* Program Dramma REINT register */ FD_piDrammaWrWPBUSReg(MemModule,FD_REINIT,0); /* Mask all Memory Module interrupts */ FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ALL); /* Get Columns enabled (Bit 16..24) */ FD_piDrammaRdRPBUSReg (memModule,FD_PENDING_INT,&pendingVal); /* Memory Module switched OFF */ configRegVal =FD_CONFIG_REG_27_11_B | (MemModule << 22); configRegVal =FD_CONFIG_REG_27_11_B | FD_COLUMN_ENABLE(pendingVal); for (i=0,maskCol =FD_CONFIG_REG_COL_01 ;i