Ensure emulated flop is not used.

This commit is contained in:
Richard Barry 2008-05-20 05:20:25 +00:00
parent dd1ef6a777
commit bea704342a
2 changed files with 48 additions and 47 deletions

View file

@ -109,7 +109,7 @@ static void vFlopTest2( void *pvParameters );
/* Buffers into which the flop registers will be saved. There is a buffer for
both tasks. */
static unsigned portLONG ulFlopRegisters[ flopNUMBER_OF_TASKS ][ portNO_FLOP_REGISTERS_TO_SAVE ] = { 0 };
static volatile unsigned portLONG ulFlopRegisters[ flopNUMBER_OF_TASKS ][ portNO_FLOP_REGISTERS_TO_SAVE ] = { 0 };
/* Variables that are incremented by the tasks to indicate that they are still
running. */
@ -163,7 +163,7 @@ static void vFlopTest1( void *pvParameters )
back the next time the task runs. Being preempted during this memset
could cause the test to fail, hence the critical section. */
portENTER_CRITICAL();
memset( ulFlopRegisters[ 0 ], 0x00, ( portNO_FLOP_REGISTERS_TO_SAVE * sizeof( unsigned portBASE_TYPE ) ) );
memset( ( void * ) ulFlopRegisters[ 0 ], 0x00, ( portNO_FLOP_REGISTERS_TO_SAVE * sizeof( unsigned portBASE_TYPE ) ) );
portEXIT_CRITICAL();
/* We don't have to do anything other than indicate that we are
@ -182,7 +182,7 @@ static void vFlopTest2( void *pvParameters )
registers. Clear the buffer to ensure the same values then get written
back the next time the task runs. */
portENTER_CRITICAL();
memset( ulFlopRegisters[ 1 ], 0x00, ( portNO_FLOP_REGISTERS_TO_SAVE * sizeof( unsigned portBASE_TYPE ) ) );
memset( ( void * ) ulFlopRegisters[ 1 ], 0x00, ( portNO_FLOP_REGISTERS_TO_SAVE * sizeof( unsigned portBASE_TYPE ) ) );
portEXIT_CRITICAL();
/* We don't have to do anything other than indicate that we are
@ -197,6 +197,7 @@ portBASE_TYPE xAreFlopRegisterTestsStillRunning( void )
{
portBASE_TYPE xReturn = pdPASS;
unsigned portBASE_TYPE x, y, z = flopSTART_VALUE;
static unsigned portLONG ulLastFlop1CycleCount = 0, ulLastFlop2CycleCount = 0;
/* Called from the 'check' task.
@ -219,17 +220,17 @@ unsigned portBASE_TYPE x, y, z = flopSTART_VALUE;
/* Check both tasks have actually been swapped in and out since this function
last executed. */
if( ulFlop1CycleCount == 0 )
if( ulFlop1CycleCount == ulLastFlop1CycleCount )
{
xReturn = pdFAIL;
}
if( ulFlop2CycleCount == 0 )
if( ulFlop2CycleCount == ulLastFlop2CycleCount )
{
xReturn = pdFAIL;
}
ulFlop1CycleCount = 0;
ulFlop2CycleCount = 0;
ulLastFlop1CycleCount = ulFlop1CycleCount;
ulLastFlop2CycleCount = ulFlop2CycleCount;
}

View file

