diff --git a/FaultSources.c b/FaultSources.c index 1fc459a..ad82653 100644 --- a/FaultSources.c +++ b/FaultSources.c @@ -180,79 +180,4 @@ FaultSource_Display() ar_dFaultScores_sorted[eFaultSourceCurrent].szName, buff ); } -} - - -void -WordBitFaultSet( const unsigned long ErrorMark, - const double dScore, - const def_eFaultSource eFaultSourceL, - const def_eFaultSource eFaultSourceH) -{ - 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); - } - -} - -void -QuartetBitFaultSet( const unsigned long ErrorMark, - const double dScore, - const def_eFaultSource eFaultSource) -{ - for(unsigned char bitPos = 0; bitPos <= 4 ; bitPos++) - if(ErrorMark & (1 << bitPos)) - FaultSource_AddScore(eFaultSource + bitPos, 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); - if(ErrorMark & 0x0000FF00) - FaultSource_AddScore(eFaultSourceCASH,dScore); - if(ErrorMark & 0x00FF0000) - FaultSource_AddScore(eFaultSourceCASL,dScore); - if(ErrorMark & 0xFF000000) - FaultSource_AddScore(eFaultSourceCASH,dScore); - - FaultSource_AddScore(eFaultSourceRAS,dScore / 2); - FaultSource_AddScore(eFaultSourceWE,dScore / 2); - } -} - +} \ No newline at end of file diff --git a/FaultSources.h b/FaultSources.h index 73cc9cc..349e19b 100644 --- a/FaultSources.h +++ b/FaultSources.h @@ -997,47 +997,94 @@ typedef struct _def_sFaultSourceScoreRec{ }def_sFaultSourceScoreRec; extern def_sFaultSourceScoreRec ar_dFaultScores[NB_FAULT_SOURCE]; -extern def_sFaultSourceScoreRec ar_dFaultScores_sorted[NB_FAULT_SOURCE]; +extern def_sFaultSourceScoreRecar_dFaultScores_sorted[NB_FAULT_SOURCE]; -void FaultSource_Reset(); -void FaultSource_AddScore(def_eFaultSource eFaultSource, double dScore); -void FaultSource_Sort(); -void FaultSource_GetLoc(def_eFaultSource eFaultSource, char* loc); -void FaultSource_Display(); +void +FaultSource_Reset(); + +void +FaultSource_AddScore(def_eFaultSource eFaultSource, double dScore); + +void +FaultSource_Sort(); + +void +FaultSource_GetLoc(def_eFaultSource eFaultSource, char* loc); + +void +FaultSource_Display(); -void -WordBitFaultSet( const unsigned long ErrorMark, +static inline +WordBitFaultSet( const uint32_t ErrorMark, const double dScore, const def_eFaultSource eFaultSourceL, - const def_eFaultSource eFaultSourceH); - -void -QuartetBitFaultSet( const unsigned long ErrorMark, - const double dScore, - const def_eFaultSource eFaultSource); - + const def_eFaultSource eFaultSourceH) +{ + for(unsigned char bitPos = 0; bitPos <= 31 ; bitPos++) + if(ErrorMark & (1u << bitPos)) + { + if(bitPos < 16) + FaultSource_AddScore(eFaultSourceL + bitPos, dScore); + else + FaultSource_AddScore(eFaultSourceH + bitPos - 16, dScore); + } -inline void -MemChipDQFaultSet( const unsigned long ErrorMark, +} + +static inline void +QuartetBitFaultSet( const uint8_t ErrorMark, + const double dScore, + const def_eFaultSource eFaultSource) +{ + for(uint8_t bitPos = 0; bitPos <= 4 ; bitPos++) + if(ErrorMark & (1u << bitPos)) + FaultSource_AddScore(eFaultSource + bitPos, dScore); +} + +static inline void +MemChipDQFaultSet( const uint32_t ErrorMark, const double dScore, const def_eFaultSource eFaultSourceL, - const def_eFaultSource eFaultSourceH); + const def_eFaultSource eFaultSourceH) +{ + WordBitFaultSet(ErrorMark, dScore, eFaultSourceL + 1, eFaultSourceH + 1); +} -inline void -TMUTexDataFaultSet( const unsigned long ErrorMark_w0w1, - const unsigned long ErrorMark_w2w3, +static inline void +TMUTexDataFaultSet( const uint32_t ErrorMark_w0w1, + const uint32_t ErrorMark_w2w3, const double dScore, - const def_eFaultSource eTMUFaultSource); + 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, +static inline void +TMUTexDataCtrlFaultSet( const uint32_t ErrorMark, double dScore, const def_eFaultSource eFaultSourceCASL, const def_eFaultSource eFaultSourceCASH, const def_eFaultSource eFaultSourceRAS, const def_eFaultSource eFaultSourceWE - ); + ) +{ + if( count_bit32(ErrorMark) > 16 ) + { + if(ErrorMark & 0x000000FF) + FaultSource_AddScore(eFaultSourceCASL,dScore); + if(ErrorMark & 0x0000FF00) + FaultSource_AddScore(eFaultSourceCASH,dScore); + if(ErrorMark & 0x00FF0000) + FaultSource_AddScore(eFaultSourceCASL,dScore); + if(ErrorMark & 0xFF000000) + FaultSource_AddScore(eFaultSourceCASH,dScore); + + FaultSource_AddScore(eFaultSourceRAS,dScore / 2); + FaultSource_AddScore(eFaultSourceWE,dScore / 2); + } +} #endif //_DEF_FAULTSOURCES_H_ diff --git a/Test_Address.c b/Test_Address.c index 004d66a..7b8c57e 100644 --- a/Test_Address.c +++ b/Test_Address.c @@ -124,10 +124,10 @@ RenderTestAddress( sst1DeviceInfoStruct* devInfo, if(RamSizeMB<3 && add_list[idx].u32Addr >= 0x200000) continue; if(RamSizeMB<2 && add_list[idx].u32Addr >= 0x100000) continue; - const FxU32 TestVal1 = get_notnull_random_balanced_mByte(); - const FxU32 TestVal2 = get_notnull_random_balanced_mByte(); - const FxU32 TestValBlank1 = get_notnull_random_balanced_mByte(); - const FxU32 TestValBlank2 = get_notnull_random_balanced_mByte(); + const uint32_t TestVal1 = get_notnull_random_balanced_mByte(); + const uint32_t TestVal2 = get_notnull_random_balanced_mByte(); + const uint32_t TestValBlank1 = get_notnull_random_balanced_mByte(); + const uint32_t TestValBlank2 = get_notnull_random_balanced_mByte(); // Clearing memory targets for(unsigned char idxclr=0; @@ -170,20 +170,22 @@ RenderTestAddress( sst1DeviceInfoStruct* devInfo, // false positive if(idxdraw > idx) break; - /* set to mem addr */ + /* set to mem addr */ //TODO: 4x2 ISET(sstregs->texBaseAddr, (add_list[idxdraw].u32Addr >> 3)); - drawTriangle(sstregs, 0, 0, 4); /* draw a 4x4 triangle */ + /* draw a 4x4 triangle */ + drawSquare(sstregs, 0, 0, 4); + sst1InitIdle(sst); // First line, to use bits 00..31 - const FxU32 L1 = IGET(sst[(SST_LFB_ADDR>>2) + 0]); + const uint32_t L1 = IGET(sst[(SST_LFB_ADDR>>2) + 0]); // Second line,to use bits 32..63 - const FxU32 L2 = IGET(sst[(SST_LFB_ADDR>>2) + (2048>>2) + 0]); + const uint32_t L2 = IGET(sst[(SST_LFB_ADDR>>2) + (2048>>2) + 0]); - const unsigned long ErrorMark_L1 = (idxdraw == idx) ? (L1 ^ TestVal1) : (L1 ^ TestValBlank1); - const unsigned long ErrorMark_L2 = (idxdraw == idx) ? (L2 ^ TestVal2) : (L2 ^ TestValBlank2); + const uint32_t ErrorMark_L1 = (idxdraw == idx) ? (L1 ^ TestVal1) : (L1 ^ TestValBlank1); + const uint32_t ErrorMark_L2 = (idxdraw == idx) ? (L2 ^ TestVal2) : (L2 ^ TestValBlank2); - const unsigned long ErrorMarkBlank_L1 = (idxdraw == idx) ? (L1 ^ TestValBlank1) : (L1 ^ TestVal1); - const unsigned long ErrorMarkBlank_L2 = (idxdraw == idx) ? (L2 ^ TestValBlank2) : (L2 ^ TestVal2) ; + const uint32_t ErrorMarkBlank_L1 = (idxdraw == idx) ? (L1 ^ TestValBlank1) : (L1 ^ TestVal1); + const uint32_t ErrorMarkBlank_L2 = (idxdraw == idx) ? (L2 ^ TestValBlank2) : (L2 ^ TestVal2) ; if(ErrorMark_L1 || ErrorMark_L2) { diff --git a/Test_Data.c b/Test_Data.c index 09f64bc..e47393c 100644 --- a/Test_Data.c +++ b/Test_Data.c @@ -54,31 +54,32 @@ RenderTest( sst1DeviceInfoStruct* devInfo, ISET(texAddr[0], value2); ISET(texAddr[1], value2 + 1); ISET(texAddr[2], value2 + 2); ISET(texAddr[3], value2 + 3); - /* draw a 8x8triangle */ - drawTriangle(sstregs,0,0,8); + /* draw a 8x8 square */ //TODO: 4x2 + drawSquare(sstregs,0,0,8); + sst1InitIdle(sst); /* reading back first line pixels addresses */ - const FxU32 L1_1 = IGET(sst[(SST_LFB_ADDR >> 2) + 0]); - const FxU32 L1_2 = IGET(sst[(SST_LFB_ADDR >> 2) + 1]); - const FxU32 L1_3 = IGET(sst[(SST_LFB_ADDR >> 2) + 2]); - const FxU32 L1_4 = IGET(sst[(SST_LFB_ADDR >> 2) + 3]); + const uint32_t L1_1 = IGET(sst[(SST_LFB_ADDR >> 2) + 0]); + const uint32_t L1_2 = IGET(sst[(SST_LFB_ADDR >> 2) + 1]); + const uint32_t L1_3 = IGET(sst[(SST_LFB_ADDR >> 2) + 2]); + const uint32_t L1_4 = IGET(sst[(SST_LFB_ADDR >> 2) + 3]); /* reading back second line pixels addresses */ - const FxU32 L2_1 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 0]); - const FxU32 L2_2 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 1]); - const FxU32 L2_3 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 2]); - const FxU32 L2_4 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 3]); + const uint32_t L2_1 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 0]); + const uint32_t L2_2 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 1]); + const uint32_t L2_3 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 2]); + const uint32_t L2_4 = IGET(sst[(SST_LFB_ADDR >> 2) + (2048 >> 2) + 3]); unsigned long long NbErr = 0; - const unsigned long ErrorMark_L1_1 = L1_1 ^ ( value1 + 0 ); - const unsigned long ErrorMark_L1_2 = L1_2 ^ ( value1 + 1 ); - const unsigned long ErrorMark_L1_3 = L1_3 ^ ( value1 + 2 ); - const unsigned long ErrorMark_L1_4 = L1_4 ^ ( value1 + 3 ); - const unsigned long ErrorMark_L2_1 = L2_1 ^ ( value2 + 0 ); - const unsigned long ErrorMark_L2_2 = L2_2 ^ ( value2 + 1 ); - const unsigned long ErrorMark_L2_3 = L2_3 ^ ( value2 + 2 ); - const unsigned long ErrorMark_L2_4 = L2_4 ^ ( value2 + 3 ); + const uint32_t ErrorMark_L1_1 = L1_1 ^ ( value1 + 0 ); + const uint32_t ErrorMark_L1_2 = L1_2 ^ ( value1 + 1 ); + const uint32_t ErrorMark_L1_3 = L1_3 ^ ( value1 + 2 ); + const uint32_t ErrorMark_L1_4 = L1_4 ^ ( value1 + 3 ); + const uint32_t ErrorMark_L2_1 = L2_1 ^ ( value2 + 0 ); + const uint32_t ErrorMark_L2_2 = L2_2 ^ ( value2 + 1 ); + const uint32_t ErrorMark_L2_3 = L2_3 ^ ( value2 + 2 ); + const uint32_t ErrorMark_L2_4 = L2_4 ^ ( value2 + 3 ); if( ErrorMark_L1_1 || ErrorMark_L1_2 || ErrorMark_L1_3 || ErrorMark_L1_4 || ErrorMark_L2_1 || ErrorMark_L2_2 || ErrorMark_L2_3 || ErrorMark_L2_4) @@ -459,9 +460,9 @@ test_TMU_datalines( sst1DeviceInfoStruct* devInfo, const unsigned char RamSizeMB) { typedef struct _def_sMemBlock{ - unsigned long ulAddStart; - unsigned long ulAddEnd; - unsigned long ulAddLength; + uint32_t ulAddStart; + uint32_t ulAddEnd; + uint32_t ulAddLength; }def_sMemBlock; const def_sMemBlock ar_memBlocks[] = { @@ -491,9 +492,9 @@ test_TMU_datalines( sst1DeviceInfoStruct* devInfo, { const def_sMemBlock* pMemBlk = &ar_memBlocks[iMemBlock]; - if(RamSizeMB<4 && pMemBlk->ulAddStart >= 0x300000) continue; - if(RamSizeMB<3 && pMemBlk->ulAddStart >= 0x200000) continue; - if(RamSizeMB<2 && pMemBlk->ulAddStart >= 0x100000) continue; + if(RamSizeMB < 4 && pMemBlk->ulAddStart >= 0x300000) continue; + if(RamSizeMB < 3 && pMemBlk->ulAddStart >= 0x200000) continue; + if(RamSizeMB < 2 && pMemBlk->ulAddStart >= 0x100000) continue; /* printf("Testing memory block 0x%08x to 0x%08x ...\n", pMemBlk->ulAddStart, @@ -528,7 +529,7 @@ test_TMU_datalines( sst1DeviceInfoStruct* devInfo, //printf("Done @ 0x%08x\n",dataTest); - const FxU32 new_addrTest = pMemBlk->ulAddStart | (1 << ucAddMovingBit); + const FxU32 new_addrTest = pMemBlk->ulAddStart | (1u << ucAddMovingBit); if(new_addrTest == pMemBlk->ulAddStart) break; addrTest = new_addrTest; } diff --git a/Test_Data_Huge.c b/Test_Data_Huge.c index 233a4dd..da07f17 100644 --- a/Test_Data_Huge.c +++ b/Test_Data_Huge.c @@ -36,7 +36,45 @@ #define _NB_CHECK_LOOP 3 //#define _PROFILING + +#define _DEF_PREHEAT_TIME_S 10 +static void +HeatMemAndTMU( sst1DeviceInfoStruct* devInfo, + FxU32* sst, + SstRegs *sstregs, + const char ucNumTMU, + const FxU32 mem) +{ + ISET(sstregs->texBaseAddr, (mem>>3)); /* set to mem addr */ + + volatile FxU32 *texRowAddr + = (ucNumTMU<<(21-2)) + (((FxU32)0/*LOD0*/)<<(17-2)) + + (FxU32 *)SST_TEX_ADDRESS(sst); + + for(unsigned short iter_row = 0; iter_row < _DEF_NB_PIXEL_ROW; iter_row++) + { + for(unsigned short iter_col = 0; iter_col < _DEF_NB_PIXEL_COL; iter_col+=2) + { + ISET(texRowAddr[iter_col/2], get_notnull_random_balanced_mByte()); + } + texRowAddr += (1<<(9-2)); //jump to next line + } + + clock_t begin = clock(); + do + { + if(((sst1InitReturnStatus(sst) & SST_FIFOLEVEL)) >= 0x20) + { + /* draw a 252x256 square */ + drawSquare(sstregs, 0, 0, 256); + } + } + while(((double)(clock() - begin)/CLOCKS_PER_SEC) < _DEF_PREHEAT_TIME_S ); + + sst1InitIdle(sst); +} + static unsigned long long RenderTest( sst1DeviceInfoStruct* devInfo, FxU32* sst, @@ -50,18 +88,18 @@ RenderTest( sst1DeviceInfoStruct* devInfo, #endif ISET(sstregs->texBaseAddr, (mem>>3)); /* set to mem addr */ - static unsigned short + static uint16_t ar_u16Pixels[_DEF_NB_PIXEL_ROW][_DEF_NB_PIXEL_COL]; - static unsigned long + static uint32_t ar_u16PixelsRaw[_DEF_NB_PIXEL_ROW][_DEF_NB_PIXEL_COL/2]; - static unsigned short + static uint16_t ar_u16PixelsReRead[_DEF_NB_PIXEL_ROW][_DEF_NB_PIXEL_COL]; for(unsigned short iter_row = 0; iter_row < _DEF_NB_PIXEL_ROW; iter_row++) { for(unsigned short iter_col = 0; iter_col < _DEF_NB_PIXEL_COL; iter_col+=2) { - const unsigned long NewData = get_notnull_random_balanced_mByte(); + const uint32_t NewData = get_notnull_random_balanced_mByte(); ar_u16PixelsRaw[iter_row][iter_col/2] = NewData; ar_u16Pixels[iter_row][iter_col] = NewData >>16; ar_u16Pixels[iter_row][iter_col+1] = NewData & 0xFFFF; @@ -100,51 +138,20 @@ RenderTest( sst1DeviceInfoStruct* devInfo, #ifdef _PROFILING before_draw[i] = clock(); #endif - - drawTriangle(sstregs, 0, 0, 512); /* draw a 252x512 triangle */ + /* draw a 252x256 square */ + drawSquare(sstregs, 0, 0, 256); + sst1InitIdle(sst); #ifdef _PROFILING after_draw[i] = clock(); #endif - /* - printf("rdy.\n"); - GrLfbInfo_t info; - if(grLfbLock( GR_LFB_READ_ONLY, - GR_BUFFER_BACKBUFFER, - GR_LFBWRITEMODE_ANY, - GR_ORIGIN_UPPER_LEFT, - FXFALSE, - &info) - ) - { - printf("got LFB access.\n"); - FxU32 *rptr; - rptr = info.lfbPtr; - for(unsigned short iter_row = 0; iter_row < _DEF_NB_PIXEL_ROW; iter_row++) - { - for(unsigned short iter_col = 0; iter_col < _DEF_NB_PIXEL_COL; iter_col+=8) - { - ar_u16PixelsReRead[iter_row][iter_col] = *rptr >> 16; - ar_u16PixelsReRead[iter_row][iter_col+1] = *rptr & 0xFFFF; - rptr+=1; - } - rptr+=info.strideInBytes>>2; - } - grLfbUnlock(GR_LFB_READ_ONLY,GR_BUFFER_FRONTBUFFER); - } - else - { - printf("NOT LFB access.\n"); - } - */ volatile FxU32* pLFB = sst + (SST_LFB_ADDR>>2); for(unsigned short iter_row = 0; iter_row < _DEF_NB_PIXEL_ROW; iter_row++) { - //printf("reading row %d\n",iter_row); for(unsigned short iter_col = 0; iter_col < _DEF_NB_PIXEL_COL; iter_col+=2) { - const FxU32 u32Data = *pLFB++; + const uint32_t u32Data = *pLFB++; ar_u16PixelsReRead[iter_row][iter_col] = u32Data >> 16; ar_u16PixelsReRead[iter_row][iter_col+1] = u32Data & 0xFFFF; @@ -208,9 +215,9 @@ test_TMU_datalines_Huge( sst1DeviceInfoStruct* devInfo, const unsigned char RamSizeMB) { typedef struct _def_sMemBlock{ - unsigned long ulAddStart; - unsigned long ulAddEnd; - unsigned long ulAddLength; + uint32_t ulAddStart; + uint32_t ulAddEnd; + uint32_t ulAddLength; }def_sMemBlock; const def_sMemBlock ar_memBlocks[] = { diff --git a/Utils.c b/Utils.c index a31fe12..a59b8ec 100644 --- a/Utils.c +++ b/Utils.c @@ -21,46 +21,26 @@ #include "Utils.h" -inline void -printbin32( const unsigned long ulVal, +void +printbin32( const uint32_t ulVal, const unsigned char bGroupByBytes) { - for(unsigned long idxBit = 1<<31;idxBit>0;idxBit>>=1) + for(uint32_t idxBit = 1u<<31 ; idxBit > 0 ; idxBit >>= 1) { if(bGroupByBytes) switch(idxBit) { - case 1<<23: - case 1<<15: - case 1<<7: + case 1u << 23: + case 1u << 15: + case 1u << 7: putchar(' '); } putchar(ulVal & idxBit ? '1' : '0'); } } -inline unsigned char -count_bit32(const unsigned long ulVal) -{ - unsigned char cpt = 0; - for(unsigned long idxBit = 1<<31;idxBit>0;idxBit>>=1) - if(ulVal & idxBit) - cpt++; - return cpt; -} - -inline unsigned char -count_bit8(const unsigned char ulVal) -{ - unsigned char cpt = 0; - for(unsigned char idxBit = 1<<7;idxBit>0;idxBit>>=1) - if(ulVal & idxBit) - cpt++; - return cpt; -} - -inline void -printbin32Info( const unsigned long ulVal, +void +printbin32Info( const uint32_t ulVal, const unsigned short uhb, const unsigned short ulb) { @@ -68,48 +48,48 @@ printbin32Info( const unsigned long ulVal, putchar('\n'); printf("%02d....%02d %02d....%02d %02d....%02d %02d....%02d\n", uhb, - 3*(uhb+ulb+1)/4, 3*((uhb+ulb+1)/4)-1, - (uhb+ulb+1)/2, ((uhb+ulb+1)/2)-1, - (uhb+ulb+1)/4, ((uhb+ulb+1)/4)-1, + 3 * (uhb+ulb+1) / 4, 3 * ( (uhb+ulb+1) / 4) - 1, + (uhb+ulb+1) / 2, ( (uhb+ulb+1) / 2) - 1, + (uhb+ulb+1) / 4, ( (uhb+ulb+1) / 4) - 1, ulb); } -unsigned long get_notnull_random() +uint32_t get_notnull_random() { - unsigned long val; + uint32_t val; do - val = random()<<1 ^ random(); + val = (random() << 1) ^ random(); while(!val); return val; } -unsigned long get_notnull_random_balanced() +uint32_t get_notnull_random_balanced() { - unsigned long val; + uint32_t val; do - val = random()<<1 ^ random(); + val = (random() << 1) ^ random(); while(count_bit32(val) != 16); return val; } -unsigned char get_notnull8_random_balanced() +uint8_t get_notnull8_random_balanced() { - unsigned char val; - static unsigned char prev = 0; + uint8_t val; + static uint8_t prev = 0; do - val = random()<<1 ^ random(); + val = (random() << 1) ^ random(); while((count_bit8(val) != 4) || (val == prev)); prev = val; return val; } -unsigned long get_notnull_random_balanced_mByte() +uint32_t get_notnull_random_balanced_mByte() { - unsigned long val; - static unsigned long prev = 0; + uint32_t val; + static uint32_t prev = 0; do - val = (get_notnull8_random_balanced() << 24) + val = (get_notnull8_random_balanced() << 24) | (get_notnull8_random_balanced() << 16) | (get_notnull8_random_balanced() << 8) | (get_notnull8_random_balanced() << 0); diff --git a/Utils.h b/Utils.h index 28f8817..8331598 100644 --- a/Utils.h +++ b/Utils.h @@ -18,13 +18,47 @@ #ifndef _DEF_UTILS_H_ #define _DEF_UTILS_H_ -inline void printbin32(const unsigned long ulVal,const unsigned char bGroupByBytes); -inline unsigned char count_bit32(const unsigned long ulVal); -inline unsigned char count_bit8(const unsigned char ulVal); -inline void printbin32Info(const unsigned long ulVal, const unsigned short uhb, const unsigned short ulb); -unsigned long get_notnull_random(); -unsigned long get_notnull_random_balanced(); -unsigned char get_notnull8_random_balanced(); -unsigned long get_notnull_random_balanced_mByte(); +#include + +static inline unsigned char +count_bit32(const uint32_t ulVal) +{ + unsigned char cpt = 0; + for(uint32_t idxBit = 1<<31;idxBit>0;idxBit>>=1) + if(ulVal & idxBit) + cpt++; + return cpt; +} + +static inline unsigned char +count_bit8(const uint8_t ulVal) +{ + unsigned char cpt = 0; + for(uint8_t idxBit = 1<<7;idxBit>0;idxBit>>=1) + if(ulVal & idxBit) + cpt++; + return cpt; +} + +void +printbin32( const uint32_t ulVal, + const unsigned char bGroupByBytes); + +void +printbin32Info( const uint32_t ulVal, + const unsigned short uhb, + const unsigned short ulb); + +uint32_t +get_notnull_random(); + +uint32_t +get_notnull_random_balanced(); + +uint8_t +get_notnull8_random_balanced(); + +uint32_t +get_notnull_random_balanced_mByte(); #endif //_DEF_UTILS_H_ diff --git a/V2MemTest.h b/V2MemTest.h index 63f9a50..91b2810 100644 --- a/V2MemTest.h +++ b/V2MemTest.h @@ -36,7 +36,6 @@ typedef enum _def_eLogLevel { typedef struct _def_sOptions { - def_eLogLevel ucLogLevel; unsigned char bLogStdOut; char szLogFileName[2048]; char szTSVFile[2048]; diff --git a/main.c b/main.c index 97728b2..2ac91f9 100644 --- a/main.c +++ b/main.c @@ -76,7 +76,7 @@ def_sOptions sOptions = { int main(int argc, char **argv) { unsigned long long ullNbErrorAll = 0; - const FxU32 boardNum = 0; + const unsigned char boardNum = 0; sst1DeviceInfoStruct devInfo; FxU32* sst;