static void test_cache_coherent_alloc(void) { void *p0; void *p1; System_state_Codes previous_state; printf("test cache coherent allocation\n"); p0 = rtems_cache_coherent_allocate(1, 0, 0); rtems_test_assert(p0 != NULL); rtems_cache_coherent_free(p0); p0 = rtems_cache_coherent_allocate(1, 0, 0); rtems_test_assert(p0 != NULL); add_area(&cache_coherent_area_0[0]); add_area(&cache_coherent_area_1[0]); previous_state = _System_state_Get(); _System_state_Set(previous_state + 1); add_area(&cache_coherent_area_2[0]); _System_state_Set(previous_state); p1 = rtems_cache_coherent_allocate(1, 0, 0); rtems_test_assert(p1 != NULL); rtems_cache_coherent_free(p0); rtems_cache_coherent_free(p1); }
static void test_system_not_up(void) { rtems_interrupt_level level; puts( "start with a system state != SYSTEM_STATE_UP" ); rtems_interrupt_disable( level ); System_state_Codes state = _System_state_Get(); _System_state_Set( SYSTEM_STATE_FAILED ); test_call_heap_walk( true ); _System_state_Set( state ); rtems_interrupt_enable( level ); }
void rtems_initialize_executive(void) { const volatile rtems_sysinit_item *cur = RTEMS_LINKER_SET_BEGIN(_Sysinit ); const volatile rtems_sysinit_item *end = RTEMS_LINKER_SET_END( _Sysinit ); /* Invoke the registered system initialization handlers */ while ( cur != end ) { ( *cur->handler )(); ++cur; } _System_state_Set( SYSTEM_STATE_UP ); _SMP_Request_start_multitasking(); _Thread_Start_multitasking(); /******************************************************************* ******************************************************************* ******************************************************************* ****** APPLICATION RUNS HERE ****** ****** THE FUNCTION NEVER RETURNS ****** ******************************************************************* ******************************************************************* *******************************************************************/ }
void rtems_shutdown_executive( uint32_t result ) { if ( _System_state_Is_up( _System_state_Get() ) ) { #if defined(RTEMS_SMP) _SMP_Request_other_cores_to_shutdown(); #endif _Per_CPU_Information[0].idle->Wait.return_code = result; _System_state_Set( SYSTEM_STATE_SHUTDOWN ); _Thread_Stop_multitasking(); /******************************************************************* ******************************************************************* ****** RETURN TO RTEMS_INITIALIZE_START_MULTITASKING() ****** ****** AND THEN TO BOOT_CARD() ****** ******************************************************************* *******************************************************************/ } _Internal_error_Occurred( INTERNAL_ERROR_CORE, true, INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP ); }
void rtems_shutdown_executive( uint32_t result ) { if ( !_System_state_Is_shutdown( _System_state_Get() ) ) { _System_state_Set( SYSTEM_STATE_SHUTDOWN ); _Thread_Stop_multitasking(); } }
uint32_t rtems_initialize_start_multitasking(void) { _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING ); _Thread_Start_multitasking(); /******************************************************************* ******************************************************************* ******************************************************************* ****** APPLICATION RUNS HERE ****** ****** RETURNS WHEN SYSTEM IS SHUT DOWN ****** ******************************************************************* ******************************************************************* *******************************************************************/ return _Per_CPU_Information[0].idle->Wait.return_code; }
void rtems_initialize_start_multitasking(void) { _System_state_Set( SYSTEM_STATE_UP ); _SMP_Request_start_multitasking(); _Thread_Start_multitasking(); /******************************************************************* ******************************************************************* ******************************************************************* ****** APPLICATION RUNS HERE ****** ****** THE FUNCTION NEVER RETURNS ****** ******************************************************************* ******************************************************************* *******************************************************************/ }
void _Internal_error_Occurred( Internal_errors_Source the_source, bool is_internal, Internal_errors_t the_error ) { _User_extensions_Fatal( the_source, is_internal, the_error ); _Internal_errors_What_happened.the_source = the_source; _Internal_errors_What_happened.is_internal = is_internal; _Internal_errors_What_happened.the_error = the_error; _System_state_Set( SYSTEM_STATE_FAILED ); _CPU_Fatal_halt( the_error ); /* will not return from this routine */ while (true); }
void _Thread_Start_multitasking( void ) { /* * The system is now multitasking and completely initialized. * This system thread now "hides" in a single processor until * the system is shut down. */ _System_state_Set( SYSTEM_STATE_UP ); _Thread_Dispatch_necessary = false; _Thread_Executing = _Thread_Heir; /* * Get the init task(s) running. * * Note: Thread_Dispatch() is normally used to dispatch threads. As * part of its work, Thread_Dispatch() restores floating point * state for the heir task. * * This code avoids Thread_Dispatch(), and so we have to restore * (actually initialize) the floating point state "by hand". * * Ignore the CPU_USE_DEFERRED_FP_SWITCH because we must always * switch in the first thread if it is FP. */ #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) /* * don't need to worry about saving BSP's floating point state */ if ( _Thread_Heir->fp_context != NULL ) _Context_Restore_fp( &_Thread_Heir->fp_context ); #endif #if defined(_CPU_Start_multitasking) _CPU_Start_multitasking( &_Thread_BSP_context, &_Thread_Heir->Registers ); #else _Context_Switch( &_Thread_BSP_context, &_Thread_Heir->Registers ); #endif }
void rtems_initialize_start_multitasking(void) { uint32_t status; _System_state_Set( SYSTEM_STATE_BEGIN_MULTITASKING ); _Thread_Start_multitasking(); /******************************************************************* ******************************************************************* ******************************************************************* ****** APPLICATION RUNS HERE ****** ****** RETURNS WHEN SYSTEM IS SHUT DOWN ****** ******************************************************************* ******************************************************************* *******************************************************************/ status = _Per_CPU_Information[0].idle->Wait.return_code; rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, status ); }
void rtems_initialize_data_structures(void) { /* * Dispatching and interrupts are disabled until the end of the * initialization sequence. This prevents an inadvertent context * switch before the executive is initialized. * * WARNING: Interrupts should have been disabled by the BSP and * are disabled by boot_card(). */ #if defined(RTEMS_MULTIPROCESSING) /* * Initialize the system state based on whether this is an MP system. * In an MP configuration, internally we view single processor * systems as a very restricted multiprocessor system. */ _Configuration_MP_table = Configuration.User_multiprocessing_table; if ( _Configuration_MP_table == NULL ) { _Configuration_MP_table = (void *)&_Initialization_Default_multiprocessing_table; _System_state_Handler_initialization( FALSE ); } else { _System_state_Handler_initialization( TRUE ); } #else _System_state_Handler_initialization( FALSE ); #endif /* * Initialize any target architecture specific support as early as possible */ _CPU_Initialize(); #if defined(RTEMS_MULTIPROCESSING) _Objects_MP_Handler_early_initialization(); #endif /* * Do this as early as possible to ensure no debugging output * is even attempted to be printed. */ _Debug_Manager_initialization(); _API_extensions_Initialization(); _Thread_Dispatch_initialization(); /* * Before this is called, we are not allowed to allocate memory * from the Workspace because it is not initialized. */ _Workspace_Handler_initialization(); #if defined(RTEMS_SMP) _SMP_Handler_initialize(); #endif _User_extensions_Handler_initialization(); _ISR_Handler_initialization(); /* * Initialize the internal support API and allocator Mutex */ _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects; _API_Mutex_Initialization( 1 ); _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex ); _Priority_bit_map_Handler_initialization(); _Watchdog_Handler_initialization(); _TOD_Handler_initialization(); _Thread_Handler_initialization(); _Scheduler_Handler_initialization(); #if defined(RTEMS_MULTIPROCESSING) _Objects_MP_Handler_initialization(); _MPCI_Handler_initialization( RTEMS_TIMEOUT ); #endif /* MANAGERS */ _RTEMS_API_Initialize(); _Extension_Manager_initialization(); _IO_Manager_initialization(); #ifdef RTEMS_POSIX_API _POSIX_API_Initialize(); #endif /* * Discover and initialize the secondary cores in an SMP system. */ #if defined(RTEMS_SMP) _SMP_Processor_count = bsp_smp_initialize( rtems_configuration_smp_maximum_processors ); #endif _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING ); /* * No threads should be created before this point!!! * _Thread_Executing and _Thread_Heir are not set. * * At this point all API extensions are in place. After the call to * _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set. */ _Thread_Create_idle(); /* * Scheduling can properly occur now as long as we avoid dispatching. */ }
void rtems_initialize_data_structures(void) { _System_state_Handler_initialization( FALSE ); _CPU_Initialize(); /* * Do this as early as possible to ensure no debugging output * is even attempted to be printed. */ _Debug_Manager_initialization(); _API_extensions_Initialization(); _Thread_Dispatch_initialization(); _User_extensions_Handler_initialization(); _ISR_Handler_initialization(); /* * Initialize the internal support API and allocator Mutex */ _Objects_Information_table[OBJECTS_INTERNAL_API] = _Internal_Objects; _API_Mutex_Initialization( 2 ); _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex ); _API_Mutex_Allocate( &_Once_Mutex ); _Watchdog_Handler_initialization(); _TOD_Handler_initialization(); _Thread_Handler_initialization(); _Scheduler_Handler_initialization(); _SMP_Handler_initialize(); _CPU_set_Handler_initialization(); /* MANAGERS */ /* * Install our API Object Management Table and initialize the * various managers. */ _Objects_Information_table[OBJECTS_CLASSIC_API] = _RTEMS_Objects; _RTEMS_tasks_Manager_initialization(); _Semaphore_Manager_initialization(); /* * Install our API Object Management Table and initialize the * various managers. */ _Objects_Information_table[OBJECTS_POSIX_API] = _POSIX_Objects; _POSIX_Key_Manager_initialization(); /* * Discover and initialize the secondary cores in an SMP system. */ _SMP_Handler_initialize(); _System_state_Set( SYSTEM_STATE_BEFORE_MULTITASKING ); /* * No threads should be created before this point!!! * _Thread_Executing and _Thread_Heir are not set. * * At this point all API extensions are in place. After the call to * _Thread_Create_idle() _Thread_Executing and _Thread_Heir will be set. */ _Thread_Create_idle(); /* * Scheduling can properly occur now as long as we avoid dispatching. */ _System_state_Set( SYSTEM_STATE_UP ); _SMP_Request_start_multitasking(); _Thread_Start_multitasking(); /* Add Initialization of the Thread_Dispatch wrapper */ Init__wrap__Thread_Dispatch(); /* * Now we are back in a non-dispatching critical section */ #if defined(RTEMS_SMP) { ISR_Level level; /* * On SMP we enter _Thread_Handler() with interrupts disabled and * _Thread_Dispatch() obtained the per-CPU lock for us. We have to * release it here and set the desired interrupt level of the thread. */ Per_CPU_Control *cpu_self = _Per_CPU_Get(); _Assert( cpu_self->thread_dispatch_disable_level == 1 ); _Assert( _ISR_Get_level() != 0 ); cpu_self->thread_dispatch_disable_level = 0; _Profiling_Thread_dispatch_enable( cpu_self, 0 ); /* For whatever reason, we haven't locked our per cpu yet in the * Scheduler Simulator. Until this is done, this release is not needed. */ /* _Per_CPU_Release( cpu_self ); */ level = _Thread_Executing->Start.isr_level; _ISR_Set_level( level); /* * The thread dispatch level changed from one to zero. Make sure we lose * no thread dispatch necessary update. */ _Thread_Dispatch(); } #else _Thread_Enable_dispatch(); #endif /* * Print an initial message */ check_heir_and_executing(); }