Esempio n. 1
0
static void run_test_ftoi32(FILE* f, unsigned int i, uint32_t fpscr) {
  uint32_t in = select_f32(i);
  uint32_t old_fpscr = get_fpscr();

  set_fpscr(fpscr);
  uint32_t out_u = ftoui32(in);
  uint32_t new_fpscr_u = get_fpscr();

  set_fpscr(fpscr);
  uint32_t out_s = ftosi32(in);
  uint32_t new_fpscr_s = get_fpscr();

  set_fpscr(old_fpscr);
  fprintf(f, "0x%08" PRIX32 " => u:0x%08" PRIX32 " fpscr: 0x%08" PRIX32 " | s:0x%08" PRIX32 " fpscr: 0x%08" PRIX32 "\n",
          in, out_u, new_fpscr_u, out_s, new_fpscr_s);
  return;
}
Esempio n. 2
0
portBASE_TYPE xPortUsesFloatingPoint( xTaskHandle xTask )
{
unsigned long *pulFlopBuffer;
portBASE_TYPE xReturn;
extern void * volatile pxCurrentTCB;

	/* This function tells the kernel that the task referenced by xTask is
	going to use the floating point registers and therefore requires the
	floating point registers saved as part of its context. */

	/* Passing NULL as xTask is used to indicate that the calling task is the
	subject task - so pxCurrentTCB is the task handle. */
	if( xTask == NULL )
	{
		xTask = ( xTaskHandle ) pxCurrentTCB;
	}

	/* Allocate a buffer large enough to hold all the flop registers. */
	pulFlopBuffer = ( unsigned long * ) pvPortMalloc( portFLOP_STORAGE_SIZE );
	
	if( pulFlopBuffer != NULL )
	{
		/* Start with the registers in a benign state. */
		memset( ( void * ) pulFlopBuffer, 0x00, portFLOP_STORAGE_SIZE );
		
		/* The first thing to get saved in the buffer is the FPSCR value -
		initialise this to the current FPSCR value. */
		*pulFlopBuffer = get_fpscr();
		
		/* Use the task tag to point to the flop buffer.  Pass pointer to just 
		above the buffer because the flop save routine uses a pre-decrement. */
		vTaskSetApplicationTaskTag( xTask, ( void * ) ( pulFlopBuffer + portFLOP_REGISTERS_TO_STORE ) );		
		xReturn = pdPASS;
	}
	else
	{
		xReturn = pdFAIL;
	}
	
	return xReturn;
}