1 |
/**************************************************************************** |
2 |
* F i l e D a t a |
3 |
* $Id: LU_LogUtility_INFN.c,v 1.24 2005/03/20 18:21:00 sebastiani Exp $ |
4 |
* $Revision: 1.24 $ |
5 |
* $Date: 2005/03/20 18:21:00 $ |
6 |
* $RCSfile: LU_LogUtility_INFN.c,v $ |
7 |
* |
8 |
**************************************************************************** |
9 |
* S W D e v e l o p m e n t E n v i r o n m e n t |
10 |
* |
11 |
* $Author: sebastiani $ |
12 |
* : |
13 |
**************************************************************************** |
14 |
* U p d a t i n g |
15 |
* |
16 |
* $Log: LU_LogUtility_INFN.c,v $ |
17 |
* Revision 1.24 2005/03/20 18:21:00 sebastiani |
18 |
* *** empty log message *** |
19 |
* |
20 |
* Revision 1.23 2005/03/06 14:54:46 sebastiani |
21 |
* version running on 06 03 2005 |
22 |
* |
23 |
* Revision 1.22 2005/02/19 10:19:38 sebastiani |
24 |
* ALM_S4_CALIB_00_HARD,ALM_S4_CALIB_00_SOFT,ALM_S4_128TRIGGER_0 added |
25 |
* |
26 |
* Revision 1.21 2004/11/25 09:20:17 sebastiani |
27 |
* *** empty log message *** |
28 |
* |
29 |
* Revision 1.20 2004/11/19 15:14:52 sebastiani |
30 |
* PRH_EXTERN_{VAR,ARR,TABLE} removed and put them on the autogenerated parameter heeader file |
31 |
* |
32 |
* Revision 1.19 2004/10/22 16:05:06 sebastiani |
33 |
* *** empty log message *** |
34 |
* |
35 |
* Revision 1.18 2004/09/17 15:01:00 faber |
36 |
* LU_INFN_LOG flags fixing |
37 |
* |
38 |
* Revision 1.17 2004/09/14 15:07:08 faber |
39 |
* New development for TimeSync, managed by interrupt. coding completed but never tested. |
40 |
* |
41 |
* Revision 1.16 2004/08/31 09:08:35 sebastiani |
42 |
* fix warning |
43 |
* |
44 |
* Revision 1.15 2004/08/26 16:54:34 sebastiani |
45 |
* version work fine |
46 |
* |
47 |
* Revision 1.14 2004/07/27 17:30:17 faber |
48 |
* OBT can be now in second or milliseconds, depending of the situazion. |
49 |
* OBT_s is used for FM compatibility, OBT_ms basically for MM infos |
50 |
* |
51 |
* Revision 1.13 2004/07/27 10:13:48 faber |
52 |
* LU_ALARM macro introduced, |
53 |
* LU_XXXX bit field "logtype" redefined. |
54 |
* HistoryArea 5 now log a 32 bit word as "info1" |
55 |
* and logging is reformatted. |
56 |
* |
57 |
* Revision 1.12 2004/06/23 13:53:16 alfarano |
58 |
* static declaration for fileid |
59 |
* |
60 |
* Revision 1.11 2004/05/13 10:47:17 faber |
61 |
* hid the HB_Store funcion in favour of wrapped funcions |
62 |
* |
63 |
* Revision 1.10 2004/03/09 09:39:27 faber |
64 |
* LU_TRACE system introduced |
65 |
* |
66 |
* Revision 1.9 2003/11/27 17:53:23 faber |
67 |
* -Power management poweron procedure done and some tested in the simulator |
68 |
* -history entry 5 now takes OBT |
69 |
* |
70 |
* Revision 1.8 2003/11/06 10:27:12 faber |
71 |
* HB_HKBuffer now implemented as multibuffer (as specified in the |
72 |
* mass memory format). Only compilation, not tested |
73 |
* |
74 |
* Revision 1.7 2003/10/21 16:09:12 alfarano |
75 |
* LU_LOG_INFN replacement for all remaining original log functions |
76 |
* |
77 |
* Revision 1.6 2003/10/17 09:25:10 sebastiani |
78 |
* __FILEID__ mechanism is now provied by global variables |
79 |
* instead of macro definitions in order to make such simbols |
80 |
* to be resolved at link time instead of compilation time. |
81 |
* |
82 |
* Revision 1.5 2003/09/19 15:57:35 faber |
83 |
* Large development update INFN software |
84 |
* |
85 |
* Revision 1.4 2003/09/16 08:42:05 faber |
86 |
* StoreOrb/Incl done / new LOG initialization |
87 |
* |
88 |
* Revision 1.3 2003/09/15 17:46:27 faber |
89 |
* HB_HKBuffer_INFN module introduced. |
90 |
* |
91 |
* Revision 1.2 2003/08/22 07:55:43 sebastiani |
92 |
* conform source to the new loganalizer.c philosophy |
93 |
* |
94 |
* Revision 1.1.1.1 2003/08/04 09:40:22 sebastiani |
95 |
* Imported sources laben rel. 19.06.2003 integrated with pam2 |
96 |
* |
97 |
* Revision 1.2 2003/07/17 11:15:04 sebastiani |
98 |
* *** empty log message *** |
99 |
* |
100 |
* Revision 1.1 2003/06/12 14:49:19 sebastiani |
101 |
* first versione of Log Module source |
102 |
* |
103 |
* |
104 |
*****************************************************************************/ |
105 |
|
106 |
|
107 |
/*============================= Include File ================================*/ |
108 |
|
109 |
#include <src/INFN/LU_SourceFileID_INFN.h> |
110 |
#define __FILEID__ _LU_LogUtility_INFN__c |
111 |
#include <src/INFN/PRH_ParamHandler_INFN.h> |
112 |
#include <src/INFN/LU_LogUtility_INFN.h> |
113 |
#include <src/INFN/PRH_ParamHandler_INFN_auto.h> |
114 |
LU_DECL_MASK(); |
115 |
|
116 |
#include <src/INFN/PRH_ParamHandler_INFN_auto.h> |
117 |
#include <src/INFN/HB_HKBuffer_INFN.h> |
118 |
#include <src/INFN/LU_LogUtility_INFN.h> |
119 |
#include <src/HKManager/HistoryArea/HA_HistoryArea_p.h> |
120 |
#include <src/HKManager/HistoryArea/HA_HistoryArea_int.h> |
121 |
#include <src/INFN/CM_Common_INFN.h> |
122 |
/*============================ Global define ================================*/ |
123 |
|
124 |
|
125 |
/*============================== global types ==============================*/ |
126 |
|
127 |
|
128 |
|
129 |
/*****************************************************************************/ |
130 |
/*=========================== Structure define ==============================*/ |
131 |
|
132 |
|
133 |
/*****************************************************************************/ |
134 |
/*============================ Enumerate define =============================*/ |
135 |
|
136 |
/*****************************************************************************/ |
137 |
|
138 |
/*=== LogUtility O P E R A T I O N E N V I R O N M ==*/ |
139 |
|
140 |
/*****************************************************************************/ |
141 |
|
142 |
|
143 |
static BOOL LU_StoreInHB_Flag; |
144 |
#include <src/INFN/LU_COMPILE_STAMP.include> |
145 |
|
146 |
// variables for TRACE() macros, trace fileid/line of the calling task |
147 |
UINT16 LU_task_info_line [LU_TOTAL_TASKS]; |
148 |
BYTE LU_task_info_fileid [LU_TOTAL_TASKS]; |
149 |
UINT16 LU_task_info_humanid[LU_TOTAL_TASKS]; |
150 |
UINT16 LU_first_task_index=0; |
151 |
|
152 |
/* the initialization that have to be done before the Laben initialization exept the OS module */ |
153 |
status_code LU_PreInit() |
154 |
{ |
155 |
LU_InitNames(); |
156 |
LU_StoreInHB_Flag = FALSE; |
157 |
LU_SetLogMaskAll(LU_DEFAULT_MASK); |
158 |
return SUCCESSFUL; |
159 |
} |
160 |
|
161 |
UINT32 LU_GetCompilationTimeStamp() { |
162 |
return LU_COMPILE_STAMP; |
163 |
} |
164 |
|
165 |
status_code LU_SetLogMaskAll(UINT16 v) |
166 |
{ |
167 |
int i; |
168 |
for(i=0;i<PRH_ARR_N_LOG_MASK;i++) |
169 |
PRH_ARR_LOG_MASK[i]=v; |
170 |
} |
171 |
|
172 |
#ifndef LOGANALIZER |
173 |
void LU_StoreInHB(BOOL storeflag) { |
174 |
LU_StoreInHB_Flag = storeflag; |
175 |
} |
176 |
#endif |
177 |
|
178 |
status_code LU_Init() { |
179 |
int i; |
180 |
#ifdef SIMULATOR |
181 |
/* write the magic number for the analizer: */ |
182 |
static char seq[4] = {0xFA , 0xFE ,0xDE, 0xFA }; |
183 |
for (i=0;i<4;i++) { |
184 |
console_outbyte_polled(0,seq[i]); |
185 |
console_outbyte_polled(1,seq[i]); |
186 |
} |
187 |
#endif |
188 |
return SUCCESSFUL; |
189 |
} |
190 |
|
191 |
void LU_WriteOnUART(unsigned char *string) |
192 |
{ |
193 |
unsigned char *s; |
194 |
if(PRH_VAR_LU_WRITE_ON_UART) { |
195 |
for ( s = string ; *s ; s++ ) |
196 |
console_outbyte_polled( 0, *s ); |
197 |
console_outbyte_polled( 0, '\r' ); |
198 |
console_outbyte_polled( 0, '\n' ); |
199 |
} |
200 |
} |
201 |
|
202 |
|
203 |
#define UWORD unsigned short int |
204 |
#define UBYTE unsigned char |
205 |
status_code LU_PutLog (MsgTsk* msg) { |
206 |
unsigned char EntryType; |
207 |
static unsigned char buf[100],str[100],str2[100]; |
208 |
unsigned int entry; |
209 |
unsigned char code; |
210 |
unsigned int time; |
211 |
unsigned int rep1,rep2,rep3,line,fileid; |
212 |
|
213 |
#if 0 |
214 |
// console_outbyte_polled(0,msg->LlInfo*sizeof(UWORD)); |
215 |
//console_outbyte_polled(1,msg->LlInfo*sizeof(UWORD)); |
216 |
for(entry=0;entry<msg->LlInfo*sizeof(UWORD);entry++) { |
217 |
console_outbyte_polled(0,msg->Info[entry]); |
218 |
//console_outbyte_polled(1,msg->Info[entry]); |
219 |
} |
220 |
#endif |
221 |
|
222 |
/* ignore all the rest: */ |
223 |
//return SUCCESSFUL; |
224 |
|
225 |
EntryType = msg->Info[0] >> 4; |
226 |
|
227 |
entry =EntryType; |
228 |
code =msg->Info[1]; |
229 |
time =(((UWORD*)(msg->Info))[1] << 16) + ((UWORD*)(msg->Info))[2]; |
230 |
rep1 =0; |
231 |
rep2 =0; |
232 |
rep3 =0; |
233 |
|
234 |
switch( EntryType ) { |
235 |
case HA_EVENT_04: |
236 |
sprintf(str,""); |
237 |
break; |
238 |
case HA_EVENT_00: |
239 |
case HA_EVENT_01: |
240 |
case HA_EVENT_02: |
241 |
case HA_EVENT_03: |
242 |
case HA_EVENT_06: |
243 |
rep1 = ((UWORD*)(msg->Info))[3]; |
244 |
sprintf(str,"R1: %10d 0x%X",rep1,rep1); |
245 |
break; |
246 |
|
247 |
case HA_EVENT_10: |
248 |
rep1 = ((UWORD*)(msg->Info))[3]; |
249 |
rep2 = ((UWORD*)(msg->Info))[4]; |
250 |
sprintf(str,"R1: %10d %X - R2: %10d 0x%X ",rep1,rep1,rep2,rep2); |
251 |
break; |
252 |
|
253 |
case HA_EVENT_05: |
254 |
line = ((UWORD*)(msg->Info))[3]; |
255 |
rep2 = ((UWORD*)(msg->Info))[4]; |
256 |
rep1 = ((UWORD*)(msg->Info))[5]; |
257 |
rep3 = rep1 | (rep2<<16); |
258 |
LU_GetSourceInfo(str2,code,line); |
259 |
sprintf(str,"INFN: Info1: %9u 0x%08x [%s]",rep3,rep3,str2); |
260 |
break; |
261 |
case HA_EVENT_07: |
262 |
case HA_EVENT_11: |
263 |
rep1 = ((UWORD*)(msg->Info))[3]; |
264 |
rep2 = ((UWORD*)(msg->Info))[4]; |
265 |
rep3 = ((UWORD*)(msg->Info))[5]; |
266 |
sprintf(str,"R1: %10d 0x%X - R2: %10d 0x%X - R3: %10d %X ",rep1,rep1,rep2,rep2,rep3,rep3); |
267 |
break; |
268 |
default: |
269 |
break; |
270 |
} |
271 |
|
272 |
sprintf(buf,"%2d OBT: %5ld Code: %3d - %s",entry,time,code,str); |
273 |
|
274 |
// TS_piWriteOnUART(buf); |
275 |
LU_WriteOnUART(buf); |
276 |
return (SUCCESSFUL); |
277 |
|
278 |
} |
279 |
|
280 |
|
281 |
|
282 |
status_code LU_trace_load_task_info(UINT32 human_id, rtems_id taskid) { |
283 |
UINT16 index=(UINT16)(taskid); |
284 |
|
285 |
/* we assume here that rtems assing an incrementing index field in the object id of every task */ |
286 |
if(LU_first_task_index==0) |
287 |
LU_first_task_index=index; |
288 |
/* check if all is OK */ |
289 |
if(index-LU_first_task_index >= LU_TOTAL_TASKS) /* internal error */ |
290 |
LU_INFN_LOG(LU_INTERNAL|LU_HA,LU_ALLLOG,__FILEID__,__LINE__,index); |
291 |
else |
292 |
LU_task_info_humanid[index-LU_first_task_index]=human_id; |
293 |
} |
294 |
|
295 |
|
296 |
status_code LU_INFN_LOG(unsigned int thistype,unsigned int localmask, |
297 |
unsigned int fileid,unsigned int line,unsigned int info1) { |
298 |
BYTE b[8]; |
299 |
BYTE *pb=b; |
300 |
TI_TIME obt_ms,obt_s; |
301 |
TI_piGetTimeInfo_ms(&obt_ms); |
302 |
if(thistype & localmask) { |
303 |
if(LU_StoreInHB_Flag) { |
304 |
CM_WRITE_BE_UINT8(pb,thistype); |
305 |
CM_WRITE_BE_UINT8(pb,fileid); |
306 |
CM_WRITE_BE_UINT16(pb,line); |
307 |
CM_WRITE_BE_UINT32(pb,info1); |
308 |
HB_StoreLog(sizeof(b),b,obt_ms); |
309 |
} |
310 |
|
311 |
#if 0 |
312 |
#warning "make all LU_DEBUG_TRACE to go in HA too. this check is only for ground: remove in flight!" |
313 |
if( (thistype & LU_DEBUG_TRACE) || (thistype & LU_NORMAL_TRACE) ) |
314 |
thistype|=LU_HA; |
315 |
#endif |
316 |
|
317 |
/* |
318 |
#ifndef DEBUG |
319 |
if (thistype & LU_HA & localmask) |
320 |
#endif |
321 |
*/ |
322 |
|
323 |
#warning do we want OBT in s or in ms ? if ms, russian must be warned ? TM was in s |
324 |
|
325 |
HA_piLogHistoryEntry5(fileid,line,info1,obt_ms / 1000); |
326 |
} |
327 |
return SUCCESSFUL; |
328 |
|
329 |
} |
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|