first commit
This commit is contained in:
327
FaultSources.c
Normal file
327
FaultSources.c
Normal file
@@ -0,0 +1,327 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FaultSources.h"
|
||||
#include "Utils.h"
|
||||
|
||||
def_sFaultSourceScoreRec ar_dFaultScores[NB_FAULT_SOURCE] =
|
||||
{
|
||||
{
|
||||
.eThisFaultSource = VOODOO_BOARD,
|
||||
.szName = "VOODOO_BOARD",
|
||||
.szLoc = "Main Board",
|
||||
.eParrentFaultSource = _INVALID_FAULT_SOURCE_,
|
||||
.dScore = 0.0
|
||||
},
|
||||
FAULT_SOURCES(GEN_FAULT_SOURCES_ARRAY)
|
||||
};
|
||||
|
||||
def_sFaultSourceScoreRec ar_dFaultScores_sorted[NB_FAULT_SOURCE];
|
||||
|
||||
void
|
||||
FaultSource_Reset()
|
||||
{
|
||||
for(def_eFaultSource idx=0;idx<NB_FAULT_SOURCE;idx++)
|
||||
ar_dFaultScores[idx].dScore = 0.0;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
FaultSource_getNbDeps(const def_eFaultSource eFaultSource)
|
||||
{
|
||||
unsigned long res = 0;
|
||||
for(unsigned long idx = 0;
|
||||
idx < NB_FAULT_SOURCE;
|
||||
idx++)
|
||||
if(ar_dFaultScores[idx].eParrentFaultSource == eFaultSource)
|
||||
res++;
|
||||
return res;
|
||||
}
|
||||
void
|
||||
FaultSource_AddScore( def_eFaultSource eFaultSource,
|
||||
double dScore)
|
||||
{
|
||||
double dDivider = 1.0;
|
||||
do
|
||||
{
|
||||
dScore /= dDivider;
|
||||
ar_dFaultScores[eFaultSource].dScore += dScore;
|
||||
eFaultSource = ar_dFaultScores[eFaultSource].eParrentFaultSource;
|
||||
dDivider = FaultSource_getNbDeps(eFaultSource);
|
||||
if(dDivider <= 0) dDivider = 1.0;
|
||||
}while(eFaultSource != _INVALID_FAULT_SOURCE_);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
FaultSource_Sort_GetIdx(const def_eFaultSource eFaultSource)
|
||||
{
|
||||
for(unsigned long idx = 0;
|
||||
idx < NB_FAULT_SOURCE;
|
||||
idx++)
|
||||
if(ar_dFaultScores_sorted[idx].eThisFaultSource == eFaultSource)
|
||||
return idx;
|
||||
return _INVALID_FAULT_SOURCE_;
|
||||
}
|
||||
|
||||
static inline void
|
||||
FaultSource_Sort_Swap( const def_eFaultSource eFaultSourceCurrentA,
|
||||
const def_eFaultSource eFaultSourceCurrentB)
|
||||
{
|
||||
static def_sFaultSourceScoreRec tmp;
|
||||
memcpy(&tmp,&ar_dFaultScores_sorted[eFaultSourceCurrentA],sizeof(def_sFaultSourceScoreRec));
|
||||
memcpy(&ar_dFaultScores_sorted[eFaultSourceCurrentA],&ar_dFaultScores_sorted[eFaultSourceCurrentB],sizeof(def_sFaultSourceScoreRec));
|
||||
memcpy(&ar_dFaultScores_sorted[eFaultSourceCurrentB],&tmp,sizeof(def_sFaultSourceScoreRec));
|
||||
}
|
||||
|
||||
void
|
||||
FaultSource_Sort()
|
||||
{
|
||||
unsigned char bSwapped = 1;
|
||||
|
||||
memcpy(ar_dFaultScores_sorted,ar_dFaultScores,sizeof(ar_dFaultScores_sorted));
|
||||
|
||||
// shaker sort
|
||||
while(bSwapped)
|
||||
{
|
||||
bSwapped = 0;
|
||||
|
||||
for(long eFaultSourceCurrentComp=0;
|
||||
eFaultSourceCurrentComp<(NB_FAULT_SOURCE-1);
|
||||
eFaultSourceCurrentComp++)
|
||||
{
|
||||
if( ar_dFaultScores_sorted[eFaultSourceCurrentComp].dScore
|
||||
< ar_dFaultScores_sorted[eFaultSourceCurrentComp+1].dScore)
|
||||
{
|
||||
FaultSource_Sort_Swap(eFaultSourceCurrentComp,eFaultSourceCurrentComp+1);
|
||||
bSwapped=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//if(!bSwapped)
|
||||
// break;
|
||||
for(long eFaultSourceCurrentComp=(NB_FAULT_SOURCE-2);
|
||||
eFaultSourceCurrentComp>=0;
|
||||
eFaultSourceCurrentComp--)
|
||||
{
|
||||
if( ar_dFaultScores_sorted[eFaultSourceCurrentComp].dScore
|
||||
< ar_dFaultScores_sorted[eFaultSourceCurrentComp+1].dScore)
|
||||
{
|
||||
FaultSource_Sort_Swap(eFaultSourceCurrentComp,eFaultSourceCurrentComp+1);
|
||||
bSwapped=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// updating refs
|
||||
for(long eFaultSourceIdx=0;
|
||||
eFaultSourceIdx<NB_FAULT_SOURCE;
|
||||
eFaultSourceIdx++)
|
||||
{
|
||||
unsigned long idx = FaultSource_Sort_GetIdx(ar_dFaultScores_sorted[eFaultSourceIdx].eParrentFaultSource);
|
||||
ar_dFaultScores_sorted[eFaultSourceIdx].eParrentFaultSource = idx;
|
||||
}
|
||||
for(long eFaultSourceIdx=0;
|
||||
eFaultSourceIdx<NB_FAULT_SOURCE;
|
||||
eFaultSourceIdx++)
|
||||
{
|
||||
ar_dFaultScores_sorted[eFaultSourceIdx].eThisFaultSource = eFaultSourceIdx;
|
||||
}
|
||||
}
|
||||
void
|
||||
FaultSource_GetLoc(def_eFaultSource eFaultSource, char* loc)
|
||||
{
|
||||
loc[0]='\0';
|
||||
strcpy(loc,ar_dFaultScores_sorted[eFaultSource].szLoc);
|
||||
eFaultSource = ar_dFaultScores_sorted[eFaultSource].eParrentFaultSource;
|
||||
|
||||
while(eFaultSource != _INVALID_FAULT_SOURCE_)
|
||||
{
|
||||
static char buff[1024];
|
||||
sprintf(buff,"%s->%s",ar_dFaultScores_sorted[eFaultSource].szLoc,loc);
|
||||
strcpy(loc,buff);
|
||||
eFaultSource = ar_dFaultScores_sorted[eFaultSource].eParrentFaultSource;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FaultSource_Display()
|
||||
{
|
||||
double dScoreSum = 0;
|
||||
|
||||
for(def_eFaultSource eFaultSourceCurrent=0;
|
||||
eFaultSourceCurrent < NB_FAULT_SOURCE && ar_dFaultScores_sorted[eFaultSourceCurrent].dScore > 0;
|
||||
eFaultSourceCurrent++ )
|
||||
dScoreSum+=ar_dFaultScores_sorted[eFaultSourceCurrent].dScore;
|
||||
|
||||
printf("------------------------------------------------\n");
|
||||
printf("\nDefects list:\n\n");
|
||||
printf("Score\tElement [Loc]\n");
|
||||
printf("------------------------------------------------\n");
|
||||
for(def_eFaultSource eFaultSourceCurrent=0;
|
||||
eFaultSourceCurrent < NB_FAULT_SOURCE
|
||||
&& (ar_dFaultScores_sorted[eFaultSourceCurrent].dScore > 0);
|
||||
eFaultSourceCurrent++ )
|
||||
{
|
||||
static char buff[1024];
|
||||
FaultSource_GetLoc(eFaultSourceCurrent,buff);
|
||||
printf("%02.3f\t%s [%s]\n",
|
||||
100*ar_dFaultScores_sorted[eFaultSourceCurrent].dScore/dScoreSum,
|
||||
ar_dFaultScores_sorted[eFaultSourceCurrent].szName,
|
||||
buff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WordBitFaultSet( const unsigned long ErrorMark,
|
||||
const double dScore,
|
||||
const def_eFaultSource eFaultSourceL,
|
||||
const def_eFaultSource eFaultSourceH)
|
||||
{
|
||||
/* loop unrolling optimization
|
||||
for(unsigned long bitPos = 0; bitPos <= 31 ; bitPos++)
|
||||
{
|
||||
if(ErrorMark & (1<<bitPos))
|
||||
{
|
||||
if(bitPos<16)
|
||||
FaultSource_AddScore(eFaultSourceL + bitPos, dScore);
|
||||
else
|
||||
FaultSource_AddScore(eFaultSourceH + bitPos - 16, dScore);
|
||||
}
|
||||
}*/
|
||||
if(ErrorMark & 0x00000001)
|
||||
FaultSource_AddScore(eFaultSourceL, dScore);
|
||||
if(ErrorMark & 0x00000002)
|
||||
FaultSource_AddScore(eFaultSourceL+1, dScore);
|
||||
if(ErrorMark & 0x00000004)
|
||||
FaultSource_AddScore(eFaultSourceL+2, dScore);
|
||||
if(ErrorMark & 0x00000008)
|
||||
FaultSource_AddScore(eFaultSourceL+3, dScore);
|
||||
if(ErrorMark & 0x00000010)
|
||||
FaultSource_AddScore(eFaultSourceL+4, dScore);
|
||||
if(ErrorMark & 0x00000020)
|
||||
FaultSource_AddScore(eFaultSourceL+5, dScore);
|
||||
if(ErrorMark & 0x00000040)
|
||||
FaultSource_AddScore(eFaultSourceL+6, dScore);
|
||||
if(ErrorMark & 0x00000080)
|
||||
FaultSource_AddScore(eFaultSourceL+7, dScore);
|
||||
if(ErrorMark & 0x00000100)
|
||||
FaultSource_AddScore(eFaultSourceL+8, dScore);
|
||||
if(ErrorMark & 0x00000200)
|
||||
FaultSource_AddScore(eFaultSourceL+9, dScore);
|
||||
if(ErrorMark & 0x00000400)
|
||||
FaultSource_AddScore(eFaultSourceL+10, dScore);
|
||||
if(ErrorMark & 0x00000800)
|
||||
FaultSource_AddScore(eFaultSourceL+11, dScore);
|
||||
if(ErrorMark & 0x00001000)
|
||||
FaultSource_AddScore(eFaultSourceL+12, dScore);
|
||||
if(ErrorMark & 0x00002000)
|
||||
FaultSource_AddScore(eFaultSourceL+13, dScore);
|
||||
if(ErrorMark & 0x00004000)
|
||||
FaultSource_AddScore(eFaultSourceL+14, dScore);
|
||||
if(ErrorMark & 0x00008000)
|
||||
FaultSource_AddScore(eFaultSourceL+15, dScore);
|
||||
if(ErrorMark & 0x00010000)
|
||||
FaultSource_AddScore(eFaultSourceH, dScore);
|
||||
if(ErrorMark & 0x00020000)
|
||||
FaultSource_AddScore(eFaultSourceH+1, dScore);
|
||||
if(ErrorMark & 0x00040000)
|
||||
FaultSource_AddScore(eFaultSourceH+2, dScore);
|
||||
if(ErrorMark & 0x00080000)
|
||||
FaultSource_AddScore(eFaultSourceH+3, dScore);
|
||||
if(ErrorMark & 0x00100000)
|
||||
FaultSource_AddScore(eFaultSourceH+4, dScore);
|
||||
if(ErrorMark & 0x00200000)
|
||||
FaultSource_AddScore(eFaultSourceH+5, dScore);
|
||||
if(ErrorMark & 0x00400000)
|
||||
FaultSource_AddScore(eFaultSourceH+6, dScore);
|
||||
if(ErrorMark & 0x00800000)
|
||||
FaultSource_AddScore(eFaultSourceH+7, dScore);
|
||||
if(ErrorMark & 0x01000000)
|
||||
FaultSource_AddScore(eFaultSourceH+8, dScore);
|
||||
if(ErrorMark & 0x02000000)
|
||||
FaultSource_AddScore(eFaultSourceH+9, dScore);
|
||||
if(ErrorMark & 0x04000000)
|
||||
FaultSource_AddScore(eFaultSourceH+10, dScore);
|
||||
if(ErrorMark & 0x08000000)
|
||||
FaultSource_AddScore(eFaultSourceH+11, dScore);
|
||||
if(ErrorMark & 0x10000000)
|
||||
FaultSource_AddScore(eFaultSourceH+12, dScore);
|
||||
if(ErrorMark & 0x20000000)
|
||||
FaultSource_AddScore(eFaultSourceH+13, dScore);
|
||||
if(ErrorMark & 0x40000000)
|
||||
FaultSource_AddScore(eFaultSourceH+14, dScore);
|
||||
if(ErrorMark & 0x80000000)
|
||||
FaultSource_AddScore(eFaultSourceH+15, dScore);
|
||||
}
|
||||
|
||||
void
|
||||
QuartetBitFaultSet( const unsigned long ErrorMark,
|
||||
const double dScore,
|
||||
const def_eFaultSource eFaultSource)
|
||||
{
|
||||
/* loop unrolling optimization
|
||||
for(unsigned long bitPos = 0; bitPos <= 4 ; bitPos++)
|
||||
{
|
||||
if(ErrorMark & (1<<bitPos))
|
||||
{
|
||||
FaultSource_AddScore(eFaultSource + bitPos, dScore);
|
||||
}
|
||||
}*/
|
||||
if(ErrorMark & 0x1)
|
||||
FaultSource_AddScore(eFaultSource, dScore);
|
||||
if(ErrorMark & 0x2)
|
||||
FaultSource_AddScore(eFaultSource+1, dScore);
|
||||
if(ErrorMark & 0x4)
|
||||
FaultSource_AddScore(eFaultSource+2, dScore);
|
||||
if(ErrorMark & 0x8)
|
||||
FaultSource_AddScore(eFaultSource+3, dScore);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
MemChipDQFaultSet( const unsigned long ErrorMark,
|
||||
const double dScore,
|
||||
const def_eFaultSource eFaultSourceL,
|
||||
const def_eFaultSource eFaultSourceH)
|
||||
{
|
||||
WordBitFaultSet(ErrorMark, dScore, eFaultSourceL + 1, eFaultSourceH + 1);
|
||||
}
|
||||
|
||||
inline void
|
||||
TMUTexDataFaultSet( const unsigned long ErrorMark_w0w1,
|
||||
const unsigned long ErrorMark_w2w3,
|
||||
const double dScore,
|
||||
const def_eFaultSource eTMUFaultSource)
|
||||
{
|
||||
WordBitFaultSet(ErrorMark_w0w1, dScore, eTMUFaultSource + 0 + 1, eTMUFaultSource + 16 + 1);
|
||||
WordBitFaultSet(ErrorMark_w2w3, dScore, eTMUFaultSource + 32 + 1, eTMUFaultSource + 48 + 1);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
TMUTexDataCtrlFaultSet( const unsigned long ErrorMark,
|
||||
double dScore,
|
||||
const def_eFaultSource eFaultSourceCASL,
|
||||
const def_eFaultSource eFaultSourceCASH,
|
||||
const def_eFaultSource eFaultSourceRAS,
|
||||
const def_eFaultSource eFaultSourceWE
|
||||
)
|
||||
{
|
||||
|
||||
if( ErrorMark && (count_bit32(ErrorMark) > 16) )
|
||||
{
|
||||
if(ErrorMark & 0x000000FF)
|
||||
FaultSource_AddScore(eFaultSourceCASL,dScore/2);
|
||||
if(ErrorMark & 0x0000FF00)
|
||||
FaultSource_AddScore(eFaultSourceCASH,dScore/2);
|
||||
if(ErrorMark & 0x00FF0000)
|
||||
FaultSource_AddScore(eFaultSourceCASL,dScore/2);
|
||||
if(ErrorMark & 0xFF000000)
|
||||
FaultSource_AddScore(eFaultSourceCASH,dScore/2);
|
||||
|
||||
FaultSource_AddScore(eFaultSourceRAS,dScore/4);
|
||||
FaultSource_AddScore(eFaultSourceWE,dScore/4);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user