int __gnat_get_task_options (void) { int options; /* Get the options for the task creator */ taskOptionsGet (taskIdSelf (), &options); /* Force VX_FP_TASK because it is almost always required */ options |= VX_FP_TASK; /* Mask those bits that are not under user control */ #ifdef VX_USR_TASK_OPTIONS return options & VX_USR_TASK_OPTIONS; #else return options; #endif }
void slowPoll( void ) { static BOOLEAN addedFixedItems = FALSE; RANDOM_STATE randomState; BYTE buffer[ RANDOM_BUFSIZE + 8 ]; int taskID, value, status; status = initRandomData( randomState, buffer, RANDOM_BUFSIZE ); if( cryptStatusError( status ) ) retIntError_Void(); /* The following are fixed for the lifetime of the process (and in fact for the BSP as a whole) so we only add them once */ if( !addedFixedItems ) { const char *string; int value; /* Add the model name of the CPU board and the BSP version and revision number */ string = sysModel(); if( string != NULL ) addRandomData( randomState, string, strlen( string ) ); string = sysBspRev(); if( string != NULL ) addRandomData( randomState, string, strlen( string ) ); value = sysProcNumGet(); /* Usually 0 */ addRandomLong( randomState, value ); } /* Add the current task ID and task options. The task options are relatively fixed but the task ID seems quite random and over the full 32-bit range */ taskID = taskIdSelf(); addRandomLong( randomState, taskID ); status = taskOptionsGet( taskID, &value ); if( status == OK ) addRandomLong( randomState, value ); endRandomData( randomState, 3 ); fastPoll(); }
int __gnat_get_task_options (void) { int options; /* Get the options for the task creator */ taskOptionsGet (taskIdSelf (), &options); /* Force VX_FP_TASK or VX_SPE_TASK as needed */ #if defined (__SPE__) options |= VX_SPE_TASK; #else options |= VX_FP_TASK; #endif /* Mask those bits that are not under user control */ #ifdef VX_USR_TASK_OPTIONS return options & VX_USR_TASK_OPTIONS; #else return options; #endif }
static void fpuInit() { FP_CONTEXT fpContext; fppSave(&fpContext); /* disable floating-point traps */ #if defined(__i386__) /* set the fp control word precision to 53-bit for both single and double precision */ fpContext.fpcr = 0xffff027f; fppRestore(&fpContext); #elif defined(__sparc__) fpContext.fsr &= ~0x0f800000; fppRestore(&fpContext); fppSave(&fpContext); #endif #if 1 { int options = -1; int status = taskOptionsGet(0, &options); assert(status == OK); assert(options & VX_FP_TASK); } #endif }
os_result os_procCreate( const char *executable_file, const char *name, const char *arguments, os_procAttr *procAttr, os_procId *procId) { int procTaskId; int sched_policy; os_result rv = os_resultSuccess; os_procContextData process_procContextData; os_int32 startRoutine = 0; os_int32 pOptions,privateSet; os_int32 len,i=0,n=0; char *converted = NULL; assert(executable_file != NULL); assert(name != NULL); assert(arguments != NULL); assert(procAttr != NULL); assert(procId != NULL); len = strlen(arguments); converted = (char*)os_malloc(len+1); for (; i < len ; i++) { if (arguments[i] != '\"') { converted[n] = arguments[i]; n++; } } converted[n] = '\0'; pOptions = 0; privateSet = 0; taskOptionsGet(taskIdSelf(),&pOptions); if ((pOptions & VX_PRIVATE_ENV) == 0) { envPrivateCreate(taskIdSelf(), 0); privateSet = 1; } putenv("SPLICE_NEW_PROCESS=no"); if (procAttr->schedClass == OS_SCHED_REALTIME) { sched_policy = SCHED_FIFO; } else if (procAttr->schedClass == OS_SCHED_TIMESHARE) { return os_resultInvalid; } else if (procAttr->schedClass == OS_SCHED_DEFAULT) { sched_policy = SCHED_OTHER; } else { return os_resultInvalid; } if ((procAttr->schedPriority > VXWORKS_PRIORITY_MIN) || (procAttr->schedPriority < VXWORKS_PRIORITY_MAX) ) { return os_resultInvalid; } { os_library binlib; os_libraryAttr attr; os_libraryAttrInit(&attr); /* Dynamic load of services is a special case, so try just static via os_libraryOpen */ attr.staticLibOnly=1; binlib = os_libraryOpen( executable_file, &attr); /* FIXME existing use of os_int32 for pointer is CRAZY!! */ if ( binlib != NULL ) { startRoutine = (os_int32)os_libraryGetSymbol( binlib, executable_file ); } if ( startRoutine == 0 && os_dynamicLibPlugin != NULL ) { startRoutine = (os_uint32)os_dynamicLibPlugin->dlp_loadLib( executable_file ); } if ( startRoutine == 0 ) { OS_REPORT(OS_ERROR, "os_procCreate", 1, "Unable to load %s (%s)", executable_file, name); rv = os_resultInvalid; } } if (rv == os_resultSuccess) { process_procContextData = (os_procContextData )os_malloc((size_t)OS_SIZEOF(os_procContextData)); if (process_procContextData == (os_procContextData) NULL) { OS_REPORT(OS_WARNING, "os_procCreate", 1, "malloc failed with error %d (%s, %s)", os_getErrno(), executable_file, name); rv = os_resultInvalid; } else { #if defined ( _WRS_VXWORKS_MAJOR ) && ( _WRS_VXWORKS_MAJOR > 6 ) || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR > 8 ) /* the blockParent semaphore is used to prevent this task exiting before the spawned task has completed copying its environ. */ os_sem_t blockParent; os_sem_init( &blockParent, 0); #endif os_procInit(process_procContextData, name, executable_file, converted); process_procContextData->procAttrPrio = procAttr->schedPriority; procTaskId = taskSpawn((char *)name, procAttr->schedPriority, VX_FP_TASK #if ! defined ( _WRS_VXWORKS_MAJOR ) || _WRS_VXWORKS_MAJOR < 6 || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR < 9 ) /* VX_PRIVATE_ENV flag is no longer functional in vxworks 6.9 */ | VX_PRIVATE_ENV #endif #if defined ( VXWORKS_55 ) || defined ( VXWORKS_54 ) | VX_STDIO | VX_DEALLOC_STACK #endif , VXWORKS_PROC_DEFAULT_STACK, (FUNCPTR)os_procWrapper, (int)process_procContextData, (int)process_procContextData->executable, (int)startRoutine, (int)process_procContextData->arguments, taskIdSelf(), #if ! defined ( _WRS_VXWORKS_MAJOR ) || _WRS_VXWORKS_MAJOR < 6 || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR < 9 ) 0, #else &blockParent, #endif 0, 0, 0, 0); #if defined ( _WRS_VXWORKS_MAJOR ) && ( _WRS_VXWORKS_MAJOR > 6 || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR > 8 ) ) os_sem_wait(&blockParent); os_sem_destroy(&blockParent); #endif if (procTaskId == ERROR) { os_free(process_procContextData); rv = os_resultInvalid; } else { *procId = *(os_procId *)&process_procContextData; rv = os_resultSuccess; } } } putenv("SPLICE_NEW_PROCESS=empty"); if ( privateSet == 1) { envPrivateDestroy(taskIdSelf()); } os_free(converted); return rv; }