@ -155,16 +155,16 @@ portBASE_TYPE x, y;
static portTASK_FUNCTION( vCompetingMathTask1, pvParameters )
{
volatile portFLOAT d1, d2, d3, d4;
volatile portFLOAT ff1, ff2, ff3, ff4;
volatile unsigned portSHORT *pusTaskCheckVariable;
volatile portFLOAT dAnswer;
volatile portFLOAT fAnswer;
portSHORT sError = pdFALSE;
d1 = 123.4567;
d2 = 2345.6789;
d3 = -918.222;
ff1 = 123.4567F;
ff2 = 2345.6789F;
ff3 = -918.222F;
dAnswer = ( d1 + d2 ) * d3;
fAnswer = ( ff1 + ff2 ) * ff3;
/* The variable this task increments to show it is still running is passed in
as the parameter. */
@ -173,11 +173,11 @@ portSHORT sError = pdFALSE;
/* Keep performing a calculation and checking the result against a constant. */
for(;;)
{
d1 = 123.4567;
d2 = 2345.6789;
d3 = -918.222;
ff1 = 123.4567F;
ff2 = 2345.6789F;
ff3 = -918.222F;
d4 = ( d1 + d2 ) * d3;
ff4 = ( ff1 + ff2 ) * ff3;
#if configUSE_PREEMPTION == 0
taskYIELD();
@ -185,7 +185,7 @@ portSHORT sError = pdFALSE;
/* If the calculation does not match the expected constant, stop the
increment of the check variable. */
if( fabs( d4 - dAnswer ) > 0.001 )
if( fabs( ff4 - fAnswer ) > 0.001F )
{
sError = pdTRUE;
}
@ -207,16 +207,16 @@ portSHORT sError = pdFALSE;
static portTASK_FUNCTION( vCompetingMathTask2, pvParameters )
{
volatile portFLOAT d1, d2, d3, d4;
volatile portFLOAT ff1, ff2, ff3, ff4;
volatile unsigned portSHORT *pusTaskCheckVariable;
volatile portFLOAT dAnswer;
volatile portFLOAT fAnswer;
portSHORT sError = pdFALSE;
d1 = -389.38;
d2 = 32498.2;
d3 = -2.0001;
ff1 = -389.38F;
ff2 = 32498.2F;
ff3 = -2.0001F;
dAnswer = ( d1 / d2 ) * d3;
fAnswer = ( ff1 / ff2 ) * ff3;
/* The variable this task increments to show it is still running is passed in
@ -226,11 +226,11 @@ portSHORT sError = pdFALSE;
/* Keep performing a calculation and checking the result against a constant. */
for( ;; )
{
d1 = -389.38;
d2 = 32498.2;
d3 = -2.0001;
ff1 = -389.38F;
ff2 = 32498.2F;
ff3 = -2.0001F;
d4 = ( d1 / d2 ) * d3;
ff4 = ( ff1 / ff2 ) * ff3;
#if configUSE_PREEMPTION == 0
taskYIELD();
@ -238,7 +238,7 @@ portSHORT sError = pdFALSE;
/* If the calculation does not match the expected constant, stop the
increment of the check variable. */
if( fabs( d4 - dAnswer ) > 0.001 )
if( fabs( ff4 - fAnswer ) > 0.001F )
{
sError = pdTRUE;
}
@ -260,7 +260,7 @@ portSHORT sError = pdFALSE;
static portTASK_FUNCTION( vCompetingMathTask3, pvParameters )
{
volatile portFLOAT *pdArray, dTotal1, dTotal2, dDifference;
volatile portFLOAT *pfArray, fTotal1, fTotal2, fDifference;
volatile unsigned portSHORT *pusTaskCheckVariable;
const size_t xArraySize = 10;
size_t xPosition;
@ -270,20 +270,20 @@ portSHORT sError = pdFALSE;
as the parameter. */
pusTaskCheckVariable = ( unsigned portSHORT * ) pvParameters;
pdArray = ( portFLOAT * ) pvPortMalloc( xArraySize * sizeof( portFLOAT ) );
pfArray = ( portFLOAT * ) pvPortMalloc( xArraySize * sizeof( portFLOAT ) );
/* Keep filling an array, keeping a running total of the values placed in the
array. Then run through the array adding up all the values. If the two totals
do not match, stop the check variable from incrementing. */
for( ;; )
{
dTotal1 = 0.0;
dTotal2 = 0.0;
fTotal1 = 0.0F;
fTotal2 = 0.0F;
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
{
pdArray[ xPosition ] = ( portFLOAT ) xPosition + 5.5;
dTotal1 += ( portFLOAT ) xPosition + 5.5;
pfArray[ xPosition ] = ( portFLOAT ) xPosition + 5.5F;
fTotal1 += ( portFLOAT ) xPosition + 5.5F;
}
#if configUSE_PREEMPTION == 0
@ -292,11 +292,11 @@ portSHORT sError = pdFALSE;
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
{
dTotal2 += pdArray[ xPosition ];
fTotal2 += pfArray[ xPosition ];
}
dDifference = dTotal1 - dTotal2;
if( fabs( dDifference ) > 0.001 )
fDifference = fTotal1 - fTotal2;
if( fabs( fDifference ) > 0.001F )
{
sError = pdTRUE;
}
@ -317,7 +317,7 @@ portSHORT sError = pdFALSE;
static portTASK_FUNCTION( vCompetingMathTask4, pvParameters )
{
volatile portFLOAT *pdArray, dTotal1, dTotal2, dDifference;
volatile portFLOAT *pfArray, fTotal1, fTotal2, fDifference;
volatile unsigned portSHORT *pusTaskCheckVariable;
const size_t xArraySize = 10;
size_t xPosition;
@ -327,20 +327,20 @@ portSHORT sError = pdFALSE;
as the parameter. */
pusTaskCheckVariable = ( unsigned portSHORT * ) pvParameters;
pdArray = ( portFLOAT * ) pvPortMalloc( xArraySize * sizeof( portFLOAT ) );
pfArray = ( portFLOAT * ) pvPortMalloc( xArraySize * sizeof( portFLOAT ) );
/* Keep filling an array, keeping a running total of the values placed in the
array. Then run through the array adding up all the values. If the two totals
do not match, stop the check variable from incrementing. */
for( ;; )
{
dTotal1 = 0.0;
dTotal2 = 0.0;
fTotal1 = 0.0F;
fTotal2 = 0.0F;
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
{
pdArray[ xPosition ] = ( portFLOAT ) xPosition * 12.123;
dTotal1 += ( portFLOAT ) xPosition * 12.123;
pfArray[ xPosition ] = ( portFLOAT ) xPosition * 12.123F;
fTotal1 += ( portFLOAT ) xPosition * 12.123F;
}
#if configUSE_PREEMPTION == 0
@ -349,11 +349,11 @@ portSHORT sError = pdFALSE;
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
{
dTotal2 += pdArray[ xPosition ];
fTotal2 += pfArray[ xPosition ];
}
dDifference = dTotal1 - dTotal2;
if( fabs( dDifference ) > 0.001 )
fDifference = fTotal1 - fTotal2;
if( fabs( fDifference ) > 0.001F )
{
sError = pdTRUE;
}