1 |
/**************************************************************************** |
2 |
/* F i l e D a t a |
3 |
/* |
4 |
/* Module : FileManager |
5 |
/* C.I. No. : |
6 |
/* $Revision: 1.31 $ |
7 |
/* $Date: 2005/03/20 18:17:24 $ |
8 |
/* Belonging to : |
9 |
/* : |
10 |
/* $RCSfile: FT_MMSUManager_int.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: FT_MMSUManager_int.c,v $ |
25 |
/* Revision 1.31 2005/03/20 18:17:24 sebastiani |
26 |
/* rawFlag old code cancelled under if 0 |
27 |
/* |
28 |
/* Revision 1.30 2005/03/06 14:54:16 sebastiani |
29 |
/* fix log |
30 |
/* |
31 |
/* Revision 1.29 2005/02/21 08:58:28 sebastiani |
32 |
/* all log comments completed |
33 |
/* |
34 |
/* Revision 1.28 2004/11/19 15:14:35 sebastiani |
35 |
/* PRH_EXTERN_{VAR,ARR,TABLE} removed and put them on the autogenerated parameter heeader file |
36 |
/* |
37 |
/* Revision 1.27 2004/09/17 15:01:00 faber |
38 |
/* LU_INFN_LOG flags fixing |
39 |
/* |
40 |
/* Revision 1.26 2004/09/10 15:27:05 sebastiani |
41 |
/* fixed TM CC |
42 |
/* |
43 |
/* Revision 1.25 2004/08/26 16:54:07 sebastiani |
44 |
/* fix some bug |
45 |
/* |
46 |
/* Revision 1.24 2004/08/02 12:15:21 sebastiani |
47 |
/* using hk_manager to access to tmtc |
48 |
/* |
49 |
/* Revision 1.23 2004/07/28 09:03:01 sebastiani |
50 |
/* *** empty log message *** |
51 |
/* |
52 |
/* Revision 1.22 2004/07/27 17:30:17 faber |
53 |
/* OBT can be now in second or milliseconds, depending of the situazion. |
54 |
/* OBT_s is used for FM compatibility, OBT_ms basically for MM infos |
55 |
/* |
56 |
/* Revision 1.21 2004/04/23 14:37:26 tassa |
57 |
/* ops fix compilation! |
58 |
/* |
59 |
/* Revision 1.20 2004/04/23 14:16:02 tassa |
60 |
/* change for donwloading procedures vrl handling |
61 |
/* |
62 |
/* Revision 1.19 2004/03/08 15:49:09 alfarano |
63 |
/* improved handling functions for FE |
64 |
/* |
65 |
/* Revision 1.18 2004/03/05 14:07:14 sebastiani |
66 |
/* TM_piSendTC (TM_VRL_START,1) moved in StartDownlink in the right place,after starting of DMA in order to avoid delay time at starting |
67 |
/* |
68 |
/* Revision 1.17 2004/03/03 11:23:43 tassa |
69 |
/* Start downlink manager by timer+message |
70 |
/* |
71 |
/* Revision 1.16 2003/12/15 10:57:16 sebastiani |
72 |
/* last changes for the acceptance of TM tests in Rome of 9-12/Dec/2003 |
73 |
/* |
74 |
/* Revision 1.15 2003/11/28 14:49:46 sebastiani |
75 |
/* in MMSU delete comment lines |
76 |
/* in KHB fix HW bug |
77 |
/* in TS_PamManager add test |
78 |
/* |
79 |
/* Revision 1.14 2003/11/18 09:01:14 alfarano |
80 |
/* laben patch fixes some problems |
81 |
/* |
82 |
/* Revision 1.13 2003/11/13 16:05:18 sebastiani |
83 |
/* main_spare managerment |
84 |
/* |
85 |
/* Revision 1.12 2003/11/11 15:13:39 faber |
86 |
/* commands for VRL/TMTC use now the INFN style wrapped identifiers |
87 |
/* |
88 |
/* Revision 1.11 2003/11/05 08:17:19 sebastiani |
89 |
/* History Entry6 substituted with INFN style log |
90 |
/* |
91 |
/* Revision 1.10 2003/10/31 17:21:29 sebastiani |
92 |
/* bug fix on read and write function in TM_TMTCManager: added busy flag control on each read & write |
93 |
/* CRC functions updated in the SRAMPageManager |
94 |
/* |
95 |
/* Revision 1.9 2003/10/27 18:50:24 sebastiani |
96 |
/* *** empty log message *** |
97 |
/* |
98 |
/* Revision 1.8 2003/10/21 16:09:12 alfarano |
99 |
/* LU_LOG_INFN replacement for all remaining original log functions |
100 |
/* |
101 |
/* Revision 1.7 2003/10/17 08:25:48 sebastiani |
102 |
/* FILE1 bugfixes, |
103 |
/* downlink various bugfixes, VRL switch on/off introduced, |
104 |
/* FT_ifStopDownLink_CallBack function introduced, |
105 |
/* "case" FT_STOP_DOWNLINK introduced for the MSSUManager task |
106 |
/* |
107 |
/* Revision 1.6 2003/09/10 14:10:58 laben |
108 |
/* Fix Timer to ticks. |
109 |
/* |
110 |
/* Revision 1.5 2003/09/10 13:44:00 laben |
111 |
/* New File System model: just one file used like a circular buffer. |
112 |
/* NEw donwlink procedure: downlink next sector until the timer expires. |
113 |
/* |
114 |
/* Revision 1.4 2003/08/27 09:49:17 wizard |
115 |
/* Fix last sector in donwload. |
116 |
/* Set Sector size to 1024*1015 |
117 |
/* Fix Donwload procedure... ( set size set lastsector flag.....) |
118 |
/* bye |
119 |
/* |
120 |
/* Revision 1.3 2003/08/07 08:44:14 wizard |
121 |
/* SIMULATOR bugs ifdef/ifndef corrected |
122 |
/* laben bug "GetFileInfo" for FS_ERC32 id accepted in order to fix SM_pi_GetPacket |
123 |
/* |
124 |
/* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani |
125 |
/* Imported sources laben rel. 19.06.2003 integrated with pam2 |
126 |
/* |
127 |
/* Revision 1.20 2003/06/09 10:23:22 aurora |
128 |
/* improved the management of data acquisition |
129 |
/* |
130 |
/* Revision 1.19 2003/06/06 09:41:50 aurora |
131 |
/* fixed the latchup recovery function |
132 |
/* |
133 |
/* Revision 1.18 2003/05/20 07:48:17 aurora |
134 |
/* correct the downlink mcmd when some parameter is wrong. |
135 |
/* The acquisition mode is restored only when the mcmd is executed. |
136 |
/* |
137 |
/* Revision 1.17 2003/04/29 13:22:40 aurora |
138 |
/* cleared the last field of entry 6 for memory test |
139 |
/* |
140 |
/* Revision 1.16 2003/04/11 08:24:55 aurora |
141 |
/* Fixed Memory Module TEST |
142 |
/* |
143 |
/* Revision 1.15 2003/01/22 13:55:10 aurora |
144 |
/* typo |
145 |
/* |
146 |
/* Revision 1.14 2002/11/20 13:56:48 zulia |
147 |
/* The ABORT S2M now run always |
148 |
/* |
149 |
/* Revision 1.13 2002/11/14 09:48:31 zulia |
150 |
/* removed unsed code |
151 |
/* |
152 |
/* Revision 1.12 2002/10/17 10:05:18 zulia |
153 |
/* fixed ON/OFF memory module |
154 |
/* optimised PIFReset |
155 |
/* |
156 |
/* Revision 1.11 2002/07/31 14:27:00 zulia |
157 |
/* Correct EXE_MEM_CONF and init memory module |
158 |
/* |
159 |
/* Revision 1.10 2002/07/29 09:03:53 zulia |
160 |
/* new downlink format |
161 |
/* |
162 |
/* Revision 1.9 2002/05/09 13:43:49 aurora |
163 |
/* Modified for column latchup recovery |
164 |
/* Latchup retry added during column switch |
165 |
/* |
166 |
/* Revision 1.8 2002/05/09 08:16:34 zulia |
167 |
/* * acceptance release |
168 |
/* |
169 |
/* |
170 |
/*****************************************************************************/ |
171 |
|
172 |
|
173 |
/*============================= Include File ================================*/ |
174 |
|
175 |
|
176 |
|
177 |
#include <src/INFN/LU_SourceFileID_INFN.h> |
178 |
#define __FILEID__ _FT_MMSUManager_int__c |
179 |
#include <src/INFN/PRH_ParamHandler_INFN.h> |
180 |
#include <src/INFN/LU_LogUtility_INFN.h> |
181 |
#include <src/INFN/PRH_ParamHandler_INFN_auto.h> |
182 |
LU_DECL_MASK(); |
183 |
|
184 |
|
185 |
|
186 |
|
187 |
#include <src/INFN/LU_SourceFileID_INFN.h> |
188 |
|
189 |
|
190 |
#include <src/INFN/LU_LogUtility_INFN.h> |
191 |
|
192 |
#include <src/FileManager/MMSUManager/FT_MMSUManager_int.h> |
193 |
#include <src/INFN/MH_ModeHandler_INFN.h> |
194 |
#include <src/SRAMManager/SRAMPageManager/SM_SRAMPageManager_p.h> |
195 |
#include <src/TM_TCManager/TMTCManager/TM_TMTCManager_p.h> |
196 |
#include <src/INFN/OS_rtems_INFN_p.h> |
197 |
#include <src/INFN/PM_PamManager_INFN.h> |
198 |
#include <src/INFN/HK_Manager_INFN.h> |
199 |
|
200 |
|
201 |
/*============================== Local Variables ============================*/ |
202 |
|
203 |
// FROM BRANCH_TM_SAMARA |
204 |
UINT32 FT_main_spare = FT_VRL_MAIN; |
205 |
|
206 |
/*****************************************************************************/ |
207 |
|
208 |
/*======= M M S U M a n a g e r I N T E R N A L F U N C T I O N S =======*/ |
209 |
|
210 |
/*****************************************************************************/ |
211 |
|
212 |
/*****************************************************************************/ |
213 |
/* @Function: FT_ifSndMsgMMSUManager */ |
214 |
/* @Purpose : */ |
215 |
/* The function formats a message, then sends it to the MMSUManager task in */ |
216 |
/* order to execute a specific operation. */ |
217 |
/* */ |
218 |
/* @@ */ |
219 |
/* @Parameter Name @Mode @Description */ |
220 |
/* Code IN Task operation code */ |
221 |
/* Info IN Task operation parameter */ |
222 |
/* status_code OUT Return code */ |
223 |
/* @@ */ |
224 |
/*****************************************************************************/ |
225 |
|
226 |
status_code FT_ifSndMsgMMSUManager(unsigned int Code, unsigned int Info) |
227 |
{ |
228 |
status_code status; |
229 |
MsgTsk sndMsg; |
230 |
|
231 |
/* Message code */ |
232 |
sndMsg.Code =Code; |
233 |
/* Operation parameter */ |
234 |
*(unsigned int* )&sndMsg.Info =Info; |
235 |
/* Size of parameter */ |
236 |
sndMsg.LlInfo =sizeof(unsigned int); |
237 |
/* Send message to MMSUManager */ |
238 |
status =FT_piSndMsgMMSUManager(&sndMsg); |
239 |
return (status); |
240 |
} |
241 |
|
242 |
|
243 |
/*****************************************************************************/ |
244 |
/* @Function: FT_ifMCMDExeMemConf */ |
245 |
/* @Purpose : */ |
246 |
/* The function menages the EXE MEM CONF execution. The MCMD information */ |
247 |
/* are extracted from the buffer and inserted in the EXE MEM CONF MCMD */ |
248 |
/* structure. */ |
249 |
/* The buffer is deleted from the partition. The Memory Module is switched */ |
250 |
/* ON or OFF in accordance with the MCMD switched flag parameter. */ |
251 |
/* To switch ON the module are performed the following actions: */ |
252 |
/* - Check if all two Module are OFF. */ |
253 |
/* - Check if Memory Module to switch ON is OK. */ |
254 |
/* - Sending a log to the History area to notify the EXE MEM CONF MCND */ |
255 |
/* execution. */ |
256 |
/* To switch OFF the module are performed the following actions: */ |
257 |
/* - Sending a log to the History area to notify the EXE MEM CONF MCND */ |
258 |
/* execution. */ |
259 |
/* Any error detected during EXE MEM CONF initialization causes the MCMD */ |
260 |
/* rejection. A specific log sent to the HistoryArea object, defines the */ |
261 |
/* reason of the failure. */ |
262 |
/* */ |
263 |
/* @@ */ |
264 |
/* @Parameter Name @Mode @Description */ |
265 |
/* PtrMcmd IN Pointer to MCMD header */ |
266 |
/* (MA_HEADER_MCMD type) */ |
267 |
/* MMSUStatus IN Pointer to all MMSU status structure */ |
268 |
/* (FT_ALL_MMSU_STATUS type) */ |
269 |
/* @@ */ |
270 |
/*****************************************************************************/ |
271 |
|
272 |
void FT_ifMCMDExeMemConf (MA_HEADER_MCMD* PtrMcmd, |
273 |
FT_MMSU_STATUS* MMSUStatus, |
274 |
FT_RW_CH* ptrRWChannel) |
275 |
{ |
276 |
status_code status; |
277 |
unsigned short* pMcmdInfo; |
278 |
unsigned int timetagFlag; |
279 |
unsigned int param; |
280 |
unsigned int module; |
281 |
unsigned int memModSw; |
282 |
unsigned int memModOn; |
283 |
unsigned int i; |
284 |
|
285 |
/* Extract MCMD parameters and delete it from partition */ |
286 |
pMcmdInfo =(unsigned short* )PtrMcmd->PtrMCMD; |
287 |
param =*(pMcmdInfo+OFFSET_HEADER); |
288 |
module =(param & FT_MM_SEL) ? FT_MEM_MOD_2 : FT_MEM_MOD_1; |
289 |
memModSw =param & FT_MM_SW; |
290 |
timetagFlag =(*(pMcmdInfo+1)&TIMETAG_MASK) ? TIMETAG_MCMD : IMMEDIATE_MCMD; |
291 |
MA_piDelBufferMCMD(PtrMcmd->PtrMCMD,timetagFlag); |
292 |
|
293 |
/* Check if Memory Module must be switched ON or OFF */ |
294 |
if (memModSw) |
295 |
{ |
296 |
/* Check if possible switch ON the Memory Module */ |
297 |
/* Switch ON the Memory Module if Nominal and */ |
298 |
/* Redounded is OFF and Module to switch is OK */ |
299 |
if (MMSUStatus->Module[FT_MEM_MOD_1].Mode==FT_MODE_MEM_MOD_OFF && |
300 |
MMSUStatus->Module[FT_MEM_MOD_2].Mode==FT_MODE_MEM_MOD_OFF ) |
301 |
{ |
302 |
status =SUCCESSFUL; |
303 |
MMSUStatus->Module[module].State = FT_STATE_MOD_OK; |
304 |
} |
305 |
else |
306 |
{ |
307 |
/* Define error type */ |
308 |
status = HA_E2_ONE_MEM_MODULE_ON; |
309 |
} |
310 |
} |
311 |
else |
312 |
{ |
313 |
/* It's always possible switch OFF the Module */ |
314 |
status =SUCCESSFUL; |
315 |
} |
316 |
|
317 |
/*=============== Entry 2 Log in History Area ============*/ |
318 |
// LO G_INFN HA_piLogHistoryEntry2 (PtrMcmd->Type,status); |
319 |
/*@LOG MCMD MemExeConf - status */ |
320 |
LU_INFN_LOG(LU_NORMAL_TRACE|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
321 |
if (status == SUCCESSFUL) |
322 |
{ |
323 |
if (memModSw) |
324 |
{ |
325 |
/*=========== Memory Module is switched ON =======*/ |
326 |
|
327 |
/* Memory Module ON */ |
328 |
if ( FT_opMemModuleON(module) == SUCCESSFUL ) |
329 |
FT_ifRWChannelInit(ptrRWChannel, module, &MMSUStatus->Module[module]); |
330 |
|
331 |
} |
332 |
else |
333 |
{ |
334 |
/*========== Memory Module is switched OFF =======*/ |
335 |
/* Delete all file that using the Module into FAT */ |
336 |
/* and mark as unused the sectors in the Free List*/ |
337 |
/* Memory Module OFF */ |
338 |
FT_opMemModuleOFF(module); |
339 |
} |
340 |
} |
341 |
} |
342 |
|
343 |
|
344 |
|
345 |
/*****************************************************************************/ |
346 |
/* @Function: FT_ifMCMDBiteExec */ |
347 |
/* @Purpose : */ |
348 |
/* The function menages the Bite MCMD execution. The MCMD Bite information */ |
349 |
/* are extracted from the buffer and inserted in the Bite MCMD structure. */ |
350 |
/* The buffer is deleted from the partition. To begin the Bite operations */ |
351 |
/* are performed the followings actions: */ |
352 |
/* - Checking of the MCMD Bite parameters. */ |
353 |
/* - Program Dramma REINIT and SCRUBBING and REFRESH registers. */ |
354 |
/* - Interrupt SFT_OVL and HW_OR,HW_AND masked. */ |
355 |
/* - Interrupt SA_OVL and LATCHUP_MONITOR enabled. */ |
356 |
/* - Starting of the Memory Module fill. */ |
357 |
/* - Sending a log to the History area to notify the Bite starting */ |
358 |
/* operations. */ |
359 |
/* Any error detected during Biteinitialization causes the MCMD rejection. */ |
360 |
/* A specific log sent to the HistoryArea object, defines the reason of the */ |
361 |
/* failure. */ |
362 |
/* */ |
363 |
/* @@ */ |
364 |
/* @Parameter Name @Mode @Description */ |
365 |
/* PtrMcmd IN Pointer to MCMD header */ |
366 |
/* (MA_HEADER_MCMD type) */ |
367 |
/* MMSUStatus IN Pointer to all MMSU status structure */ |
368 |
/* (FT_MMSU_STATUS type) */ |
369 |
/* TestStatus IN Pointer to test statuts structure */ |
370 |
/* (FT_TEST_MOD_STATUS type) */ |
371 |
/* status_code OUT Return code */ |
372 |
//* @@ */ |
373 |
/*****************************************************************************/ |
374 |
|
375 |
status_code FT_ifMCMDBiteExec (MA_HEADER_MCMD* PtrMcmd, |
376 |
FT_MMSU_STATUS* MMSUStatus, |
377 |
FT_TEST_MOD_STATUS* TestStatus, |
378 |
FT_RW_CH* PtrRWChannel) |
379 |
{ |
380 |
status_code status = HA_E2_MCMD_OK; |
381 |
unsigned short* pMcmdInfo; |
382 |
unsigned int initPattern; |
383 |
unsigned int boardId; |
384 |
unsigned int timetagFlag; |
385 |
unsigned int i; |
386 |
FT_MEM_MOD* pMemMod; |
387 |
|
388 |
/* Extract parameters and delete MCMD from partition */ |
389 |
pMcmdInfo =(unsigned short* )PtrMcmd->PtrMCMD; |
390 |
|
391 |
initPattern = (UINT32)(*(pMcmdInfo+OFFSET_HEADER)); |
392 |
|
393 |
/* Delete MCMD from partition */ |
394 |
timetagFlag =(*(pMcmdInfo+1)&TIMETAG_MASK) ? TIMETAG_MCMD : IMMEDIATE_MCMD; |
395 |
MA_piDelBufferMCMD(PtrMcmd->PtrMCMD,timetagFlag); |
396 |
|
397 |
/* Perform a BITE only if the memory module is ON */ |
398 |
/* and no BITE is in progress */ |
399 |
if(PtrRWChannel->PtrModuleStatus->Mode != FT_MODE_MEM_MOD_ON) |
400 |
{ |
401 |
if(PtrRWChannel->PtrModuleStatus->Mode == FT_MODE_MEM_MOD_BITE) |
402 |
{ |
403 |
status = HA_E2_BT_RUNNING; |
404 |
} |
405 |
else |
406 |
{ |
407 |
status = HA_E2_MOD_NOT_AVAILABLE; |
408 |
} |
409 |
} |
410 |
if (status == HA_E2_MCMD_OK) |
411 |
{ |
412 |
boardId = PtrRWChannel->ActiveModule; |
413 |
/* Start the timeout timer for the BITE operation */ |
414 |
status = OS_piStartTimer(FT_TIM, FT_BITETO, |
415 |
FT_ifBiteTORecovery, (void*)PtrRWChannel); |
416 |
if (status != SUCCESSFUL) |
417 |
{ |
418 |
/* Timer not started correctly */ |
419 |
// LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_FS,HA_E10_TIMER_ERR,status); |
420 |
/*@LOG error starting timer for bite operation - status */ |
421 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
422 |
status =HA_E2_INTERNAL_ERR; |
423 |
} |
424 |
} |
425 |
if (status == HA_E2_MCMD_OK) |
426 |
{ |
427 |
/* Program Dramma REINT register */ |
428 |
FD_piDrammaWrWPBUSReg (boardId,FD_REINIT,0); |
429 |
/* Program Dramma SCRUBBING and REFRESH register */ |
430 |
FD_piDrammaWrWPBUSReg (boardId,FD_SCRUBBER_REFRESH,FD_SCRABBER_REFRESH_VALUE); |
431 |
/* Interrupt masked: SFT_OVL,HW_OR,HW_AND */ |
432 |
/* Interrupt unmask: SA_OVL,LATCHUP_MONITOR */ |
433 |
FD_piDrammaWrWPBUSReg(boardId,FD_INTMSK,FD_MM_INT_ABIL_SA); |
434 |
/* Clear all memory module interrupts */ |
435 |
status =FD_piDrammaWrWPBUSReg(boardId,FD_INTCLR,FD_MM_INT_ALL); |
436 |
/* Start Memory module fix pattern filling */ |
437 |
initPattern |= FD_INITREG_START | FD_INITREG_INIT_MEM; |
438 |
status =FD_piDrammaWrWPBUSReg(boardId,FD_INITREG,initPattern); |
439 |
|
440 |
/* Set in MMSU status Module in BITE mode */ |
441 |
MMSUStatus->Module[boardId].Mode =FT_MODE_MEM_MOD_BITE; |
442 |
|
443 |
/* Set variable in Module Test Status */ |
444 |
TestStatus->State =FT_TEST_START; |
445 |
TestStatus->Module =boardId; |
446 |
TestStatus->TestIdx =0; |
447 |
|
448 |
/*============= Entry 2 Log in History Area ==========*/ |
449 |
// LOG_INFN HA_piLogHistoryEntry2 (PtrMcmd->Type,status); |
450 |
/*@LOG BITE: trace - status */ |
451 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
452 |
/*========= Entry 0 Log in History Area ==========*/ |
453 |
// LOG_INFN HA_piLogHistoryEntry0(HA_E0_STARTING,HA_E0_BITE,HA_E0_BITE_BIT); |
454 |
/*@LOG BITE: trace */ |
455 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,HA_E0_BITE_BIT); |
456 |
} |
457 |
else |
458 |
{ |
459 |
/*============= Entry 2 Log in History Area ==========*/ |
460 |
// LOG_INFN HA_piLogHistoryEntry2 (PtrMcmd->Type,status); |
461 |
/*@LOG BITE: trace - status */ |
462 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
463 |
} |
464 |
|
465 |
return(status); |
466 |
} |
467 |
|
468 |
|
469 |
|
470 |
|
471 |
/*****************************************************************************/ |
472 |
/* @Function: FT_ifColLatchUpInter */ |
473 |
/* @Purpose : */ |
474 |
/* The function sends a message to the MMSUManager task to menage the */ |
475 |
/* latchup recovery procedure. */ |
476 |
/* The lactchup recovery information are compacted in an unsigned int type */ |
477 |
/* as follows : */ |
478 |
/* 32 16 7 0 */ |
479 |
/* Latchup columns | Memory Module */ |
480 |
/* */ |
481 |
/* @@ */ |
482 |
/* @Parameter Name @Mode @Description */ |
483 |
/* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ |
484 |
/* LatchUpCol IN Latchup recovery information */ |
485 |
/* @@ */ |
486 |
/*****************************************************************************/ |
487 |
|
488 |
void FT_ifColLatchUpInter (unsigned int MemModule, |
489 |
unsigned int LatchUpCol) |
490 |
{ |
491 |
|
492 |
/* Send message to the MMSUManager to start Latchup rocovery procedure */ |
493 |
FT_ifSndMsgMMSUManager(FT_LATCHUP_RECOVERY,FT_LATCHUP_INFO(MemModule,LatchUpCol)); |
494 |
} |
495 |
|
496 |
|
497 |
|
498 |
/*****************************************************************************/ |
499 |
/* @Function: FT_ifLatchUpRecovery */ |
500 |
/* @Purpose : */ |
501 |
/* The function performs the latchup recovery procedure. */ |
502 |
/* The actions executed to recovery the columns in latchup are the */ |
503 |
/* following: */ |
504 |
/* - The memory module, and columns in error are extracted from */ |
505 |
/* the recovery information parameter. */ |
506 |
/* - Abort all the operational modes that using the Memory Module in */ |
507 |
/* fail. */ |
508 |
/* - Calling the columns latchup recovery procedure. */ |
509 |
/* - If there is 1 column in error, calling the procedure to switch the */ |
510 |
/* fail column with the spare column if available. If the column */ |
511 |
/* switch is ended correctly, the column in error is marked as FAIL */ |
512 |
/* and the spare column is marked as USED into the MMSU status */ |
513 |
/* structure. */ |
514 |
/* If the columns latchup procedure is missed the Memory Module is marked */ |
515 |
/* as fail, all the files that using the module is marked as corrupt, and */ |
516 |
/* the sectors of the module located into the free list is marked as */ |
517 |
/* unused. */ |
518 |
/* */ |
519 |
/* @@ */ |
520 |
/* @Parameter Name @Mode @Description */ |
521 |
/* RecoveryInfo IN Recovery information */ |
522 |
/* MMSUStatus IN Pointer to all MMSU status structure */ |
523 |
/* (FT_ALL_MMSU_STATUS type) */ |
524 |
/* PtrRWChannel IN Pointer to the Read/Write channels structure*/ |
525 |
/* @@ */ |
526 |
/*****************************************************************************/ |
527 |
|
528 |
void FT_ifLatchUpRecovery (unsigned int RecoveryInfo, |
529 |
FT_MMSU_STATUS* MMSUStatus, |
530 |
FT_RW_CH* PtrRWChannel) |
531 |
{ |
532 |
status_code status; |
533 |
unsigned int memModule; |
534 |
unsigned int latchupBit; |
535 |
unsigned int colError; |
536 |
unsigned int pendingVal; |
537 |
FT_MEM_MOD* pM; |
538 |
unsigned int maskCol; |
539 |
unsigned int i; |
540 |
SM_ACQMODE acqMode; |
541 |
FT_STR_MODE currentStore; |
542 |
|
543 |
/* Get LatchUp recovery information */ |
544 |
memModule = FT_LATCHUP_MEM_MOD(RecoveryInfo); |
545 |
latchupBit =FT_LATCHUP_BIT(RecoveryInfo); |
546 |
pM =&MMSUStatus->Module[memModule]; |
547 |
|
548 |
/* Call column Latchup recovery procedure */ |
549 |
status =FT_ifColumnLatchUp(memModule,FD_CONFIG_REG_27_11_B, |
550 |
latchupBit,TRUE,&colError,&pendingVal); |
551 |
|
552 |
/* Abort a running Downlink */ |
553 |
if(PtrRWChannel->ReadMode != FT_CLOSED) |
554 |
{ |
555 |
FT_ifDownlinkAbort(PtrRWChannel); |
556 |
} |
557 |
/* Disable data acquisition nad storage in the mass memory */ |
558 |
acqMode = PM_pi_GetAcqMode(); |
559 |
PM_pi_SetAcqMode(SM_IDLE); |
560 |
currentStore = PtrRWChannel->StoreEnable; |
561 |
FT_ifDisableStore(PtrRWChannel, TRUE); |
562 |
if (status==SUCCESSFUL && colError) |
563 |
{ |
564 |
/* There is 1 column in error, try to use the spare column */ |
565 |
if ((status=FT_ifColumnSwitch(memModule,colError))==SUCCESSFUL) |
566 |
{ |
567 |
/* Update column information */ |
568 |
for (i=0,maskCol=1; i<FD_MAX_COLUMN_ENABLE; i++,maskCol <<=1) |
569 |
{ |
570 |
if (colError & maskCol) |
571 |
{ |
572 |
pM->Column[i] =FT_COLUMN_FAIL; |
573 |
break; /* Column set fail, exit from the loop */ |
574 |
} |
575 |
} |
576 |
pM->Column[FT_SPARE_COL] =FT_COLUMN_ON; |
577 |
} |
578 |
} |
579 |
/* Check if latchup procedure is OK */ |
580 |
if (status!=SUCCESSFUL) |
581 |
{ |
582 |
/* Latchup procedure is NOT OK */ |
583 |
/* Memory Module is marked fail */ |
584 |
pM->State =FT_STATE_MOD_FAIL; |
585 |
/*============= Entry 11 Log in History Area ==============*/ |
586 |
// LOG_INFN HA_piLogHistoryEntry11(HA_E11_MEMORY_MODULE,HA_E11_MOD_LATCHUP_REC_ERR,memModule, colError); |
587 |
/*@LOG LatchUpRecovery - status */ |
588 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,colError); |
589 |
} |
590 |
/* Disable the storage in the mass memory */ |
591 |
if(currentStore != FT_STR_NONE) |
592 |
{ |
593 |
FT_ifEnableStore(PtrRWChannel); |
594 |
PM_pi_SetAcqMode(acqMode); |
595 |
} |
596 |
} |
597 |
|
598 |
|
599 |
|
600 |
/*****************************************************************************/ |
601 |
/* @Function: FT_ifHwErrorInter */ |
602 |
/* @Purpose : */ |
603 |
/* The function sends a message to MMSUManager task to menage the hardware */ |
604 |
/* error recovery procedure. */ |
605 |
/* The hardware error information are compacted in an unsigned int type */ |
606 |
/* as follows : */ |
607 |
/* 32 16 7 0 */ |
608 |
/* | Memory Module */ |
609 |
/* */ |
610 |
/* @@ */ |
611 |
/* @Parameter Name @Mode @Description */ |
612 |
/* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ |
613 |
/* @@ */ |
614 |
/*****************************************************************************/ |
615 |
|
616 |
void FT_ifHwErrorInter (unsigned int MemModule) |
617 |
{ |
618 |
|
619 |
/* Send message to MMSUManager to start HW error rocovery menagement */ |
620 |
FT_ifSndMsgMMSUManager(FT_HW_ERROR_RECOVERY,MemModule); |
621 |
} |
622 |
|
623 |
|
624 |
/*****************************************************************************/ |
625 |
/* @Function: FT_ifHwErrorRecovery */ |
626 |
/* @Purpose : */ |
627 |
/* The function performs the Memory Module hardware error (HW) recovery */ |
628 |
/* procedure. */ |
629 |
/* The actions executed to recovery the Memory Module HW error are the */ |
630 |
/* following: */ |
631 |
/* - Extract the memory module information from the */ |
632 |
/* -RecoveryInfo- parameter. */ |
633 |
/* - Masking of the Memory Module interrupts. */ |
634 |
/* - Abort all the operational modes that using the Memory Module in */ |
635 |
/* fail. */ |
636 |
/* - The memory module is marked as fail, all the files that using the */ |
637 |
/* module are marked as corrupt, the sectors of the module located */ |
638 |
/* into the free list are marked as unused. */ |
639 |
/* */ |
640 |
/* @@ */ |
641 |
/* @Parameter Name @Mode @Description */ |
642 |
/* RecoveryInfo IN Recovery information */ |
643 |
/* MMSUStatus IN Pointer to all MMSU status structure */ |
644 |
/* (FT_ALL_MMSU_STATUS type) */ |
645 |
/* PtrRWChannel IN Pointer to the Read/Write channels structure*/ |
646 |
/* @@ */ |
647 |
/*****************************************************************************/ |
648 |
|
649 |
void FT_ifHwErrorRecovery (unsigned int RecoveryInfo, |
650 |
FT_MMSU_STATUS* MMSUStatus, |
651 |
FT_RW_CH* PtrRWChannel) |
652 |
|
653 |
{ |
654 |
status_code status; |
655 |
unsigned int MemModule; |
656 |
FT_MEM_MOD* pM; |
657 |
unsigned int hwErr; |
658 |
unsigned int failed_col_num; |
659 |
unsigned int failed_col_bit; |
660 |
unsigned int pendingVal; |
661 |
unsigned int colEnable; |
662 |
unsigned int configRegVal; |
663 |
|
664 |
/* Get LatchUp recovery information */ |
665 |
MemModule = RecoveryInfo; |
666 |
pM =&MMSUStatus->Module[MemModule]; |
667 |
|
668 |
/* Mask all memory module interrupts */ |
669 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ALL); |
670 |
|
671 |
/* Abort a running Downlink */ |
672 |
if(PtrRWChannel->ReadMode != FT_CLOSED) |
673 |
{ |
674 |
FT_ifDownlinkAbort(PtrRWChannel); |
675 |
} |
676 |
/* Disable the storage in the mass memory */ |
677 |
if(PtrRWChannel->StoreEnable == FT_STR_ALL) |
678 |
{ |
679 |
FT_ifStoreAbort(PtrRWChannel); |
680 |
} |
681 |
|
682 |
/* Find the failed column reading the Hard Error Register */ |
683 |
FD_piDrammaRdRPBUSReg(MemModule,FD_HARD_ERROR_REG,&hwErr); |
684 |
/* retrieve the bits from 13 to 15 */ |
685 |
failed_col_num = ((hwErr & 0x0000E000)>>13); |
686 |
failed_col_bit = ( 0x01 << failed_col_num); |
687 |
|
688 |
/* If spare column is available switch */ |
689 |
if (pM->Column[FT_SPARE_COL] == FT_COLUMN_OFF) |
690 |
{ |
691 |
/* Switch off failed column */ |
692 |
FD_piDrammaWrWPBUSReg (MemModule, FD_REINIT,0); |
693 |
/* Program Dramma SCRUBBING and REFRESH register */ |
694 |
FD_piDrammaWrWPBUSReg (MemModule, FD_SCRUBBER_REFRESH, FD_SCRABBER_REFRESH_VALUE); |
695 |
/* Get columns enable */ |
696 |
FD_piDrammaRdRPBUSReg (MemModule, FD_PENDING_INT, &pendingVal); |
697 |
colEnable = FD_COLUMN_ENABLE(pendingVal); |
698 |
configRegVal = FD_CONFIG_REG_27_11_B | ((MemModule&0x07) << 22) | colEnable; |
699 |
/* Fail column OFF */ |
700 |
configRegVal &=~failed_col_bit; |
701 |
FD_piDrammaWrWPBUSReg (MemModule,FD_CONFIGURATION,configRegVal); |
702 |
/* Wait 1 ms before to put ON the spare column */ |
703 |
OS_piTaskSuspend (1); |
704 |
/* Spare column ON */ |
705 |
configRegVal |= FD_CONFIG_REG_COL_11; |
706 |
FD_piDrammaWrWPBUSReg (MemModule, FD_CONFIGURATION,configRegVal); |
707 |
/* Program Latchup Retry counter 3 ms */ |
708 |
FD_piDrammaWrWPBUSReg (MemModule, FD_LATCH_UP_RETRY, FD_LATCHUP_RETRY_VAL); |
709 |
/* Wait 2 ms */ |
710 |
OS_piTaskSuspend (2); |
711 |
/* Update columns status */ |
712 |
pM->Column[failed_col_num] = FT_COLUMN_FAIL; |
713 |
pM->Column[FT_SPARE_COL] = FT_COLUMN_ON; |
714 |
/* Start up memory module operations */ |
715 |
FD_piDrammaWrWPBUSReg (MemModule, FD_INITREG, FD_INITREG_START); |
716 |
/* Wait 2 ms, to complete start operations */ |
717 |
OS_piTaskSuspend (2); |
718 |
/* Unmask all memory module interrupts */ |
719 |
FD_piDrammaWrWPBUSReg (MemModule, FD_INTMSK, FD_MM_INT_ABIL_ALL); |
720 |
} |
721 |
else /* spare column is not available */ |
722 |
{ |
723 |
/* Memory Module is marked fail */ |
724 |
pM->State = FT_STATE_MOD_FAIL; |
725 |
} |
726 |
} |
727 |
|
728 |
|
729 |
|
730 |
|
731 |
/*****************************************************************************/ |
732 |
/* @Function: FT_ifColumnLatchUp */ |
733 |
/* @Purpose : */ |
734 |
/* The function menages the colummns latchup recovery procedure. */ |
735 |
/* The actions executed in the procedure are the following: */ |
736 |
/* - If the flag parameter is TRUE the Memory Module device is carried */ |
737 |
/* in idle state. */ |
738 |
/* - Activation of the columns in latchup. Each column in latchup is */ |
739 |
/* forced OFF, the Latchup Retry Counter register is writed, and */ |
740 |
/* then the column is forced ON again. Before to continue in the */ |
741 |
/* latchup procedure esecution the task wait 2 ms. */ |
742 |
/* - Reading of the pending interrupt register to check if there are */ |
743 |
/* again columns in latchup condition: */ |
744 |
/* Zero column error the Memory Module is OK. */ |
745 |
/* One column error the Memory Module is not considered in fail */ |
746 |
/* because the spare column could be used. */ |
747 |
/* More than one column in error the Memory Module is in fail. */ |
748 |
/* If column latchup procedure is ended correctly and the flag parameter is */ |
749 |
/* TRUE, the INITREG register is programmed to carry out from idle state the */ |
750 |
/* Memory Module. */ |
751 |
/* */ |
752 |
/* @@ */ |
753 |
/* @Parameter Name @Mode @Description */ |
754 |
/* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ |
755 |
/* ConfigVal IN Value to write in Configuration register */ |
756 |
/* Columns IN Columns in error */ |
757 |
/* ActivationColFlag IN Flag to carry in or to carry out from the */ |
758 |
/* idle state the Memory Module device */ |
759 |
/* ColumnsError OUT Returned column status */ |
760 |
/* (bit 0 to 10 columns, bit to 1 specifies */ |
761 |
/* the column error) */ |
762 |
/* PendingVal OUT Returned Pending Interrupt register */ |
763 |
/* @@ */ |
764 |
/*****************************************************************************/ |
765 |
|
766 |
status_code FT_ifColumnLatchUp (unsigned int MemModule, |
767 |
unsigned int ConfigVal, |
768 |
unsigned int Columns, |
769 |
unsigned int ActivationColFlag, |
770 |
unsigned int* ColumnsError, |
771 |
unsigned int* PendingVal) |
772 |
{ |
773 |
status_code status; |
774 |
unsigned int configRegVal; |
775 |
unsigned int pendingVal; |
776 |
unsigned int maskCol; |
777 |
unsigned int colError; |
778 |
unsigned int colLatchUp; |
779 |
unsigned int i; |
780 |
|
781 |
configRegVal =ConfigVal; |
782 |
/* If column at the end of procedure must be */ |
783 |
/* activated first set REINIT and SCRUBB register */ |
784 |
if (ActivationColFlag) |
785 |
{ |
786 |
/* Program Dramma REINT register */ |
787 |
FD_piDrammaWrWPBUSReg(MemModule,FD_REINIT,0); |
788 |
/* Program Dramma SCRUBBING and REFRESH register */ |
789 |
FD_piDrammaWrWPBUSReg(MemModule,FD_SCRUBBER_REFRESH,FD_SCRABBER_REFRESH_VALUE); |
790 |
/* Clear all memory module interrupts */ |
791 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTCLR,FD_MM_INT_ALL); |
792 |
/* Mask all memory module interrupts */ |
793 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ALL); |
794 |
} |
795 |
/* Try to activate the columns in Latch Up */ |
796 |
for (i=0,maskCol =FD_CONFIG_REG_COL_01; i<FD_MAX_COLUMN_ENABLE; i++,maskCol <<=1) |
797 |
{ |
798 |
if (Columns & maskCol) |
799 |
{ |
800 |
/* Column OFF */ |
801 |
configRegVal &=~maskCol; |
802 |
FD_piDrammaWrWPBUSReg(MemModule,FD_CONFIGURATION,configRegVal); |
803 |
/* Wait 1 ms before switch on the column */ |
804 |
OS_piTaskSuspend (1); |
805 |
/* Column ON */ |
806 |
configRegVal |=maskCol; |
807 |
FD_piDrammaWrWPBUSReg(MemModule,FD_CONFIGURATION,configRegVal); |
808 |
/* Write LATCHUP RETRAY register */ |
809 |
FD_piDrammaWrWPBUSReg(MemModule,FD_CONFIGURATION,FD_LATCHUP_RETRY_VAL); |
810 |
/* Wait 6 ms before to activate the next column */ |
811 |
OS_piTaskSuspend (2); |
812 |
} |
813 |
} |
814 |
/* Read again Pending Interrupt register */ |
815 |
FD_piDrammaRdRPBUSReg (MemModule,FD_PENDING_INT,&pendingVal); |
816 |
*PendingVal =pendingVal; |
817 |
/* Take only the Latch Up bits */ |
818 |
pendingVal =FD_MM_LTATCHUP_BIT(pendingVal); |
819 |
/* Check interrupt Latch Up monitor bits */ |
820 |
if (pendingVal) |
821 |
{ |
822 |
/* Clear all memory module interrupts */ |
823 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTCLR,FD_MM_INT_ALL); |
824 |
/* Check if there are again columns in error */ |
825 |
maskCol =FD_CONFIG_REG_COL_01; |
826 |
colError =0; |
827 |
colLatchUp =0; |
828 |
for (i=0; i<FD_MAX_COLUMN_ENABLE; i++,maskCol <<=1) |
829 |
{ |
830 |
if (pendingVal & maskCol) |
831 |
{ |
832 |
colError++; |
833 |
colLatchUp =maskCol; |
834 |
} |
835 |
} |
836 |
/* Verify how many columns are again in error */ |
837 |
if (colError <= FD_MAX_COLUMN_ERROR) |
838 |
{ |
839 |
/* There is 1 column in error */ |
840 |
/* Return SUCCESSFUL because could be used */ |
841 |
/* the spare column for recover the module */ |
842 |
status =SUCCESSFUL; |
843 |
|
844 |
} |
845 |
else |
846 |
{ |
847 |
/* There is more than 1 column in error */ |
848 |
/* The Columns are switched OFF */ |
849 |
status =UNSATISFIED; |
850 |
} |
851 |
/* Set columns in error */ |
852 |
*ColumnsError = colLatchUp; //pendingVal; |
853 |
|
854 |
} |
855 |
else/*===================== Columns are OK ===========================*/ |
856 |
{ |
857 |
/* Check if column must be activated */ |
858 |
if (ActivationColFlag) |
859 |
{ |
860 |
/* Start memory module operation programming INITREG register */ |
861 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INITREG,FD_INITREG_START); |
862 |
/* Wait 2 ms,time in order to complete the start operations */ |
863 |
OS_piTaskSuspend (2); |
864 |
/* Unmask all memory module interrupts */ |
865 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ABIL_ALL); |
866 |
} |
867 |
*ColumnsError =0; |
868 |
status =SUCCESSFUL; |
869 |
} |
870 |
return (status); |
871 |
|
872 |
} |
873 |
|
874 |
|
875 |
|
876 |
/*****************************************************************************/ |
877 |
/* @Function: FT_ifColumnSwitch */ |
878 |
/* @Purpose : */ |
879 |
/* The function performs the switch between the column specified in the */ |
880 |
/* parameter and the spare column. * |
881 |
/* The actions executed in the procedure are the following: */ |
882 |
/* - Masking of all memory module interrupts. */ |
883 |
/* - Programming of the Dramma REINT register to reset the Memery */ |
884 |
/* Module devices without loss the data. */ |
885 |
/* - Programming of the Dramma SCRUBBING and REFRESH register. */ |
886 |
/* - The specific column is forced OFF. */ |
887 |
/* - Waiting of 200 us. */ |
888 |
/* - The spare column is forced ON. */ |
889 |
/* - Programming of the Dramma INITREG to start the Memory Module. */ |
890 |
/* - The task waiting 2 ms to complete the start operations */ |
891 |
/* - Checking of the interrupts Latch Up Monitor bits. */ |
892 |
/* - If Latch Up condition has occurred the Column Latch Up recovery */ |
893 |
/* procedure is invoked. */ |
894 |
/* The function exit with return code SUCCESSFUL if all is OK and */ |
895 |
/* UNSATISFIED if column switch has not been executed correctly. */ |
896 |
/* */ |
897 |
/* @@ */ |
898 |
/* @Parameter Name @Mode @Description */ |
899 |
/* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ |
900 |
/* Column IN Column to switch */ |
901 |
/* status_code OUT Return code */ |
902 |
/* @@ */ |
903 |
/*****************************************************************************/ |
904 |
|
905 |
status_code FT_ifColumnSwitch (unsigned int MemModule, |
906 |
unsigned int Column) |
907 |
{ |
908 |
status_code status; |
909 |
unsigned int configRegVal; |
910 |
unsigned int pendingVal; |
911 |
unsigned int colError; |
912 |
unsigned int colEnable; |
913 |
unsigned int i; |
914 |
|
915 |
/* Program Dramma REINT register */ |
916 |
FD_piDrammaWrWPBUSReg(MemModule,FD_REINIT,0); |
917 |
/* Program Dramma SCRUBBING and REFRESH register */ |
918 |
FD_piDrammaWrWPBUSReg(MemModule,FD_SCRUBBER_REFRESH,FD_SCRABBER_REFRESH_VALUE); |
919 |
/* Clear all memory module interrupts */ |
920 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTCLR,FD_MM_INT_ALL); |
921 |
/* Mask all memory module interrupts */ |
922 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ALL); |
923 |
/* Get columns enable */ |
924 |
FD_piDrammaRdRPBUSReg (MemModule,FD_PENDING_INT,&pendingVal); |
925 |
colEnable =FD_COLUMN_ENABLE(pendingVal); |
926 |
configRegVal =FD_CONFIG_REG_27_11_B | ((MemModule&0x07) << 22) | colEnable; |
927 |
/* Fail column OFF */ |
928 |
configRegVal &=~Column; |
929 |
FD_piDrammaWrWPBUSReg(MemModule,FD_CONFIGURATION,configRegVal); |
930 |
/* Wait 1 ms before to put ON the spare column */ |
931 |
OS_piTaskSuspend (1); |
932 |
/* Spare column ON */ |
933 |
configRegVal |=FD_CONFIG_REG_COL_11; |
934 |
FD_piDrammaWrWPBUSReg(MemModule,FD_CONFIGURATION,configRegVal); |
935 |
/* Program Latchup Retry counter 3 ms */ |
936 |
FD_piDrammaWrWPBUSReg (MemModule,FD_LATCH_UP_RETRY,FD_LATCHUP_RETRY_VAL); |
937 |
/* Wait 2 ms before to check the Latch Up bits */ |
938 |
OS_piTaskSuspend (2); |
939 |
/* Read Pending Interrupt register */ |
940 |
FD_piDrammaRdRPBUSReg (MemModule,FD_PENDING_INT,&pendingVal); |
941 |
/* Take only the Latch Up bits */ |
942 |
pendingVal =FD_MM_LTATCHUP_BIT(pendingVal); |
943 |
/* Check interrupt Latch Up Monitor bits */ |
944 |
if (pendingVal) |
945 |
{ |
946 |
/*====== Column Latch Up recovery procedure ======*/ |
947 |
/* Clear all memory module interrupts */ |
948 |
FD_piDrammaWrWPBUSReg (MemModule,FD_INTCLR,FD_MM_INT_ALL); |
949 |
status =FT_ifColumnLatchUp(MemModule,configRegVal, |
950 |
FD_CONFIG_REG_COL_11,FALSE,&colError,&pendingVal); |
951 |
/* Check if spare column now is OK */ |
952 |
if(colError) |
953 |
{ |
954 |
/* Spare column error */ |
955 |
status =UNSATISFIED; |
956 |
} |
957 |
} |
958 |
else |
959 |
{ |
960 |
/* Active the column and the Memory Module operations */ |
961 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INITREG,FD_INITREG_START); |
962 |
/* Wait 2 ms before to check the Latch Up interrupt */ |
963 |
OS_piTaskSuspend (2); |
964 |
/* Unmask all memory module interrupts */ |
965 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ABIL_ALL); |
966 |
status =SUCCESSFUL; |
967 |
} |
968 |
|
969 |
return (status); |
970 |
|
971 |
} |
972 |
|
973 |
|
974 |
|
975 |
/*****************************************************************************/ |
976 |
/* @Function: FT_ifMMSUStatusInit */ |
977 |
/* @Purpose : */ |
978 |
/* The function initializes the MMSU status structure with the default */ |
979 |
/* value. */ |
980 |
/* */ |
981 |
/* @@ */ |
982 |
/* @Parameter Name @Mode @Description */ |
983 |
/* MemModTestDef IN Pointer to Memory Module test pattern */ |
984 |
/* Mmsu OUT Pointer to MMSU status structure */ |
985 |
/* (FT_MMSU_STATUS type) */ |
986 |
/* @@ */ |
987 |
/*****************************************************************************/ |
988 |
void FT_ifMMSUStatusInit(FT_MMSU_STATUS* Mmsu, void* MemModTestDef) |
989 |
{ |
990 |
FT_MOD_TEST* memModTestDef; |
991 |
unsigned int i,c; |
992 |
|
993 |
|
994 |
/* MMSU Memory Module status initalization */ |
995 |
for (i=0; i<FT_MAX_MEM_MOD; i++) |
996 |
{ |
997 |
Mmsu->Module [i].State =FT_STATE_MOD_OK; |
998 |
Mmsu->Module [i].Mode =FT_MODE_MEM_MOD_OFF; |
999 |
/* Columns status initalization */ |
1000 |
for (c=0; c<FT_MAX_COLUMN; c++) |
1001 |
{ |
1002 |
Mmsu->Module [i].Column[c] =FT_COLUMN_OFF; |
1003 |
} |
1004 |
/* Bite status initalization */ |
1005 |
Mmsu->Module[i].Bite.Abil =FT_TEST_PATTERN_EN; |
1006 |
Mmsu->Module[i].Bite.Type =FT_TEST_PATTERN_FIX; |
1007 |
Mmsu->Module[i].Bite.Pattern =0x00; |
1008 |
Mmsu->Module[i].Bite.Result =FT_TEST_MOD_NOT_PERFORMED; |
1009 |
Mmsu->Module[i].Bite.HWError =0x00; |
1010 |
|
1011 |
memModTestDef = (FT_MOD_TEST*)MemModTestDef; |
1012 |
/* Test status initalization */ |
1013 |
for (c=0; c<FT_MAX_TEST_PATTERN; c++,memModTestDef++) |
1014 |
{ |
1015 |
Mmsu->Module[i].Test[c] =*memModTestDef; |
1016 |
} |
1017 |
} |
1018 |
|
1019 |
} |
1020 |
|
1021 |
|
1022 |
|
1023 |
/*****************************************************************************/ |
1024 |
/* @Function: FT_ifMemModuleTestExec */ |
1025 |
/* @Purpose : */ |
1026 |
/* The function menages the Memory Module Test execution. The Test */ |
1027 |
/* initilizes again the MMSU status information and the File System */ |
1028 |
/* structures than causes all the stored data to be lost. */ |
1029 |
/* No information must be extracted from the MCMD that is deleted from */ |
1030 |
/* the partition. */ |
1031 |
/* The Test execution is started during this step, the following actions */ |
1032 |
/* are performed: */ |
1033 |
/* - Initialization of the MMSU status structure. */ |
1034 |
/* - Searching of the Memory Module if is in off condition and */ |
1035 |
/* initializes the test correctly. */ |
1036 |
/* - Sending a log to the History area to notify the test starting */ |
1037 |
/* operations. */ |
1038 |
/* */ |
1039 |
/* @@ */ |
1040 |
/* @Parameter Name @Mode @Description */ |
1041 |
/* MemModule IN Memory Module identifier. */ |
1042 |
/* MemModTestDef IN Memory Module test pattern (default value) */ |
1043 |
/* MMSUStatus OUT Pointer to all MMSU status structure */ |
1044 |
/* (FT_ALL_MMSU_STATUS type) */ |
1045 |
/* TestStatus OUT Pointer to test statuts structure */ |
1046 |
/* (FT_TEST_MOD_STATUS type) */ |
1047 |
/* @@ */ |
1048 |
/*****************************************************************************/ |
1049 |
|
1050 |
void FT_ifMemModuleTestExec (FT_MMSU_STATUS* MMSUStatus, |
1051 |
FT_TEST_MOD_STATUS* TestStatus, |
1052 |
void* MemModTestDef) |
1053 |
{ |
1054 |
status_code status; |
1055 |
unsigned int timetagFlag; |
1056 |
unsigned int module; |
1057 |
unsigned int testStartFlag; |
1058 |
FT_MEM_MOD* pM; |
1059 |
|
1060 |
|
1061 |
if(MMSUStatus->Module[FT_MEM_MOD_1].Mode == FT_MODE_MEM_MOD_ON) |
1062 |
{ |
1063 |
FT_opMemModuleOFF(FT_MEM_MOD_1); |
1064 |
} |
1065 |
if(MMSUStatus->Module[FT_MEM_MOD_2].Mode == FT_MODE_MEM_MOD_ON) |
1066 |
{ |
1067 |
FT_opMemModuleOFF(FT_MEM_MOD_2); |
1068 |
} |
1069 |
/* MMSU status initialization */ |
1070 |
FT_ifMMSUStatusInit(MMSUStatus,MemModTestDef); |
1071 |
testStartFlag =FALSE; |
1072 |
|
1073 |
for (module=FT_MEM_MOD_1; module<FT_MAX_MEM_MOD; module++) |
1074 |
{ |
1075 |
/* Switch ON Memory Module, if NOT OK is switched OFF */ |
1076 |
status =FT_opMemModuleON(module); |
1077 |
if (status==FT_MEM_MOD_SW_ON_OK || status==FT_MEM_MOD_ALREADY_ON) |
1078 |
{ |
1079 |
/* Try to start the Memory Module test */ |
1080 |
status =FT_ifMemModuleTest(module,MMSUStatus,TestStatus); |
1081 |
if (status==SUCCESSFUL) |
1082 |
{ |
1083 |
/*=== Module Test is started, exit from the loop ======*/ |
1084 |
testStartFlag =TRUE; |
1085 |
break; |
1086 |
} |
1087 |
} |
1088 |
} |
1089 |
|
1090 |
if (!testStartFlag) |
1091 |
{ |
1092 |
/*========================= TEST is ended ==========================*/ |
1093 |
/*= Result of the Memory Module test, Entry 6 Log in History area =*/ |
1094 |
FT_ifLogHistoryEntry6 (MMSUStatus,__LINE__); |
1095 |
} |
1096 |
} |
1097 |
|
1098 |
|
1099 |
|
1100 |
/*****************************************************************************/ |
1101 |
/* @Function: FT_ifMemModuleTestInter */ |
1102 |
/* @Purpose : */ |
1103 |
/* The function menages the Scrub Address Overflow interrupt during Memory */ |
1104 |
/* Module Bite or Test execution. The interrupt goes active evry time the */ |
1105 |
/* scubber completes a cycle on the whole memory. */ |
1106 |
/* If Memory Module is in Bite mode no memory check and no other memory */ |
1107 |
/* fill are requested therefore will be managed the test end. */ |
1108 |
/* If Memory Module is in Test mode the whole memory is filled and than */ |
1109 |
/* checked to verify the presence of the hardware errors. */ |
1110 |
/* When the Memory Module test has been completed the following actions are */ |
1111 |
/* performed: */ |
1112 |
/* - Checking of the Hardware OR and AND erorr. If such errors is */ |
1113 |
/* detected the Test or Bite mode is aborted and a message to */ |
1114 |
/* MMSUManager task is sent to perform the closing operations. */ |
1115 |
/* A log to History area is sent to notify the cause of the fail. */ |
1116 |
/* - In Bite mode no other operation is performed. In Test mode is */ |
1117 |
/* programmed the next memory test with a new pattern, otherwise if */ |
1118 |
/* no other test is requested, is sent a message to the MMSUMager to */ |
1119 |
/* manage the closing of the Memory Module test. */ |
1120 |
/* */ |
1121 |
/* @@ */ |
1122 |
/* @Parameter Name @Mode @Description */ |
1123 |
/* MMSUStatus OUT Pointer to all MMSU status structure */ |
1124 |
/* (FT_ALL_MMSU_STATUS type) */ |
1125 |
/* TestStatus OUT Pointer to test statuts structure */ |
1126 |
/* (FT_TEST_MOD_STATUS type) */ |
1127 |
/* @@ */ |
1128 |
/*****************************************************************************/ |
1129 |
|
1130 |
void FT_ifMemModuleTestInter (FT_MMSU_STATUS* MMSUStatus, |
1131 |
FT_TEST_MOD_STATUS* TestStatus) |
1132 |
{ |
1133 |
FT_MOD_TEST* pT; |
1134 |
unsigned int state; |
1135 |
unsigned int module; |
1136 |
unsigned int testIdx; |
1137 |
unsigned int mode; |
1138 |
unsigned int pendingVal; |
1139 |
unsigned int hwErr; |
1140 |
unsigned int testEndFlag; |
1141 |
unsigned int testStartFlag; |
1142 |
unsigned int i; |
1143 |
|
1144 |
if (TestStatus->State != FT_TEST_NO_RUNNING) |
1145 |
{ |
1146 |
/* Initialize local variable */ |
1147 |
state =TestStatus->State; |
1148 |
module =TestStatus->Module; |
1149 |
testIdx =TestStatus->TestIdx; |
1150 |
mode =MMSUStatus->Module[module].Mode; |
1151 |
testEndFlag =FALSE; |
1152 |
/* Next state */ |
1153 |
state++; |
1154 |
TestStatus->State =state; |
1155 |
|
1156 |
if (mode==FT_MODE_MEM_MOD_BITE) |
1157 |
{ |
1158 |
/* Memmory Module in BITE mode */ |
1159 |
pT =&MMSUStatus->Module[module].Bite; |
1160 |
testEndFlag =TRUE; |
1161 |
/* Set testIdx to Max test pattern because */ |
1162 |
/* in BITE mode no other memory fill need */ |
1163 |
testIdx =FT_MAX_TEST_PATTERN; |
1164 |
} |
1165 |
else |
1166 |
{ |
1167 |
/* Memmory Module in TEST mode */ |
1168 |
pT =&MMSUStatus->Module[module].Test[testIdx]; |
1169 |
testEndFlag =(state==FT_TEST_CHECK_PATTERN) ? TRUE : FALSE; |
1170 |
} |
1171 |
if (testEndFlag) |
1172 |
{ |
1173 |
/* Check HW_OR, interrupt */ |
1174 |
FD_piDrammaRdRPBUSReg (module,FD_PENDING_INT,&pendingVal); |
1175 |
pendingVal =FD_MM_INTER_BIT(pendingVal); |
1176 |
if (pendingVal & FD_MM_INT_HW_OR) |
1177 |
{ |
1178 |
/* Read Hard Error register */ |
1179 |
FD_piDrammaRdRPBUSReg(module,FD_HARD_ERROR_REG,&hwErr); |
1180 |
pT->Result =FT_TEST_MOD_NOT_OK; |
1181 |
pT->HWError =hwErr; |
1182 |
MMSUStatus->Module[module].State =FT_STATE_MOD_FAIL; |
1183 |
/*================ Module error, stop Test ===================*/ |
1184 |
TestStatus->State =FT_TEST_END; |
1185 |
if (mode==FT_MODE_MEM_MOD_TEST) |
1186 |
{ |
1187 |
/*== Send message to MMSUManager to menage the Test end ==*/ |
1188 |
FT_ifSndMsgMMSUManager(FT_TEST_MODULE_END,FT_TEST_MOD_NOT_OK); |
1189 |
} |
1190 |
/*================ Entry 11 Log in History Area ===============*/ |
1191 |
// LOG_INFN HA_piLogHistoryEntry11(HA_E11_MEMORY_MODULE, HA_E11_MOD_TEST_HW_ERR,module, hwErr); |
1192 |
/*@LOG Test Module interrupt - hwErr */ |
1193 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,hwErr); |
1194 |
} |
1195 |
else |
1196 |
{ |
1197 |
/* Module test is OK */ |
1198 |
pT->Result =FT_TEST_MOD_OK; |
1199 |
pT->HWError =0; |
1200 |
/* Search next pattern */ |
1201 |
testStartFlag =FALSE; |
1202 |
testIdx++; |
1203 |
while (!testStartFlag && testIdx<FT_MAX_TEST_PATTERN) |
1204 |
{ |
1205 |
pT++; |
1206 |
if (pT->Abil==FT_TEST_PATTERN_EN) |
1207 |
{ |
1208 |
/* Start the Memory Module test */ |
1209 |
FT_ifStartMemModuleTest(module,pT->Type,pT->Pattern); |
1210 |
TestStatus->State =FT_TEST_START; |
1211 |
testStartFlag =TRUE; |
1212 |
} |
1213 |
else |
1214 |
{ |
1215 |
testIdx++; |
1216 |
} |
1217 |
} |
1218 |
TestStatus->TestIdx =testIdx; |
1219 |
if (!testStartFlag) |
1220 |
{ |
1221 |
/*========== Memmory Module OK, test is finished =========*/ |
1222 |
TestStatus->State =FT_TEST_END; |
1223 |
if (mode==FT_MODE_MEM_MOD_TEST) |
1224 |
{ |
1225 |
/* Send message to MMSUManager to menage the Test end */ |
1226 |
FT_ifSndMsgMMSUManager(FT_TEST_MODULE_END,FT_TEST_MOD_OK); |
1227 |
} |
1228 |
} |
1229 |
} |
1230 |
} |
1231 |
} |
1232 |
|
1233 |
} |
1234 |
|
1235 |
|
1236 |
|
1237 |
/*****************************************************************************/ |
1238 |
/* @Function: FT_ifMemModuleTest */ |
1239 |
/* @Purpose : */ |
1240 |
/* The function initializes and starts the Memory Module test with a */ |
1241 |
/* specific pattern. */ |
1242 |
/* MMSU and Memory Module are specified in the function parameters. */ |
1243 |
/* The Test Status structure is initialized and a new test pattern is */ |
1244 |
/* searched into the test pattern table. If new pattern is found the Memory */ |
1245 |
/* Module start procedure is executed. Return code identifier is SUCCESSFUL */ |
1246 |
/* when memory test is started correctly, otherwise is UNSATISFIED. */ |
1247 |
/* */ |
1248 |
/* @@ */ |
1249 |
/* @Parameter Name @Mode @Description */ |
1250 |
/* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ |
1251 |
/* MMSUStatus OUT Pointer to all MMSU status structure */ |
1252 |
/* (FT_ALL_MMSU_STATUS type) */ |
1253 |
/* TestStatus OUT Pointer to test statuts structure */ |
1254 |
/* (FT_TEST_MOD_STATUS type) */ |
1255 |
/* status_code OUT Return code */ |
1256 |
/* @@ */ |
1257 |
/*****************************************************************************/ |
1258 |
|
1259 |
status_code FT_ifMemModuleTest (unsigned int MemModule, |
1260 |
FT_MMSU_STATUS* MMSUStatus, |
1261 |
FT_TEST_MOD_STATUS* TestStatus) |
1262 |
{ |
1263 |
status_code status; |
1264 |
FT_MEM_MOD* pM; |
1265 |
FT_MOD_TEST* pT; |
1266 |
unsigned int i; |
1267 |
|
1268 |
/* Set MMSU type */ |
1269 |
|
1270 |
/* Initialize the running test structure */ |
1271 |
TestStatus->State =FT_TEST_START; |
1272 |
TestStatus->Module =MemModule; |
1273 |
TestStatus->TestIdx =FT_START_TEST_PATTERN; |
1274 |
/* Pointer to Module structure */ |
1275 |
pM =&MMSUStatus->Module[MemModule]; |
1276 |
/* Pointer to Test Module structure */ |
1277 |
pT =&pM->Test[FT_START_TEST_PATTERN]; |
1278 |
/* Search first pattern */ |
1279 |
status =UNSATISFIED; |
1280 |
for (i=FT_START_TEST_PATTERN; i<FT_MAX_TEST_PATTERN; i++,pT++) |
1281 |
{ |
1282 |
if (pT->Abil==FT_TEST_PATTERN_EN) |
1283 |
{ |
1284 |
/* Start the Memory Module Test */ |
1285 |
FT_ifStartMemModuleTest(MemModule,pT->Type,pT->Pattern); |
1286 |
pM->Mode =FT_MODE_MEM_MOD_TEST; |
1287 |
status =SUCCESSFUL; |
1288 |
break; /* First pattern found, exit from the loop */ |
1289 |
} |
1290 |
} |
1291 |
|
1292 |
return (status); |
1293 |
} |
1294 |
|
1295 |
|
1296 |
|
1297 |
/*****************************************************************************/ |
1298 |
/* @Function: FT_ifStartMemModuleTest */ |
1299 |
/* @Purpose : */ |
1300 |
/* The function programs the Dramma registers to perform the test of a */ |
1301 |
/* specific Memory Module using a defined pattern. */ |
1302 |
/* The function parameters specify the MMSU, the Memory Module, the type of */ |
1303 |
/* the test, and the pattern. */ |
1304 |
/* To start the Memory Module test are performed the following actions: */ |
1305 |
/* - Clearing of all Memory Module interrupts. */ |
1306 |
/* - Masking of the SOFTERROR OVL, HARDERROR AND OR interrupts */ |
1307 |
/* - Unmasking of the SCRUB ADDRESS OVL interrupts. */ |
1308 |
/* - Programming of the Dramma REINT register to reset whole device. */ |
1309 |
/* - Programming of the Dramma SCRUBBING and REFRESH register. */ |
1310 |
/* - Programming of the Dramma INITREG to start memory fill with a FIX */ |
1311 |
/* or VARIABLE pattern depending of the test type parameter. */ |
1312 |
/* @@ */ |
1313 |
/* @Parameter Name @Mode @Description */ |
1314 |
/* MemModule IN Memory Module (FT_MEMORY_MODULE type) */ |
1315 |
/* StartType IN Type of the memory test */ |
1316 |
/* (FT_TEST_PATTERN_VAR,FT_TEST_PATTERN_FIX) */ |
1317 |
/* Pattern IN Pattern used to fill the memory */ |
1318 |
/* @@ */ |
1319 |
/*****************************************************************************/ |
1320 |
|
1321 |
void FT_ifStartMemModuleTest(unsigned int MemModule, |
1322 |
unsigned int StartType, |
1323 |
|
1324 |
unsigned int Pattern) |
1325 |
{ |
1326 |
unsigned int initReg; |
1327 |
|
1328 |
/* Program Dramma REINT register */ |
1329 |
FD_piDrammaWrWPBUSReg(MemModule,FD_REINIT,0); |
1330 |
/* Program Dramma SCRUBBING and REFRESH register */ |
1331 |
FD_piDrammaWrWPBUSReg(MemModule,FD_SCRUBBER_REFRESH,FD_SCRABBER_REFRESH_VALUE); |
1332 |
/* Clear all memory module interrupts */ |
1333 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTCLR,FD_MM_INT_ALL); |
1334 |
/* Mask SFT_OVL,HW_OR,HW_AND memory module interrupts and */ |
1335 |
/* unmask SA_OVL */ |
1336 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INTMSK,FD_MM_INT_ABIL_SA); |
1337 |
/* Check test type */ |
1338 |
if (StartType==FT_TEST_PATTERN_VAR) |
1339 |
{ |
1340 |
/* Start Memory Module filling with a VARIABLE pattern */ |
1341 |
initReg =FD_INITREG_PATTERN_VAR; |
1342 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INITREG,initReg); |
1343 |
} |
1344 |
else |
1345 |
{ |
1346 |
/* Start Memory Module filling with a FIX pattern */ |
1347 |
initReg =FD_INITREG_PATTERN_FIX | Pattern; |
1348 |
FD_piDrammaWrWPBUSReg(MemModule,FD_INITREG,initReg); |
1349 |
} |
1350 |
} |
1351 |
|
1352 |
|
1353 |
|
1354 |
/*****************************************************************************/ |
1355 |
/* @Function: FT_ifTestModuleEnd */ |
1356 |
/* @Purpose : */ |
1357 |
/* The function menages the Memory Module test end condition, and the */ |
1358 |
/* starting of the next Memeory Module test. */ |
1359 |
/* The actions performed are the following: */ |
1360 |
/* - The MMSU Test Running Status structure is reseted. */ |
1361 |
/* - The Memory Module is forced to OFF condition. */ |
1362 |
/* - Searching of the next Memory Module to test and calling the */ |
1363 |
/* function to perform the test starting. */ |
1364 |
/* - The MMSU is forced to OFF condition if all Memory Module have */ |
1365 |
/* executed the test procedure. */ |
1366 |
/* - If both MMSU local and remote have completed the Memory Module. */ |
1367 |
/* test is sent a log to History area with the results of the tests. */ |
1368 |
/* */ |
1369 |
/* @@ */ |
1370 |
/* @Parameter Name @Mode @Description */ |
1371 |
/* MMSUStatus OUT Pointer to all MMSU status structure */ |
1372 |
/* (FT_ALL_MMSU_STATUS type) */ |
1373 |
/* TestStatus OUT Pointer to test statuts structure */ |
1374 |
/* (FT_TEST_MOD_STATUS type) */ |
1375 |
/* TestStatus OUT Pointer to test statuts structure */ |
1376 |
/* (FT_TEST_MOD_STATUS type) */ |
1377 |
/* @@ */ |
1378 |
/*****************************************************************************/ |
1379 |
|
1380 |
void FT_ifTestModuleEnd (unsigned int TestResult, |
1381 |
FT_MMSU_STATUS* MMSUStatus, |
1382 |
FT_TEST_MOD_STATUS* TestStatus) |
1383 |
{ |
1384 |
status_code status; |
1385 |
FT_MEM_MOD* pM; |
1386 |
unsigned int module; |
1387 |
unsigned int endTestFlag; |
1388 |
unsigned int testStartFlag; |
1389 |
|
1390 |
module =TestStatus->Module; |
1391 |
|
1392 |
/* Reset of the MMSU Test Running Status structure */ |
1393 |
TestStatus->State =FT_TEST_NO_RUNNING; |
1394 |
TestStatus->Module =0xffffffff; /* No Module index */ |
1395 |
TestStatus->TestIdx =0xffffffff; /* No Pattern index */ |
1396 |
|
1397 |
/* Memory Module Test is ended, switch OFF the Module */ |
1398 |
status =FT_piMemModuleOFF(module); |
1399 |
/* Test the next Memory Module */ |
1400 |
module++; |
1401 |
testStartFlag =FALSE; |
1402 |
endTestFlag =FALSE; |
1403 |
while (!testStartFlag && !endTestFlag && (TestResult!=FT_TEST_MOD_ABORT)) |
1404 |
{ |
1405 |
/* Check if all MMSU Memory Module are tested */ |
1406 |
if (module<FT_MAX_MEM_MOD) |
1407 |
{ |
1408 |
/* Switch ON Memory Module, if NOT OK is switched OFF */ |
1409 |
status =FT_opMemModuleON(module); |
1410 |
if (status==FT_MEM_MOD_SW_ON_OK) |
1411 |
{ |
1412 |
/* Try to start the Memory Module test */ |
1413 |
status =FT_ifMemModuleTest(module,MMSUStatus,TestStatus); |
1414 |
if (status==SUCCESSFUL) |
1415 |
{ |
1416 |
/*==== Module Test is started, exit from the loop ======*/ |
1417 |
testStartFlag =TRUE; |
1418 |
} |
1419 |
} |
1420 |
if (!testStartFlag) |
1421 |
{ |
1422 |
module++; |
1423 |
} |
1424 |
} |
1425 |
else |
1426 |
{ |
1427 |
endTestFlag =TRUE; |
1428 |
} |
1429 |
} |
1430 |
|
1431 |
if (endTestFlag || (TestResult==FT_TEST_MOD_ABORT)) |
1432 |
{ |
1433 |
/*========================= TEST is ended ==========================*/ |
1434 |
/* Sending a log to the History area to notify the Pdht Test result */ |
1435 |
FT_ifLogHistoryEntry6 (MMSUStatus,__LINE__); |
1436 |
|
1437 |
} |
1438 |
|
1439 |
} |
1440 |
|
1441 |
/*****************************************************************************/ |
1442 |
/* @Function: FT_ifLogHistoryEntry6 */ |
1443 |
/* @Purpose : */ |
1444 |
/* The function compiles a message (MsgTask structure) whose content */ |
1445 |
/* (Info field) is foramtted in according to the layout defined by the */ |
1446 |
/* Entry Type 6. The message is sent into the mailbox of the HistoryArea */ |
1447 |
/* object. */ |
1448 |
/* The Entry Type 6 defines the PDHT test results. The details are obtained */ |
1449 |
/* by calling a function that compiles a report word in according to the */ |
1450 |
/* Entry Type 6 format. */ |
1451 |
/* */ |
1452 |
/* @@ */ |
1453 |
/* @Parameter Name @Mode @Description */ |
1454 |
/* MMSUStatus IN Pointer to all MMSU status structure */ |
1455 |
/* (FT_ALL_MMSU_STATUS type) */ |
1456 |
/* @@ */ |
1457 |
/*****************************************************************************/ |
1458 |
|
1459 |
void FT_ifLogHistoryEntry6 (FT_MMSU_STATUS* MMSUStatus,unsigned int line) |
1460 |
{ |
1461 |
MsgTsk sndMsg; |
1462 |
TI_TIME obtime; |
1463 |
unsigned int testReport; |
1464 |
|
1465 |
/* Get OBT to time tag the Log */ |
1466 |
#warning do we want OBT in s or in ms ? if ms, russian must be warned ? |
1467 |
TI_piGetTimeInfo_ms(&obtime); |
1468 |
/* Get the PDHT current state */ |
1469 |
|
1470 |
|
1471 |
/* Get Test report */ |
1472 |
FT_ifGetReportTest(MMSUStatus,&testReport); |
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
/* Compile the Entry Type 6 fields |
1478 |
*((unsigned short* )&sndMsg.Info[0]) =HA_HEADER_E6 | HA_E6_TEST_MCMD_FLAG; |
1479 |
*((unsigned short* )&sndMsg.Info[2]) =(obtime >>16); |
1480 |
*((unsigned short* )&sndMsg.Info[4]) =(obtime & 0xffff); |
1481 |
*((unsigned short* )&sndMsg.Info[6]) =(testReport & 0xffff); |
1482 |
*((unsigned short* )&sndMsg.Info[8]) = 0x0000; |
1483 |
sndMsg.Code = HA_TRACEVENT; |
1484 |
sndMsg.LlInfo = HA_SIZEW_E0; |
1485 |
*/ |
1486 |
|
1487 |
/* Send message to the Histrory area */ |
1488 |
// HA_piSndMsgHistoryArea(&sndMsg); |
1489 |
/*@LOG LOG History Entry 6 - testreport */ |
1490 |
LU_INFN_LOG(LU_CRITICAL|LU_HA|LU_NORMAL_TRACE,LU_MASK(__FILEID__),__FILEID__,line,testReport); |
1491 |
} |
1492 |
|
1493 |
|
1494 |
|
1495 |
/*****************************************************************************/ |
1496 |
/* @Function: FT_ifGetReportTest */ |
1497 |
/* @Purpose : */ |
1498 |
/* The function formats the MMSUs (Local and Remote) test results in */ |
1499 |
/* according to the bits structure defined in the Entry Type 6 layout. */ |
1500 |
/* The test informations are obtained from the content of the MMSU status */ |
1501 |
/* structure. */ |
1502 |
/* */ |
1503 |
/* @@ */ |
1504 |
/* @Parameter Name @Mode @Description */ |
1505 |
/* MMSUStatus IN Pointer to all MMSU status structure */ |
1506 |
/* (FT_ALL_MMSU_STATUS type) */ |
1507 |
/* Report OUT Returned test report */ |
1508 |
/* @@ */ |
1509 |
/*****************************************************************************/ |
1510 |
|
1511 |
void FT_ifGetReportTest(FT_MMSU_STATUS* MMSUStatus, unsigned int* Report) |
1512 |
{ |
1513 |
FT_MEM_MOD* pM; |
1514 |
unsigned int mask; |
1515 |
unsigned int report; |
1516 |
unsigned int i; |
1517 |
|
1518 |
/* Report structure : */ |
1519 |
/* 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 */ |
1520 |
/* M2 M1 */ |
1521 |
|
1522 |
/*=========== Get MMSU Local test result =========*/ |
1523 |
pM =&MMSUStatus->Module[0]; |
1524 |
for (i=0,mask =1,report =0; i<FT_MAX_MEM_MOD; i++,pM++,mask <<=1) |
1525 |
{ |
1526 |
if (pM->State != FT_STATE_MOD_OK) |
1527 |
{ |
1528 |
report |=mask; |
1529 |
} |
1530 |
} |
1531 |
|
1532 |
*Report = report; |
1533 |
|
1534 |
} |
1535 |
|
1536 |
/*****************************************************************************/ |
1537 |
/* @Function: FT_ifGetModeDetails */ |
1538 |
/* @Purpose : */ |
1539 |
/* The function formats the current Mission Modes status in according to */ |
1540 |
/* to the bits structure defined in the Entry Type 0 layout. */ |
1541 |
/* The Mission Modes informations are obtained from the content of the Open */ |
1542 |
/* Channel structure. From each open channel are extracted the current */ |
1543 |
/* information about the status of the active operational mode. */ |
1544 |
/* */ |
1545 |
/* @@ */ |
1546 |
/* @Parameter Name @Mode @Description */ |
1547 |
/* ChOpen IN Pointer to the channels structure */ |
1548 |
/* (FT_CHANNELS_OPEN type) */ |
1549 |
/* Report OUT Returned test report */ |
1550 |
/* @@ */ |
1551 |
/*****************************************************************************/ |
1552 |
|
1553 |
void FT_ifGetModeDetails (unsigned int* ModeReport) |
1554 |
{ |
1555 |
unsigned int modeRep; |
1556 |
|
1557 |
modeRep =0; |
1558 |
*ModeReport =modeRep; |
1559 |
} |
1560 |
|
1561 |
/*****************************************************************************/ |
1562 |
/* @Function: FT_ifMCMDDownLinkExec */ |
1563 |
/* @Purpose : */ |
1564 |
/* The function menages the Downlink MCMD execution by opening the RWChannel*/ |
1565 |
/* in downlink mode, switching onthe TAM IF and starting the StartPlayback */ |
1566 |
/* trigger Timer */ |
1567 |
/* */ |
1568 |
/* @@ */ |
1569 |
/* @Parameter Name @Mode @Description */ |
1570 |
/* PtrMcmd IN Pointer to MCMD header */ |
1571 |
/* (MA_HEADER_MCMD type) */ |
1572 |
/* status_code OUT Return code */ |
1573 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
1574 |
/* @@ */ |
1575 |
/*****************************************************************************/ |
1576 |
|
1577 |
status_code FT_ifMCMDDownLinkExec(MA_HEADER_MCMD* PtrMcmd, |
1578 |
FT_RW_CH* PtrRWChannel) |
1579 |
{ |
1580 |
status_code status = HA_E2_MCMD_OK; |
1581 |
UINT16* pMcmdInfo; |
1582 |
UINT32 timetagFlag; |
1583 |
UINT32 fileId; |
1584 |
UINT32 rawFlag; |
1585 |
UINT32 dlSectors; |
1586 |
UINT32 tamId; |
1587 |
|
1588 |
UINT32 totalSize; |
1589 |
UINT32 sectors; |
1590 |
FS_FILE_DESCR fileInfo; |
1591 |
MsgTsk Msg; |
1592 |
SM_ACQMODE acqMode; |
1593 |
FS_EXITCODE imageStat; |
1594 |
BOOL newImage; |
1595 |
/* word to send to INFN */ |
1596 |
UINT16 word_06; |
1597 |
UINT16 word_07; |
1598 |
UINT16 word_08; |
1599 |
TI_TIME WaitForStartDownlink; |
1600 |
TI_TIME DownlinkStartTime; |
1601 |
TI_TIME DownlinkIntervalTime; |
1602 |
TI_TIME CurrentMoscowTime; |
1603 |
|
1604 |
/* Extract parameters and delete MCMD from partition */ |
1605 |
|
1606 |
pMcmdInfo =(UINT16* )PtrMcmd->PtrMCMD; |
1607 |
// Bit 0 |
1608 |
fileId =(UINT32)((*(pMcmdInfo+OFFSET_HEADER)) & 0x0001); |
1609 |
// Bit 1-2 |
1610 |
tamId =(UINT32)((*(pMcmdInfo+OFFSET_HEADER)) & 0x0006) >> 1; |
1611 |
// Bit 3 |
1612 |
rawFlag =(UINT32)((*(pMcmdInfo+OFFSET_HEADER)) & 0x0008) >> 3; |
1613 |
// Bit 4-15 |
1614 |
dlSectors =(UINT32)((*(pMcmdInfo+OFFSET_HEADER)) & 0xfff0) >> 4; |
1615 |
word_06 = *(pMcmdInfo + OFFSET_HEADER + 1); |
1616 |
word_07 = *(pMcmdInfo + OFFSET_HEADER + 2); |
1617 |
word_08 = *(pMcmdInfo + OFFSET_HEADER + 3); |
1618 |
|
1619 |
/* get the 6th bit for the main/spare selector: */ |
1620 |
// Changed since TM in Rome: main_spare = (word_08 & 0x0020) >> 5; |
1621 |
FT_main_spare = (word_07 & 0x0020) >> 5; |
1622 |
|
1623 |
/* Delete MCMD from partition */ |
1624 |
timetagFlag =(*(pMcmdInfo+1)&TIMETAG_MASK) ? TIMETAG_MCMD : IMMEDIATE_MCMD; |
1625 |
MA_piDelBufferMCMD(PtrMcmd->PtrMCMD,timetagFlag); |
1626 |
|
1627 |
/* here call INFN provided interface for copy word_0x */ |
1628 |
|
1629 |
/* Check that the active memory module is ON */ |
1630 |
if(PtrRWChannel->PtrModuleStatus->Mode != FT_MODE_MEM_MOD_ON) |
1631 |
{ |
1632 |
status = HA_E2_MOD_NOT_AVAILABLE; |
1633 |
} |
1634 |
|
1635 |
/* Check that the read channel is not already in use */ |
1636 |
if(PtrRWChannel->ReadMode != FT_CLOSED) |
1637 |
{ |
1638 |
status = HA_E2_DL_RUNNING; |
1639 |
} |
1640 |
|
1641 |
if(status == SUCCESSFUL) |
1642 |
{ |
1643 |
PtrRWChannel->ReadSectors = 0; |
1644 |
/* Init the playback automa status */ |
1645 |
PtrRWChannel->PlayBackStatus = FT_READY; |
1646 |
|
1647 |
/* |
1648 |
* Possibile Ottimizzazione spostare il cambio di stato e |
1649 |
* il setting di PtrRWChannel->ReadMod dopo il timer!! |
1650 |
*/ |
1651 |
#warning "Possibile Ottimizzazione spostare il cambio di stato e il setting di PtrRWChannel->ReadMod dopo il timer" |
1652 |
|
1653 |
/* Stop the acquisition and the SRAM page storage */ |
1654 |
|
1655 |
#if 0 |
1656 |
#warning "e' necessario mettere in SM_IDLE lo stato?????" |
1657 |
acqMode = PM_pi_GetAcqMode(); |
1658 |
PM_pi_SetAcqMode(SM_IDLE); |
1659 |
FT_ifDisableStore(PtrRWChannel, TRUE); |
1660 |
#endif |
1661 |
|
1662 |
if(rawFlag == TRUE) |
1663 |
{ |
1664 |
/* Prepare a sector chain that starts from the sector number 0 and */ |
1665 |
/* has the selected number of sectors */ |
1666 |
// FS_piMakeFileImage(0, (dlSectors * FT_SECTSIZE) / FT_SAMPLESIZE, §ors, TRUE); |
1667 |
/* Lock the read channel in raw downlink mode */ |
1668 |
PtrRWChannel->ReadMode = FT_BITEDNLK; |
1669 |
} |
1670 |
else |
1671 |
{ |
1672 |
/* Prepare a sector chain that covers all the sectors used by the */ |
1673 |
/* selected file and the HK file */ |
1674 |
|
1675 |
/* we have deleted FILE2*/ |
1676 |
// PtrRWChannel->FileId = (fileId == FT_FILE1) ? FS_FILE1 : FS_FILE2; |
1677 |
PtrRWChannel->FileId = FS_FILE1; |
1678 |
|
1679 |
/* Lock the read channel in downlink mode */ |
1680 |
PtrRWChannel->ReadMode = FT_DOWNLINK; |
1681 |
} |
1682 |
|
1683 |
|
1684 |
/* Switch on the selected TAM I/F */ |
1685 |
|
1686 |
/* FROM BRANCH_TM_SAMARA*/ |
1687 |
// TM_piSendTC (TM_VRL_MAIN_OFF,1); |
1688 |
// TM_piSendTC (TM_VRL_SPARE_OFF,1); |
1689 |
HK_SendTC (TM_VRL_OFF,1); |
1690 |
// HK_SendTC (TM_VRL_SPARE_OFF,1); |
1691 |
|
1692 |
OS_piTaskSuspend (PRH_VAR_TM_VRL_SUSPEND_HCL); |
1693 |
// old.. to remove |
1694 |
// HK_SendTC (TM_VRL_STOP,1); |
1695 |
// OS_piTaskSuspend (PRH_VAR_TM_VRL_SUSPEND_HCL); |
1696 |
|
1697 |
if(FT_main_spare == FT_VRL_MAIN) |
1698 |
HK_SendTC (TM_VRL_MAIN_ON_START,1); |
1699 |
else |
1700 |
HK_SendTC (TM_VRL_SPARE_ON_START,1); |
1701 |
|
1702 |
|
1703 |
PtrRWChannel->TamId=tamId; |
1704 |
/* Start the timer that will trigger the palyback start as soon as the */ |
1705 |
/* selected TAM I/F has completed the warm up */ |
1706 |
|
1707 |
/* |
1708 |
Set Timer to Downlink Start |
1709 |
*/ |
1710 |
|
1711 |
status = TI_piGetCurrentMoscowTime_s(&CurrentMoscowTime); |
1712 |
|
1713 |
if (status != SUCCESSFUL) |
1714 |
{ |
1715 |
/*@LOG Downlink: error getting current moscow time - status */ |
1716 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1717 |
status = HA_E2_INTERNAL_ERR; |
1718 |
FT_ifStopDownLink(PtrRWChannel); |
1719 |
// oppure FT_ifDownLinkClose(PtrRWChannel); ?? |
1720 |
} |
1721 |
else { |
1722 |
|
1723 |
status = MH_GetDownlinkInfo(&DownlinkStartTime,&DownlinkIntervalTime); |
1724 |
|
1725 |
if (status != SUCCESSFUL) |
1726 |
{ |
1727 |
/*@LOG Downlink: error getting downlink info - status */ |
1728 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1729 |
status =HA_E2_INTERNAL_ERR; |
1730 |
FT_ifStopDownLink(PtrRWChannel); |
1731 |
// oppure FT_ifDownLinkClose(PtrRWChannel); ?? |
1732 |
} |
1733 |
else |
1734 |
{ |
1735 |
|
1736 |
PtrRWChannel->DownlinkStartTime = DownlinkStartTime; |
1737 |
PtrRWChannel->DownlinkIntervalTime = DownlinkIntervalTime; |
1738 |
|
1739 |
WaitForStartDownlink = 0; |
1740 |
|
1741 |
if (DownlinkStartTime > CurrentMoscowTime){ |
1742 |
WaitForStartDownlink = DownlinkStartTime - CurrentMoscowTime; |
1743 |
|
1744 |
} |
1745 |
|
1746 |
if(WaitForStartDownlink < FT_TAM_WARMUP) |
1747 |
WaitForStartDownlink = FT_TAM_WARMUP; |
1748 |
|
1749 |
//WaitForStartDownlink=20; |
1750 |
|
1751 |
status = OS_piStartTimer(FT_TIM, TI_SECOND_TO_TICK(WaitForStartDownlink), |
1752 |
FT_ifStartDownLink_CallBack, (void*)PtrRWChannel); |
1753 |
/*@LOG Downlink: wait for start downlink*/ |
1754 |
LU_INFN_LOG(LU_NORMAL_TRACE|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,WaitForStartDownlink); |
1755 |
/*@LOG Downlink: duration of downlink */ |
1756 |
LU_INFN_LOG(LU_NORMAL_TRACE|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,DownlinkIntervalTime); |
1757 |
|
1758 |
if (status != SUCCESSFUL) |
1759 |
{ |
1760 |
// LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_FS,HA_E10_TIMER_ERR,status); |
1761 |
/*@LOG Timer not started correctly - status */ |
1762 |
LU_INFN_LOG(LU_FATAL|LU_HA ,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1763 |
status =HA_E2_INTERNAL_ERR; |
1764 |
FT_ifStopDownLink(PtrRWChannel); |
1765 |
// oppure FT_ifDownLinkClose(PtrRWChannel); ?? |
1766 |
} |
1767 |
/* Re-enable the store channel */ |
1768 |
/* and the perviously interrupted acquisition activity */ |
1769 |
#if 0 |
1770 |
FT_ifEnableStore(PtrRWChannel); |
1771 |
PM_pi_SetAcqMode(acqMode); |
1772 |
#endif |
1773 |
} |
1774 |
} |
1775 |
} |
1776 |
if (status != SUCCESSFUL) |
1777 |
{ |
1778 |
/*@LOG Downlink Error */ |
1779 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1780 |
/*============= Entry 2 Log in History Area ==========*/ |
1781 |
} |
1782 |
return (status); |
1783 |
} |
1784 |
|
1785 |
/*****************************************************************************/ |
1786 |
/* @Function: FT_ifMCMDAbordExec */ |
1787 |
/* @Purpose : */ |
1788 |
/* The function menages the Abort MCMD execution by calling the proper */ |
1789 |
/* function to abort the Downlink, Mass Memory storage or Test operation. */ |
1790 |
/* */ |
1791 |
/* @@ */ |
1792 |
/* @Parameter Name @Mode @Description */ |
1793 |
/* PtrMcmd IN Pointer to MCMD header */ |
1794 |
/* (MA_HEADER_MCMD type) */ |
1795 |
/* status_code OUT Return code */ |
1796 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
1797 |
/* @@ */ |
1798 |
/*****************************************************************************/ |
1799 |
status_code FT_ifMCMDAbordExec(MA_HEADER_MCMD* PtrMcmd, |
1800 |
FT_RW_CH* PtrRWChannel, |
1801 |
FT_TEST_MOD_STATUS* PtrTestModuleStatus) |
1802 |
{ |
1803 |
status_code status = HA_E2_MCMD_OK; |
1804 |
UINT16* pMcmdInfo; |
1805 |
UINT32 timetagFlag; |
1806 |
UINT32 abortType; |
1807 |
|
1808 |
/* Extract parameters and delete MCMD from partition */ |
1809 |
pMcmdInfo =(UINT16* )PtrMcmd->PtrMCMD; |
1810 |
// Abort Type parameter |
1811 |
abortType =(UINT32)((*(pMcmdInfo+OFFSET_HEADER)) & 0x0007); |
1812 |
|
1813 |
/* Delete MCMD from partition */ |
1814 |
timetagFlag =(*(pMcmdInfo+1)&TIMETAG_MASK) ? TIMETAG_MCMD : IMMEDIATE_MCMD; |
1815 |
MA_piDelBufferMCMD(PtrMcmd->PtrMCMD,timetagFlag); |
1816 |
|
1817 |
if(abortType & FT_ABORT_DLK) |
1818 |
{ |
1819 |
if(PtrRWChannel->ReadMode == FT_CLOSED) |
1820 |
{ |
1821 |
/* Downlink not running */ |
1822 |
/*============= Entry 2 Log in History Area ==========*/ |
1823 |
// LOG_INFN HA_piLogHistoryEntry2(PtrMcmd->Type,HA_E2_INVALID_DL_ABORT); |
1824 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,HA_E2_INVALID_DL_ABORT); |
1825 |
status = HA_E2_INVALID_ABORT; |
1826 |
} |
1827 |
else |
1828 |
{ |
1829 |
/* Downlink running, abort it */ |
1830 |
FT_ifDownlinkAbort(PtrRWChannel); |
1831 |
} |
1832 |
} |
1833 |
|
1834 |
if(abortType & FT_ABORT_S2M) |
1835 |
{ |
1836 |
/* SRAM to MMSU running, abort it */ |
1837 |
FT_ifStoreAbort(PtrRWChannel); |
1838 |
} |
1839 |
|
1840 |
if(abortType & FT_ABORT_TST) |
1841 |
{ |
1842 |
if(PtrTestModuleStatus->State == FT_TEST_NO_RUNNING) |
1843 |
{ |
1844 |
/* Test not running */ |
1845 |
/*============= Entry 2 Log in History Area ==========*/ |
1846 |
// LOG_INFN HA_piLogHistoryEntry2(PtrMcmd->Type,HA_E2_INVALID_TEST_ABORT); |
1847 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,HA_E2_INVALID_TEST_ABORT); |
1848 |
status = HA_E2_INVALID_ABORT; |
1849 |
} |
1850 |
else |
1851 |
{ |
1852 |
/* Test running, abort it */ |
1853 |
PtrTestModuleStatus->State = FT_TEST_NO_RUNNING; |
1854 |
FT_ifSndMsgMMSUManager(FT_TEST_MODULE_END,FT_TEST_MOD_ABORT); |
1855 |
} |
1856 |
} |
1857 |
/*============= Entry 2 Log in History Area ==========*/ |
1858 |
// LOG_INFN HA_piLogHistoryEntry2 (PtrMcmd->Type,status); |
1859 |
LU_INFN_LOG(LU_NORMAL_TRACE|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1860 |
} |
1861 |
|
1862 |
|
1863 |
|
1864 |
/*****************************************************************************/ |
1865 |
/* @Function: FT_ifStartDownLink */ |
1866 |
/* @Purpose : */ |
1867 |
/* This function is used to start the Playback operation. */ |
1868 |
/* */ |
1869 |
/* @@ */ |
1870 |
/* @Parameter Name @Mode @Description */ |
1871 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
1872 |
/* TimerId IN Timer identification */ |
1873 |
/* @@ */ |
1874 |
/*****************************************************************************/ |
1875 |
|
1876 |
void FT_ifStartDownLink(FT_RW_CH* PtrRWChannel) |
1877 |
{ |
1878 |
unsigned int intLevel; |
1879 |
FS_SECT_DESCR sectorInfo; |
1880 |
status_code status; |
1881 |
TI_TIME DownlinkTime; |
1882 |
|
1883 |
SM_ACQMODE acqMode; |
1884 |
|
1885 |
/* Check if the read channel is locked in any kind of downlink mode */ |
1886 |
if(PtrRWChannel->ReadMode == FT_DOWNLINK || |
1887 |
PtrRWChannel->ReadMode == FT_BITEDNLK) |
1888 |
{ |
1889 |
|
1890 |
#if 1 |
1891 |
#warning "e' necessario mettere in SM_IDLE lo stato?????" |
1892 |
acqMode = PM_pi_GetAcqMode(); |
1893 |
PM_pi_SetAcqMode(SM_IDLE); |
1894 |
FT_ifDisableStore(PtrRWChannel, TRUE); |
1895 |
#endif |
1896 |
|
1897 |
/*========= Entry 0 Log in History Area ==========*/ |
1898 |
// LOG_INFN HA_piLogHistoryEntry0(HA_E0_STARTING,HA_E0_DOWN_LINK,HA_E0_DL_BIT); |
1899 |
/*@LOG Start downlink */ |
1900 |
LU_INFN_LOG(LU_NORMAL_TRACE|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,HA_E0_DL_BIT); |
1901 |
/* Enable the playback related interrupt */ |
1902 |
OS_piInterDisable(&intLevel); |
1903 |
SD_piClearInt(SD_RPB_EOT); |
1904 |
SD_piUnMaskInt(SD_RPB_EOT); |
1905 |
OS_piInterEnable(intLevel); |
1906 |
|
1907 |
/* Program the DRAMMA and WPBUS with the info about the first two sectors */ |
1908 |
/* and start the data transfer */ |
1909 |
FS_piGetCurrentSector(§orInfo); |
1910 |
FD_piDrammaWrWPBUSReg(PtrRWChannel->ActiveModule, FD_RADDR1_WPBUS, sectorInfo.SectAddr); |
1911 |
|
1912 |
// per consentire il download di settori da 1024*1015 byte, abbiamo aggiunto la seguente istruzione e cambiato quella successiva |
1913 |
|
1914 |
FD_piSetBlockLength(FT_SECTSIZE / FT_SAMPLESIZE); |
1915 |
|
1916 |
// Start Timer di finestra temporale downlink. |
1917 |
|
1918 |
DownlinkTime = PtrRWChannel->DownlinkIntervalTime; |
1919 |
|
1920 |
status = OS_piStartTimer_INFN(DNLK_TIM, TI_SECOND_TO_TICK(DownlinkTime), |
1921 |
FT_ifStopDownLink_CallBack, (void*)PtrRWChannel); |
1922 |
/*@LOG Downlink: StartTimer_INFN - status */ |
1923 |
LU_INFN_LOG(LU_NORMAL_TRACE|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1924 |
if (status != SUCCESSFUL) |
1925 |
{ |
1926 |
/* Timer not started correctly */ |
1927 |
// LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_FS,HA_E10_TIMER_ERR,status); |
1928 |
/*@LOG Downlink - status */ |
1929 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
1930 |
status =HA_E2_INTERNAL_ERR; |
1931 |
FT_ifStopDownLink(PtrRWChannel); |
1932 |
// oppure FT_ifDownLinkClose(PtrRWChannel); ?? |
1933 |
} |
1934 |
else |
1935 |
{ |
1936 |
/*============= Entry 2 Log in History Area ==========*/ |
1937 |
// HA_piLogHistoryEntry2 (PtrMcmd->Type,status); |
1938 |
FD_piStartTransferFromMemory(PtrRWChannel->ActiveModule, TRUE); |
1939 |
|
1940 |
OS_piTaskSuspend (PRH_VAR_TM_VRL_SUSPEND_BEFORE_START); |
1941 |
// FROM BRANCH_TM_SAMARA |
1942 |
if(FT_main_spare == FT_VRL_MAIN) |
1943 |
HK_SendTC (TM_VRL_MAIN_ON_START,1); |
1944 |
else |
1945 |
HK_SendTC (TM_VRL_SPARE_ON_START,1); |
1946 |
// HK_SendTC |
1947 |
// TM_piSendTC (TM_VRL_START,1); |
1948 |
OS_piTaskSuspend (PRH_VAR_TM_VRL_SUSPEND_HCL); |
1949 |
|
1950 |
// FD_piStartTransferFromMemory(PtrRWChannel->ActiveModule, FALSE); |
1951 |
} |
1952 |
|
1953 |
/* |
1954 |
This 3-line comment had indroduced from zulianello@laben in his visit in Roma, 28.07.2003 |
1955 |
in order to fix the "End of 1-MB gap problem" |
1956 |
|
1957 |
FS_piGetNextSector(§orInfo); |
1958 |
FD_piDrammaWrWPBUSReg(PtrRWChannel->ActiveModule, FD_RADDR1_WPBUS, sectorInfo.SectAddr); |
1959 |
FD_piStartTransferFromMemory(PtrRWChannel->ActiveModule, FALSE); |
1960 |
*/ |
1961 |
|
1962 |
PtrRWChannel->PlayBackStatus = FT_RUN; |
1963 |
|
1964 |
#if 1 |
1965 |
FT_ifEnableStore(PtrRWChannel); |
1966 |
PM_pi_SetAcqMode(acqMode); |
1967 |
#endif |
1968 |
|
1969 |
} |
1970 |
} |
1971 |
|
1972 |
|
1973 |
/*****************************************************************************/ |
1974 |
/* @Function: FT_ifDownLinkClose */ |
1975 |
/* @Purpose : */ |
1976 |
/* This function is used to close the Downlink operation and RWChannel */ |
1977 |
/* via the MMSU Manager */ |
1978 |
/* @@ */ |
1979 |
/* @Parameter Name @Mode @Description */ |
1980 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
1981 |
/* @@ */ |
1982 |
/*****************************************************************************/ |
1983 |
|
1984 |
rtems_timer_service_routine FT_ifStopDownLink_CallBack(rtems_id timer_id,void *PtrRWChannel) |
1985 |
{ |
1986 |
MsgTsk SndMsg; |
1987 |
status_code s; |
1988 |
SndMsg.Code = FT_STOP_DOWNLINK; |
1989 |
s=FT_opSndMsgMMSUManager(&SndMsg); |
1990 |
} |
1991 |
|
1992 |
rtems_timer_service_routine FT_ifStartDownLink_CallBack(rtems_id timer_id,void *PtrRWChannel) |
1993 |
{ |
1994 |
MsgTsk SndMsg; |
1995 |
status_code s; |
1996 |
SndMsg.Code = FT_START_DOWNLINK; |
1997 |
s=FT_opSndMsgMMSUManager(&SndMsg); |
1998 |
} |
1999 |
|
2000 |
/*****************************************************************************/ |
2001 |
/* @Function: FT_ifDownLinkClose */ |
2002 |
/* @Purpose : */ |
2003 |
/* This function is used to close the Downlink operation and RWChannel */ |
2004 |
/* */ |
2005 |
/* @@ */ |
2006 |
/* @Parameter Name @Mode @Description */ |
2007 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2008 |
/* @@ */ |
2009 |
/*****************************************************************************/ |
2010 |
|
2011 |
void FT_ifStopDownLink(FT_RW_CH* PtrRWChannel) |
2012 |
{ |
2013 |
unsigned int intLevel; |
2014 |
status_code status; |
2015 |
// Disable ReadEOT |
2016 |
OS_piInterDisable(&intLevel); |
2017 |
SD_piClearInt(SD_RPB_EOT); |
2018 |
SD_piMaskInt(SD_RPB_EOT); |
2019 |
OS_piInterEnable(intLevel); |
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
// SET START to 0 : START HLC 4 |
2025 |
|
2026 |
// FROM BRANCH_TM_SAMARA |
2027 |
|
2028 |
// if(FT_main_spare == FT_VRL_MAIN) |
2029 |
HK_SendTC (TM_VRL_OFF,1); |
2030 |
// else |
2031 |
// HK_SendTC (TM_VRL_SPARE_OFF,1); |
2032 |
|
2033 |
/* |
2034 |
|
2035 |
HK_SendTC (TM_VRL_STOP, 0x1); |
2036 |
OS_piTaskSuspend (PRH_VAR_TM_VRL_SUSPEND_HCL); |
2037 |
|
2038 |
HK_SendTC (TM_VRL_OFF, 0x1); |
2039 |
|
2040 |
*/ |
2041 |
OS_piTaskSuspend (PRH_VAR_TM_VRL_SUSPEND_HCL); |
2042 |
|
2043 |
|
2044 |
// Reset DMA forse non necessario!!! |
2045 |
FD_piAbortTransfer(FD_ABT_READ); |
2046 |
|
2047 |
OS_piCancelTimer_INFN(DNLK_TIM); |
2048 |
|
2049 |
status = FS_piUpdateSectorPointer(); |
2050 |
|
2051 |
/* Close the read channel */ |
2052 |
PtrRWChannel->ReadMode = FT_CLOSED; |
2053 |
/* Update the store channel status enabling again the storage */ |
2054 |
/* into mass memory */ |
2055 |
FT_ifEnableStore(PtrRWChannel); |
2056 |
/*@LOG Stop Download - status */ |
2057 |
LU_INFN_LOG(LU_NORMAL_TRACE|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
2058 |
PM_SendCommand(PM_INFN_END_OF_DOWNLINK); |
2059 |
} |
2060 |
|
2061 |
/*****************************************************************************/ |
2062 |
/* @Function: FT_ifDownLinkClose */ |
2063 |
/* @Purpose : */ |
2064 |
/* This function is used to close the Downlink operation and RWChannel */ |
2065 |
/* */ |
2066 |
/* @@ */ |
2067 |
/* @Parameter Name @Mode @Description */ |
2068 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2069 |
/* @@ */ |
2070 |
/*****************************************************************************/ |
2071 |
|
2072 |
void FT_ifDownLinkClose(FT_RW_CH* PtrRWChannel) |
2073 |
{ |
2074 |
unsigned int intLevel; |
2075 |
|
2076 |
if(PtrRWChannel->ReadMode == FT_DOWNLINK) |
2077 |
{ |
2078 |
/* If a playback operation of a regular file was ended then */ |
2079 |
if(PtrRWChannel->PlayBackStatus == FT_END) { |
2080 |
/* Reset the files that has just been downloaded */ |
2081 |
FS_piResetFile(PtrRWChannel->FileId); |
2082 |
FS_piResetFile(FS_HK); |
2083 |
/*========= Entry 0 Log in History Area ==========*/ |
2084 |
// LOG_INFN HA_piLogHistoryEntry0(HA_E0_EXITING,HA_E0_DOWN_LINK,0); |
2085 |
/*@LOG DownLinkClose: reset file */ |
2086 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,0); |
2087 |
} |
2088 |
} |
2089 |
/* End of a raw downlink */ |
2090 |
if(PtrRWChannel->ReadMode == FT_BITEDNLK) |
2091 |
{ |
2092 |
if(PtrRWChannel->PlayBackStatus == FT_END) { |
2093 |
/*========= Entry 0 Log in History Area ==========*/ |
2094 |
// LOG_INFN HA_piLogHistoryEntry0(HA_E0_EXITING,HA_E0_DOWN_LINK,0); |
2095 |
/*@LOG DownLinkClose: BITE in progress */ |
2096 |
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,0); |
2097 |
} |
2098 |
} |
2099 |
/* Close the read channel */ |
2100 |
PtrRWChannel->ReadMode = FT_CLOSED; |
2101 |
/* Update the store channel status enabling again the storage */ |
2102 |
/* into mass memory */ |
2103 |
FT_ifEnableStore(PtrRWChannel); |
2104 |
} |
2105 |
|
2106 |
/*****************************************************************************/ |
2107 |
/* @Function: FT_ifDownlinkAbort */ |
2108 |
/* @Purpose : */ |
2109 |
/* This function is used to close the Downlink operation and RWChannel */ |
2110 |
/* */ |
2111 |
/* @@ */ |
2112 |
/* @Parameter Name @Mode @Description */ |
2113 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2114 |
/* @@ */ |
2115 |
/*****************************************************************************/ |
2116 |
|
2117 |
void FT_ifDownlinkAbort(FT_RW_CH* PtrRWChannel) |
2118 |
{ |
2119 |
status_code status; |
2120 |
unsigned int intLevel; |
2121 |
|
2122 |
/* Stop the trigger timer for the downlink */ |
2123 |
OS_piCancelTimer(FT_TIM); |
2124 |
/* Disable all the store related interrupts */ |
2125 |
OS_piInterDisable(&intLevel); |
2126 |
SD_piMaskInt(SD_RPB_EOT); |
2127 |
OS_piInterEnable(intLevel); |
2128 |
/* If a playback is running then */ |
2129 |
if(PtrRWChannel->PlayBackStatus != FT_READY && |
2130 |
PtrRWChannel->PlayBackStatus != FT_END) |
2131 |
{ |
2132 |
/* Abort the RPBUS transfer */ |
2133 |
FD_piAbortTransfer(FD_ABT_READ); |
2134 |
} |
2135 |
/* Close the downlink operation */ |
2136 |
FT_ifDownLinkClose(PtrRWChannel); |
2137 |
} |
2138 |
|
2139 |
/*****************************************************************************/ |
2140 |
/* @Function: FT_ifRWChannelInit */ |
2141 |
/* @Purpose : */ |
2142 |
/* This function initializes the RWChannel structure used to supervise the */ |
2143 |
/* data flow to or from the memory module */ |
2144 |
/* */ |
2145 |
/* @@ */ |
2146 |
/* @Parameter Name @Mode @Description */ |
2147 |
/* status_code OUT Return code */ |
2148 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2149 |
/* PtrModInfo IN Pointer to the active module info structure */ |
2150 |
/* Module IN Active Module */ |
2151 |
/* @@ */ |
2152 |
/*****************************************************************************/ |
2153 |
|
2154 |
status_code FT_ifRWChannelInit(FT_RW_CH* PtrRWChannel, |
2155 |
FT_MEMORY_MODULE Module, |
2156 |
FT_MEM_MOD* PtrModInfo) |
2157 |
{ |
2158 |
status_code status = SUCCESSFUL; |
2159 |
unsigned int intLevel; |
2160 |
|
2161 |
/* program the WPBUS/RPBUS wait state counters */ |
2162 |
FD_piSetWPBUSWaitState(FT_WPBUS_WCS); |
2163 |
FD_piSetRPBUSWaitState(FT_RPBUS_WSC); |
2164 |
// By default the Active module is the Primary module |
2165 |
PtrRWChannel->ActiveModule = Module; |
2166 |
PtrRWChannel->PtrModuleStatus = PtrModInfo; |
2167 |
PtrRWChannel->ReadMode = FT_CLOSED; |
2168 |
PtrRWChannel->ReadSectors = 0; |
2169 |
PtrRWChannel->PlayBackStatus = FT_END; |
2170 |
PtrRWChannel->FileId = FS_MAXID; |
2171 |
PtrRWChannel->SaveInProgress = FALSE; |
2172 |
PtrRWChannel->CurrentPageId = SM_SKETCHBOARD; |
2173 |
PtrRWChannel->StoreEnable = FT_STR_NONE; |
2174 |
OS_piInterDisable(&intLevel); |
2175 |
/* disable any read/store related interrupts */ |
2176 |
SD_piMaskInt(SD_WPB_EOT | SD_RPB_EOT); |
2177 |
OS_piInterEnable(intLevel); |
2178 |
/* release the semaphore on save queue*/ |
2179 |
// OS_piResourceRelease ( FT_RES ); |
2180 |
// console_outbyte_polled( 0, 'R' ); |
2181 |
// console_outbyte_polled( 0, '\n' ); |
2182 |
return (status); |
2183 |
} |
2184 |
|
2185 |
/*****************************************************************************/ |
2186 |
/* @Function: FT_ifDisableStore */ |
2187 |
/* @Purpose : */ |
2188 |
/* This function is used to stop the SRAM page storage operations. */ |
2189 |
/* The current store operation is stopped, the save queue reset and no more */ |
2190 |
/* save request are accepted. */ |
2191 |
/* @@ */ |
2192 |
/* @Parameter Name @Mode @Description */ |
2193 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2194 |
/* AllStr IN Flag to force the reinit of store automa */ |
2195 |
/* @@ */ |
2196 |
/*****************************************************************************/ |
2197 |
|
2198 |
void FT_ifDisableStore(FT_RW_CH* PtrRWChannel, BOOL AllStr) |
2199 |
{ |
2200 |
unsigned int intLevel; |
2201 |
FT_SAVEREQUEST saveReq; |
2202 |
UINT32 reqSize; |
2203 |
|
2204 |
if(AllStr) { |
2205 |
/* Disable the store chanel */ |
2206 |
PtrRWChannel->StoreEnable = FT_STR_NONE; |
2207 |
/* If a store operation was in progress then */ |
2208 |
if(PtrRWChannel->SaveInProgress == TRUE) { |
2209 |
/* Abort the WPBUS transfer */ |
2210 |
FD_piAbortTransfer(FD_ABT_WRITE); |
2211 |
} |
2212 |
/* Notify the SRAMPageManager that any save request */ |
2213 |
/* about the skatchboard has been cancelled */ |
2214 |
OS_piInterDisable(&intLevel); |
2215 |
PM_piPageWasSaved(FS_HK); |
2216 |
OS_piInterEnable(intLevel); |
2217 |
/* release the semaphore on save queue*/ |
2218 |
// OS_piResourceRelease ( FT_RES ); |
2219 |
// console_outbyte_polled( 0, 'R' ); |
2220 |
// console_outbyte_polled( 0, '\n' ); |
2221 |
} |
2222 |
else |
2223 |
{ |
2224 |
PtrRWChannel->StoreEnable = FT_STR_CMD; |
2225 |
} |
2226 |
} |
2227 |
|
2228 |
/*****************************************************************************/ |
2229 |
/* @Function: FT_ifEnableStore */ |
2230 |
/* @Purpose : */ |
2231 |
/* This function is used to start the SRAM page storage operations. */ |
2232 |
/* */ |
2233 |
/* @@ */ |
2234 |
/* @Parameter Name @Mode @Description */ |
2235 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2236 |
/* status_code OUT Return code */ |
2237 |
/* @@ */ |
2238 |
/*****************************************************************************/ |
2239 |
|
2240 |
status_code FT_ifEnableStore(FT_RW_CH* PtrRWChannel) |
2241 |
{ |
2242 |
status_code status = FT_STR_DONE; |
2243 |
unsigned int intLevel; |
2244 |
FT_SAVEREQUEST saveReq; |
2245 |
UINT32 reqSize; |
2246 |
|
2247 |
/* If the store channel was closed */ |
2248 |
if(PtrRWChannel->StoreEnable == FT_STR_NONE) |
2249 |
{ |
2250 |
/* Init the store flag */ |
2251 |
PtrRWChannel->SaveInProgress = FALSE; |
2252 |
PtrRWChannel->CurrentPageId = SM_SKETCHBOARD; |
2253 |
} |
2254 |
/* If the read channel is closed and the current memory module */ |
2255 |
/* is up and running */ |
2256 |
if(PtrRWChannel->ReadMode == FT_CLOSED && |
2257 |
PtrRWChannel->PtrModuleStatus->State == FT_STATE_MOD_OK && |
2258 |
PtrRWChannel->PtrModuleStatus->Mode == FT_MODE_MEM_MOD_ON) { |
2259 |
/* Enable the storage both in the mass memory and towards */ |
2260 |
/* the CMD I/F */ |
2261 |
PtrRWChannel->StoreEnable = FT_STR_ALL; |
2262 |
OS_piInterDisable(&intLevel); |
2263 |
/* enable eny store related interrupts */ |
2264 |
SD_piUnMaskInt(SD_WPB_EOT); |
2265 |
OS_piInterEnable(intLevel); |
2266 |
/* release the semaphore on save queue*/ |
2267 |
// OS_piResourceRelease ( FT_RES ); |
2268 |
// console_outbyte_polled( 0, 'R' ); |
2269 |
// console_outbyte_polled( 0, '\n' ); |
2270 |
} |
2271 |
else |
2272 |
{ |
2273 |
/* Enable only the data transfer towards the CMD I/F */ |
2274 |
PtrRWChannel->StoreEnable = FT_STR_CMD; |
2275 |
} |
2276 |
} |
2277 |
|
2278 |
/*****************************************************************************/ |
2279 |
/* @Function: FT_ifBiteTORecovery */ |
2280 |
/* @Purpose : */ |
2281 |
/* This function handles the timeout event during a BITE operation */ |
2282 |
/* */ |
2283 |
/* @@ */ |
2284 |
/* @Parameter Name @Mode @Description */ |
2285 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2286 |
/* TimerId IN Timer identification */ |
2287 |
/* @@ */ |
2288 |
/*****************************************************************************/ |
2289 |
|
2290 |
void FT_ifBiteTORecovery(unsigned int TimerId, FT_RW_CH* PtrRWChannel) |
2291 |
{ |
2292 |
/* If the BITE operation dosen't end then close it and mark the module bad */ |
2293 |
FD_piDrammaWrWPBUSReg(PtrRWChannel->ActiveModule,FD_INTMSK,FD_MM_INT_DISABIL); |
2294 |
PtrRWChannel->PtrModuleStatus->State = FT_STATE_MOD_FAIL; |
2295 |
PtrRWChannel->PtrModuleStatus->Mode = FT_MODE_MEM_MOD_ON; |
2296 |
} |
2297 |
|
2298 |
/*****************************************************************************/ |
2299 |
/* @Function: FT_ifStoreAbort */ |
2300 |
/* @Purpose : */ |
2301 |
/* This function is used to close the Downlink operation and RWChannel */ |
2302 |
/* */ |
2303 |
/* @@ */ |
2304 |
/* @Parameter Name @Mode @Description */ |
2305 |
/* PtrRWChannel IN Pointer to the RWchannel manage structure */ |
2306 |
/* @@ */ |
2307 |
/*****************************************************************************/ |
2308 |
|
2309 |
void FT_ifStoreAbort(FT_RW_CH* PtrRWChannel) |
2310 |
{ |
2311 |
SM_ACQMODE acqMode; |
2312 |
|
2313 |
/* Reinit the data acquisition and SRAM page store operations */ |
2314 |
acqMode = PM_pi_GetAcqMode(); |
2315 |
|
2316 |
/* HW reset of PIF */ |
2317 |
SD_piPIFReset(); |
2318 |
/* Init the timeout timers */ |
2319 |
SD_piSetEventTimeout(SM_ETO_TICS); |
2320 |
SD_piSetDataTimeout(SM_DTO_TICS); |
2321 |
/* Init the Header length registers */ |
2322 |
SD_piSetDataHeaderLength(SM_PKTHEADER_LEN); |
2323 |
SD_piSetCalibrationHeaderLength(SM_PKTHEADER_LEN); |
2324 |
|
2325 |
|
2326 |
PM_pi_SetAcqMode(SM_IDLE); |
2327 |
FT_ifDisableStore(PtrRWChannel, TRUE); |
2328 |
FT_ifEnableStore(PtrRWChannel); |
2329 |
PM_pi_SetAcqMode(acqMode); |
2330 |
} |
2331 |
|
2332 |
|