@@ -91,6 +91,8 @@ int32 HS_CustomInit(void)
91
91
{
92
92
int32 Status ;
93
93
94
+ memset (& HS_CustomData , 0 , sizeof (HS_CustomData ));
95
+
94
96
/*
95
97
** Spawn the Idle Task
96
98
*/
@@ -118,16 +120,13 @@ int32 HS_CustomInit(void)
118
120
(unsigned int )Status );
119
121
}
120
122
121
- HS_CustomData .UtilMult1 = HS_UTIL_CONV_MULT1 ;
122
- HS_CustomData .UtilMult2 = HS_UTIL_CONV_MULT2 ;
123
- HS_CustomData .UtilDiv = HS_UTIL_CONV_DIV ;
124
- HS_CustomData .UtilMask = HS_UTIL_DIAG_MASK ;
125
- HS_CustomData .UtilCycleCounter = 0 ;
126
- HS_CustomData .UtilArrayIndex = 0 ;
127
- HS_CustomData .UtilArrayMask = HS_UTIL_TIME_DIAG_ARRAY_MASK ;
128
- HS_CustomData .ThisIdleTaskExec = 0 ;
129
- HS_CustomData .LastIdleTaskExec = 0 ;
130
- HS_CustomData .LastIdleTaskInterval = 0 ;
123
+ /* Non-zero initialization */
124
+ HS_CustomData .UtilMult1 = HS_UTIL_CONV_MULT1 ;
125
+ HS_CustomData .UtilMult2 = HS_UTIL_CONV_MULT2 ;
126
+ HS_CustomData .UtilDiv = HS_UTIL_CONV_DIV ;
127
+ HS_CustomData .UtilMask = HS_UTIL_DIAG_MASK ;
128
+ HS_CustomData .UtilArrayMask = HS_UTIL_TIME_DIAG_ARRAY_MASK ;
129
+ HS_CustomData .UtilCallsPerMark = HS_UTIL_CALLS_PER_MARK ;
131
130
132
131
return (Status );
133
132
@@ -183,7 +182,7 @@ void HS_UtilizationMark(void)
183
182
184
183
CycleCount ++ ;
185
184
186
- if (CycleCount >= HS_UTIL_CALLS_PER_MARK )
185
+ if (CycleCount >= HS_CustomData . UtilCallsPerMark )
187
186
{
188
187
HS_CustomData .LastIdleTaskInterval = HS_CustomData .ThisIdleTaskExec - HS_CustomData .LastIdleTaskExec ;
189
188
HS_CustomData .LastIdleTaskExec = HS_CustomData .ThisIdleTaskExec ;
@@ -278,10 +277,9 @@ void HS_UtilDiagReport(void)
278
277
{
279
278
uint32 DiagValue [HS_UTIL_TIME_DIAG_ARRAY_LENGTH ];
280
279
uint32 DiagCount [HS_UTIL_TIME_DIAG_ARRAY_LENGTH ];
281
- uint32 i = 0 ;
282
- uint32 j = 0 ;
283
- uint32 ThisValue = 0 ;
284
- bool MatchFound = false;
280
+ uint32 i = 0 ;
281
+ uint32 j = 0 ;
282
+ uint32 ThisValue = 0 ;
285
283
286
284
uint32 Ordinal = 0 ;
287
285
uint32 NewOrdinalIndex = 0 ;
@@ -314,24 +312,19 @@ void HS_UtilDiagReport(void)
314
312
ThisValue = HS_CustomData .UtilArray [i ] - HS_CustomData .UtilArray [i - 1 ];
315
313
}
316
314
317
- j = 0 ;
318
- MatchFound = false;
319
- while ((MatchFound == false) && (j < HS_UTIL_TIME_DIAG_ARRAY_LENGTH ))
315
+ for (j = 0 ; j < HS_UTIL_TIME_DIAG_ARRAY_LENGTH ; j ++ )
320
316
{
321
- if (ThisValue == DiagValue [j ])
322
- {
323
- DiagCount [j ]++ ;
324
- MatchFound = true;
325
- }
326
- else if (DiagValue [j ] == 0xFFFFFFFF )
317
+ if (DiagValue [j ] == 0xFFFFFFFF )
327
318
{
319
+ /* Acquire a slot if empty */
328
320
DiagValue [j ] = ThisValue ;
329
- DiagCount [j ]++ ;
330
- MatchFound = true;
331
321
}
332
- else
322
+
323
+ if (ThisValue == DiagValue [j ])
333
324
{
334
- j ++ ;
325
+ /* Increment count and cause loop to exit on match */
326
+ DiagCount [j ]++ ;
327
+ j = HS_UTIL_TIME_DIAG_ARRAY_LENGTH ;
335
328
}
336
329
}
337
330
}
0 commit comments