mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Ensure emulated flop is not used.
This commit is contained in:
parent
dd1ef6a777
commit
bea704342a
|
@ -109,7 +109,7 @@ static void vFlopTest2( void *pvParameters );
|
||||||
|
|
||||||
/* Buffers into which the flop registers will be saved. There is a buffer for
|
/* Buffers into which the flop registers will be saved. There is a buffer for
|
||||||
both tasks. */
|
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
|
/* Variables that are incremented by the tasks to indicate that they are still
|
||||||
running. */
|
running. */
|
||||||
|
@ -163,7 +163,7 @@ static void vFlopTest1( void *pvParameters )
|
||||||
back the next time the task runs. Being preempted during this memset
|
back the next time the task runs. Being preempted during this memset
|
||||||
could cause the test to fail, hence the critical section. */
|
could cause the test to fail, hence the critical section. */
|
||||||
portENTER_CRITICAL();
|
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();
|
portEXIT_CRITICAL();
|
||||||
|
|
||||||
/* We don't have to do anything other than indicate that we are
|
/* 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
|
registers. Clear the buffer to ensure the same values then get written
|
||||||
back the next time the task runs. */
|
back the next time the task runs. */
|
||||||
portENTER_CRITICAL();
|
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();
|
portEXIT_CRITICAL();
|
||||||
|
|
||||||
/* We don't have to do anything other than indicate that we are
|
/* 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;
|
portBASE_TYPE xReturn = pdPASS;
|
||||||
unsigned portBASE_TYPE x, y, z = flopSTART_VALUE;
|
unsigned portBASE_TYPE x, y, z = flopSTART_VALUE;
|
||||||
|
static unsigned portLONG ulLastFlop1CycleCount = 0, ulLastFlop2CycleCount = 0;
|
||||||
|
|
||||||
/* Called from the 'check' task.
|
/* 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
|
/* Check both tasks have actually been swapped in and out since this function
|
||||||
last executed. */
|
last executed. */
|
||||||
if( ulFlop1CycleCount == 0 )
|
if( ulFlop1CycleCount == ulLastFlop1CycleCount )
|
||||||
{
|
{
|
||||||
xReturn = pdFAIL;
|
xReturn = pdFAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ulFlop2CycleCount == 0 )
|
if( ulFlop2CycleCount == ulLastFlop2CycleCount )
|
||||||
{
|
{
|
||||||
xReturn = pdFAIL;
|
xReturn = pdFAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulFlop1CycleCount = 0;
|
ulLastFlop1CycleCount = ulFlop1CycleCount;
|
||||||
ulFlop2CycleCount = 0;
|
ulLastFlop2CycleCount = ulFlop2CycleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,16 +155,16 @@ portBASE_TYPE x, y;
|
||||||
|
|
||||||
static portTASK_FUNCTION( vCompetingMathTask1, pvParameters )
|
static portTASK_FUNCTION( vCompetingMathTask1, pvParameters )
|
||||||
{
|
{
|
||||||
volatile portFLOAT d1, d2, d3, d4;
|
volatile portFLOAT ff1, ff2, ff3, ff4;
|
||||||
volatile unsigned portSHORT *pusTaskCheckVariable;
|
volatile unsigned portSHORT *pusTaskCheckVariable;
|
||||||
volatile portFLOAT dAnswer;
|
volatile portFLOAT fAnswer;
|
||||||
portSHORT sError = pdFALSE;
|
portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
d1 = 123.4567;
|
ff1 = 123.4567F;
|
||||||
d2 = 2345.6789;
|
ff2 = 2345.6789F;
|
||||||
d3 = -918.222;
|
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
|
/* The variable this task increments to show it is still running is passed in
|
||||||
as the parameter. */
|
as the parameter. */
|
||||||
|
@ -173,11 +173,11 @@ portSHORT sError = pdFALSE;
|
||||||
/* Keep performing a calculation and checking the result against a constant. */
|
/* Keep performing a calculation and checking the result against a constant. */
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
d1 = 123.4567;
|
ff1 = 123.4567F;
|
||||||
d2 = 2345.6789;
|
ff2 = 2345.6789F;
|
||||||
d3 = -918.222;
|
ff3 = -918.222F;
|
||||||
|
|
||||||
d4 = ( d1 + d2 ) * d3;
|
ff4 = ( ff1 + ff2 ) * ff3;
|
||||||
|
|
||||||
#if configUSE_PREEMPTION == 0
|
#if configUSE_PREEMPTION == 0
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
|
@ -185,7 +185,7 @@ portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
/* If the calculation does not match the expected constant, stop the
|
/* If the calculation does not match the expected constant, stop the
|
||||||
increment of the check variable. */
|
increment of the check variable. */
|
||||||
if( fabs( d4 - dAnswer ) > 0.001 )
|
if( fabs( ff4 - fAnswer ) > 0.001F )
|
||||||
{
|
{
|
||||||
sError = pdTRUE;
|
sError = pdTRUE;
|
||||||
}
|
}
|
||||||
|
@ -207,16 +207,16 @@ portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
static portTASK_FUNCTION( vCompetingMathTask2, pvParameters )
|
static portTASK_FUNCTION( vCompetingMathTask2, pvParameters )
|
||||||
{
|
{
|
||||||
volatile portFLOAT d1, d2, d3, d4;
|
volatile portFLOAT ff1, ff2, ff3, ff4;
|
||||||
volatile unsigned portSHORT *pusTaskCheckVariable;
|
volatile unsigned portSHORT *pusTaskCheckVariable;
|
||||||
volatile portFLOAT dAnswer;
|
volatile portFLOAT fAnswer;
|
||||||
portSHORT sError = pdFALSE;
|
portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
d1 = -389.38;
|
ff1 = -389.38F;
|
||||||
d2 = 32498.2;
|
ff2 = 32498.2F;
|
||||||
d3 = -2.0001;
|
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
|
/* 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. */
|
/* Keep performing a calculation and checking the result against a constant. */
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
d1 = -389.38;
|
ff1 = -389.38F;
|
||||||
d2 = 32498.2;
|
ff2 = 32498.2F;
|
||||||
d3 = -2.0001;
|
ff3 = -2.0001F;
|
||||||
|
|
||||||
d4 = ( d1 / d2 ) * d3;
|
ff4 = ( ff1 / ff2 ) * ff3;
|
||||||
|
|
||||||
#if configUSE_PREEMPTION == 0
|
#if configUSE_PREEMPTION == 0
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
|
@ -238,7 +238,7 @@ portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
/* If the calculation does not match the expected constant, stop the
|
/* If the calculation does not match the expected constant, stop the
|
||||||
increment of the check variable. */
|
increment of the check variable. */
|
||||||
if( fabs( d4 - dAnswer ) > 0.001 )
|
if( fabs( ff4 - fAnswer ) > 0.001F )
|
||||||
{
|
{
|
||||||
sError = pdTRUE;
|
sError = pdTRUE;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
static portTASK_FUNCTION( vCompetingMathTask3, pvParameters )
|
static portTASK_FUNCTION( vCompetingMathTask3, pvParameters )
|
||||||
{
|
{
|
||||||
volatile portFLOAT *pdArray, dTotal1, dTotal2, dDifference;
|
volatile portFLOAT *pfArray, fTotal1, fTotal2, fDifference;
|
||||||
volatile unsigned portSHORT *pusTaskCheckVariable;
|
volatile unsigned portSHORT *pusTaskCheckVariable;
|
||||||
const size_t xArraySize = 10;
|
const size_t xArraySize = 10;
|
||||||
size_t xPosition;
|
size_t xPosition;
|
||||||
|
@ -270,20 +270,20 @@ portSHORT sError = pdFALSE;
|
||||||
as the parameter. */
|
as the parameter. */
|
||||||
pusTaskCheckVariable = ( unsigned portSHORT * ) pvParameters;
|
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
|
/* 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
|
array. Then run through the array adding up all the values. If the two totals
|
||||||
do not match, stop the check variable from incrementing. */
|
do not match, stop the check variable from incrementing. */
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
dTotal1 = 0.0;
|
fTotal1 = 0.0F;
|
||||||
dTotal2 = 0.0;
|
fTotal2 = 0.0F;
|
||||||
|
|
||||||
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
||||||
{
|
{
|
||||||
pdArray[ xPosition ] = ( portFLOAT ) xPosition + 5.5;
|
pfArray[ xPosition ] = ( portFLOAT ) xPosition + 5.5F;
|
||||||
dTotal1 += ( portFLOAT ) xPosition + 5.5;
|
fTotal1 += ( portFLOAT ) xPosition + 5.5F;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if configUSE_PREEMPTION == 0
|
#if configUSE_PREEMPTION == 0
|
||||||
|
@ -292,11 +292,11 @@ portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
||||||
{
|
{
|
||||||
dTotal2 += pdArray[ xPosition ];
|
fTotal2 += pfArray[ xPosition ];
|
||||||
}
|
}
|
||||||
|
|
||||||
dDifference = dTotal1 - dTotal2;
|
fDifference = fTotal1 - fTotal2;
|
||||||
if( fabs( dDifference ) > 0.001 )
|
if( fabs( fDifference ) > 0.001F )
|
||||||
{
|
{
|
||||||
sError = pdTRUE;
|
sError = pdTRUE;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
static portTASK_FUNCTION( vCompetingMathTask4, pvParameters )
|
static portTASK_FUNCTION( vCompetingMathTask4, pvParameters )
|
||||||
{
|
{
|
||||||
volatile portFLOAT *pdArray, dTotal1, dTotal2, dDifference;
|
volatile portFLOAT *pfArray, fTotal1, fTotal2, fDifference;
|
||||||
volatile unsigned portSHORT *pusTaskCheckVariable;
|
volatile unsigned portSHORT *pusTaskCheckVariable;
|
||||||
const size_t xArraySize = 10;
|
const size_t xArraySize = 10;
|
||||||
size_t xPosition;
|
size_t xPosition;
|
||||||
|
@ -327,20 +327,20 @@ portSHORT sError = pdFALSE;
|
||||||
as the parameter. */
|
as the parameter. */
|
||||||
pusTaskCheckVariable = ( unsigned portSHORT * ) pvParameters;
|
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
|
/* 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
|
array. Then run through the array adding up all the values. If the two totals
|
||||||
do not match, stop the check variable from incrementing. */
|
do not match, stop the check variable from incrementing. */
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
dTotal1 = 0.0;
|
fTotal1 = 0.0F;
|
||||||
dTotal2 = 0.0;
|
fTotal2 = 0.0F;
|
||||||
|
|
||||||
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
||||||
{
|
{
|
||||||
pdArray[ xPosition ] = ( portFLOAT ) xPosition * 12.123;
|
pfArray[ xPosition ] = ( portFLOAT ) xPosition * 12.123F;
|
||||||
dTotal1 += ( portFLOAT ) xPosition * 12.123;
|
fTotal1 += ( portFLOAT ) xPosition * 12.123F;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if configUSE_PREEMPTION == 0
|
#if configUSE_PREEMPTION == 0
|
||||||
|
@ -349,11 +349,11 @@ portSHORT sError = pdFALSE;
|
||||||
|
|
||||||
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
||||||
{
|
{
|
||||||
dTotal2 += pdArray[ xPosition ];
|
fTotal2 += pfArray[ xPosition ];
|
||||||
}
|
}
|
||||||
|
|
||||||
dDifference = dTotal1 - dTotal2;
|
fDifference = fTotal1 - fTotal2;
|
||||||
if( fabs( dDifference ) > 0.001 )
|
if( fabs( fDifference ) > 0.001F )
|
||||||
{
|
{
|
||||||
sError = pdTRUE;
|
sError = pdTRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue