Changeset 514705d in rtems


Ignore:
Timestamp:
Feb 12, 2014, 3:05:35 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
38ee758
Parents:
92f50c3
git-author:
Sebastian Huber <sebastian.huber@…> (02/12/14 15:05:35)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/19/14 08:59:39)
Message:

score: Delete _Thread_BSP_context

Do not return to BSP context in the exit() shutdown path. This makes it
possible to re-use the initialization stack. It can be used for the
interrupt stack for example. On targets with a small RAM this is a
considerable benefit.

This change eliminates also some special cases and simplifies the code.

Delete _Thread_Set_global_exit_status(),
_Thread_Get_global_exit_status() and _Thread_Stop_multitasking().

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/src/exinit.c

    r92f50c3 r514705d  
    3434#include <rtems/debug.h>
    3535#include <rtems/extensionimpl.h>
    36 #include <rtems/fatal.h>
    3736#include <rtems/init.h>
    3837#include <rtems/io.h>
     
    216215void rtems_initialize_start_multitasking(void)
    217216{
    218   uint32_t status;
    219 
    220217  _System_state_Set( SYSTEM_STATE_UP );
    221218
     
    224221#endif
    225222
    226   _Thread_Start_multitasking( &_Thread_BSP_context );
     223  _Thread_Start_multitasking();
    227224
    228225  /*******************************************************************
     
    230227   *******************************************************************
    231228   ******                 APPLICATION RUNS HERE                 ******
    232    ******            RETURNS WHEN SYSTEM IS SHUT DOWN           ******
     229   ******              THE FUNCTION NEVER RETURNS               ******
    233230   *******************************************************************
    234231   *******************************************************************
    235232   *******************************************************************/
    236 
    237   status = _Thread_Get_global_exit_status();
    238   rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, status );
    239 }
     233}
  • cpukit/sapi/src/exshutdown.c

    r92f50c3 r514705d  
    1616#include <rtems/init.h>
    1717#include <rtems/score/sysstate.h>
    18 #include <rtems/score/threadimpl.h>
    1918#include <rtems/score/interr.h>
    2019
     
    2322#endif
    2423
    25 /*
    26  *  rtems_shutdown_executive
    27  *
    28  *  This kernel routine shutdowns the executive.  It halts multitasking
    29  *  and returns control to the application execution "thread" which
    30  *  initialially invoked the rtems_initialize_executive directive.
    31  *
    32  *  Input parameters:   NONE
    33  *
    34  *  Output parameters:  NONE
    35  */
     24void rtems_shutdown_executive( uint32_t result )
     25{
     26  Internal_errors_Source  source;
     27  bool                    is_internal;
     28  Internal_errors_t       code;
    3629
    37 void rtems_shutdown_executive(
    38    uint32_t   result
    39 )
    40 {
    4130  if ( _System_state_Is_up( _System_state_Get() ) ) {
    4231    #if defined(RTEMS_SMP)
     
    4433    #endif
    4534
    46     _Thread_Set_global_exit_status( result );
    47     _Thread_Stop_multitasking();
     35    source      = RTEMS_FATAL_SOURCE_EXIT;
     36    is_internal = false;
     37    code        = result;
     38  } else {
     39    source      = INTERNAL_ERROR_CORE;
     40    is_internal = true;
     41    code        = INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP;
     42  }
    4843
    49     /*******************************************************************
    50      *******************************************************************
    51      ******     RETURN TO RTEMS_INITIALIZE_START_MULTITASKING()   ******
    52      ******                 AND THEN TO BOOT_CARD()               ******
    53      *******************************************************************
    54      *******************************************************************/
    55   }
    56   _Internal_error_Occurred(
    57     INTERNAL_ERROR_CORE,
    58     true,
    59     INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP
    60   );
     44  _Internal_error_Occurred( source, is_internal, code );
     45
     46  /***************************************************************
     47   ***************************************************************
     48   *   SYSTEM SHUTS DOWN!!!  WE DO NOT RETURN TO THIS POINT!!!   *
     49   ***************************************************************
     50   ***************************************************************/
    6151}
  • cpukit/score/cpu/arm/armv7m-multitasking-start-stop.c

    r92f50c3 r514705d  
    22 * @file
    33 *
    4  * @brief ARMV7M Start and Stop Multitasking
     4 * @brief ARMV7M Start Multitasking
    55 */
    66
    77/*
    8  * Copyright (c) 2011 Sebastian Huber.  All rights reserved.
     8 * Copyright (c) 2011-2014 Sebastian Huber.  All rights reserved.
    99 *
    1010 *  embedded brains GmbH
    11  *  Obere Lagerstr. 30
     11 *  Dornierstr. 4
    1212 *  82178 Puchheim
    1313 *  Germany
     
    2828
    2929void __attribute__((naked)) _ARMV7M_Start_multitasking(
    30   Context_Control *bsp,
    3130  Context_Control *heir
    3231)
    3332{
    3433  __asm__ volatile (
    35     /* Store BSP context */
    36     "stm r0, {r4-r11, lr}\n"
    37     "str sp, [r0, %[spctxoff]]\n"
    3834    /* Restore heir context */
    39     "ldr r2, [r1, %[spctxoff]]\n"
     35    "ldr r2, [r0, %[spctxoff]]\n"
    4036    "msr psp, r2\n"
    41     "ldm r1, {r4-r11, lr}\n"
     37    "ldm r0, {r4-r11, lr}\n"
    4238    /* Enable process stack pointer (PSP) */
    4339    "mrs r2, control\n"
     
    5147}
    5248
    53 void __attribute__((naked)) _ARMV7M_Stop_multitasking( Context_Control *bsp )
    54 {
    55   __asm__ volatile (
    56     /* Disable interrupts */
    57     "mov r2, #0x80\n"
    58     "msr basepri_max, r2\n"
    59     /* Restore BSP context */
    60     "ldr r2, [r0, %[spctxoff]]\n"
    61     "msr msp, r2\n"
    62     "ldm r0, {r4-r11, lr}\n"
    63     /* Disable process stack pointer (PSP) */
    64     "mrs r2, control\n"
    65     "bic r2, #0x2\n"
    66     "msr control, r2\n"
    67     /* Return to BSP */
    68     "bx lr\n"
    69     :
    70     : [spctxoff] "J" (offsetof(Context_Control, register_sp))
    71   );
    72   __builtin_unreachable();
    73 }
    74 
    7549#endif /* ARM_MULTILIB_ARCH_V7M */
  • cpukit/score/cpu/arm/rtems/score/cpu.h

    r92f50c3 r514705d  
    459459
    460460#if defined(ARM_MULTILIB_ARCH_V7M)
    461   void _ARMV7M_Start_multitasking( Context_Control *bsp, Context_Control *heir );
    462   void _ARMV7M_Stop_multitasking( Context_Control *bsp )
    463     RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
     461  void _ARMV7M_Start_multitasking( Context_Control *heir );
    464462  #define _CPU_Start_multitasking _ARMV7M_Start_multitasking
    465   #define _CPU_Stop_multitasking _ARMV7M_Stop_multitasking
    466463#endif
    467464
  • cpukit/score/include/rtems/score/threadimpl.h

    r92f50c3 r514705d  
    2121
    2222#include <rtems/score/thread.h>
     23#include <rtems/score/interr.h>
    2324#include <rtems/score/isr.h>
    2425#include <rtems/score/objectimpl.h>
     
    5556
    5657/**
    57  *  The following context area contains the context of the "thread"
    58  *  which invoked the start multitasking routine.  This context is
    59  *  restored as the last action of the stop multitasking routine.  Thus
    60  *  control of the processor can be returned to the environment
    61  *  which initiated the system.
    62  */
    63 SCORE_EXTERN Context_Control _Thread_BSP_context;
    64 
    65 /**
    6658 *  The following holds how many user extensions are in the system.  This
    6759 *  is used to determine how many user extension data areas to allocate
     
    115107 *  part of initialization and its invocation is the last act of
    116108 *  the non-multitasking part of the system initialization.
    117  *
    118  *
    119  *  - INTERRUPT LATENCY:
    120  *    + ready chain
    121  *    + select heir
    122  */
    123 void _Thread_Start_multitasking( Context_Control *context );
     109 */
     110void _Thread_Start_multitasking( void ) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
    124111
    125112/**
     
    447434
    448435/**
    449  * This routine halts multitasking and returns control to
    450  * the "thread" (i.e. the BSP) which initially invoked the
    451  * routine which initialized the system.
    452  */
    453 
    454 RTEMS_INLINE_ROUTINE void _Thread_Stop_multitasking( void )
    455 {
    456 #if defined(_CPU_Stop_multitasking)
    457   _CPU_Stop_multitasking( &_Thread_BSP_context );
    458 #else
    459   /*
    460    *  This may look a bit of an odd but _Context_Restart_self is just
    461    *  a very careful restore of a specific context which ensures that
    462    *  if we were running within the same context, it would work.
    463    *
    464    *  And we will not return to this thread, so there is no point of
    465    *  saving the context.
    466    */
    467   _Context_Restart_self( &_Thread_BSP_context );
    468 #endif
    469 
    470   /***************************************************************
    471    ***************************************************************
    472    *   SYSTEM SHUTS DOWN!!!  WE DO NOT RETURN TO THIS POINT!!!   *
    473    ***************************************************************
    474    ***************************************************************
    475    */
    476 }
    477 
    478 /**
    479436 * This function returns true if the_thread is the currently executing
    480437 * thread, and false otherwise.
     
    629586{
    630587  _Objects_Free( &_Thread_Internal_information, &the_task->Object );
    631 }
    632 
    633 RTEMS_INLINE_ROUTINE void _Thread_Set_global_exit_status(
    634   uint32_t exit_status
    635 )
    636 {
    637   Thread_Control *idle = (Thread_Control *)
    638     _Thread_Internal_information.local_table[ 1 ];
    639 
    640   idle->Wait.return_code = exit_status;
    641 }
    642 
    643 RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_global_exit_status( void )
    644 {
    645   const Thread_Control *idle = (const Thread_Control *)
    646     _Thread_Internal_information.local_table[ 1 ];
    647 
    648   return idle->Wait.return_code;
    649588}
    650589
  • cpukit/score/src/smp.c

    r92f50c3 r514705d  
    4141  _Per_CPU_Wait_for_state( self_cpu, PER_CPU_STATE_BEGIN_MULTITASKING );
    4242
    43   _Thread_Start_multitasking( NULL );
     43  _Thread_Start_multitasking();
    4444}
    4545
  • cpukit/score/src/threadstartmultitasking.c

    r92f50c3 r514705d  
    2121#include <rtems/score/threadimpl.h>
    2222
    23 void _Thread_Start_multitasking( Context_Control *context )
     23void _Thread_Start_multitasking( void )
    2424{
    2525  Per_CPU_Control *self_cpu = _Per_CPU_Get();
     
    2929  _Per_CPU_Change_state( self_cpu, PER_CPU_STATE_UP );
    3030
     31  /*
     32   * Threads begin execution in the _Thread_Handler() function.   This
     33   * function will set the thread dispatch disable level to zero and calls
     34   * _Per_CPU_Release().
     35   */
    3136  _Per_CPU_Acquire( self_cpu );
     37  self_cpu->thread_dispatch_disable_level = 1;
    3238
    3339  self_cpu->executing->is_executing = false;
     
    6066#endif
    6167
    62 #if defined(RTEMS_SMP)
    63   if ( context != NULL ) {
    64 #endif
    65 
    6668#if defined(_CPU_Start_multitasking)
    67     _CPU_Start_multitasking( context, &heir->Registers );
     69    _CPU_Start_multitasking( &heir->Registers );
    6870#else
    69     _Context_Switch( context, &heir->Registers );
    70 #endif
    71 
    72 #if defined(RTEMS_SMP)
    73   } else {
    74     /*
    75      * Threads begin execution in the _Thread_Handler() function.   This
    76      * function will set the thread dispatch disable level to zero and calls
    77      * _Per_CPU_Release().
    78      */
    79     self_cpu->thread_dispatch_disable_level = 1;
    80 
    81     _CPU_Context_restore( &heir->Registers );
    82   }
     71    _CPU_Context_Restart_self( &heir->Registers );
    8372#endif
    8473}
  • testsuites/sptests/spsize/size.c

    r92f50c3 r514705d  
    386386/*tasksimpl.h*/ (sizeof _RTEMS_tasks_Information)         +
    387387
    388 /*thread.h*/    (sizeof _Thread_BSP_context)              +
    389                 (sizeof _Thread_Dispatch_disable_level)   +
     388/*thread.h*/    (sizeof _Thread_Dispatch_disable_level)   +
    390389                (sizeof _Thread_Maximum_extensions)       +
    391390                (sizeof _Thread_Ticks_per_timeslice)      +
Note: See TracChangeset for help on using the changeset viewer.