Changeset 8ecbc38 in rtems


Ignore:
Timestamp:
Feb 4, 2020, 12:56:41 PM (5 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
2d07ce6
Parents:
1d43a97
git-author:
Sebastian Huber <sebastian.huber@…> (02/04/20 12:56:41)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/06/20 14:19:35)
Message:

sysinit: Add RTEMS_SYSINIT_ZERO_MEMORY

Use a dedicate system initialization step to zero the memory used for
the workspace and C program heap.

This avoids dead code in case CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY is
not configured.

Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/Makefile.am

    r1d43a97 r8ecbc38  
    855855librtemscpu_a_SOURCES += score/src/memoryallocate.c
    856856librtemscpu_a_SOURCES += score/src/memoryfill.c
     857librtemscpu_a_SOURCES += score/src/memoryzerobeforeuse.c
     858librtemscpu_a_SOURCES += score/src/memoryzerofreeareas.c
    857859librtemscpu_a_SOURCES += score/src/objectallocate.c
    858860librtemscpu_a_SOURCES += score/src/objectclose.c
  • cpukit/include/rtems/confdefs.h

    r1d43a97 r8ecbc38  
    27792779    CONFIGURE_TASK_STACK_ALLOCATOR,           /* stack allocator */
    27802780    CONFIGURE_TASK_STACK_DEALLOCATOR,         /* stack deallocator */
    2781     #ifdef CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY /* true to clear memory */
    2782       true,
    2783     #else
    2784       false,
    2785     #endif
    27862781    #ifdef CONFIGURE_UNIFIED_WORK_AREAS       /* true for unified work areas */
    27872782      true,
     
    28072802    #endif
    28082803  };
     2804
     2805  #ifdef CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY
     2806    const bool _Memory_Zero_before_use = true;
     2807
     2808    RTEMS_SYSINIT_ITEM(
     2809      _Memory_Zero_free_areas,
     2810      RTEMS_SYSINIT_ZERO_MEMORY,
     2811      RTEMS_SYSINIT_ORDER_MIDDLE
     2812    );
     2813  #endif
    28092814
    28102815  #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0
  • cpukit/include/rtems/config.h

    r1d43a97 r8ecbc38  
    3030#include <rtems/score/object.h>
    3131#include <rtems/score/isr.h>
     32#include <rtems/score/memory.h>
    3233#include <rtems/score/userextdata.h>
    3334#include <rtems/score/watchdogticks.h>
     
    149150  rtems_stack_free_hook          stack_free_hook;
    150151
    151   /**
    152    * If this element is TRUE, then RTEMS will zero the Executive Workspace.
    153    * When this element is FALSE, it is assumed that the BSP or invoking
    154    * environment has ensured that memory was cleared before RTEMS was
    155    * invoked.
    156    */
    157   bool                           do_zero_of_workspace;
    158 
    159152  /**
    160153   * @brief Specifies if a unified work area is used or not.
     
    242235  */
    243236#define rtems_configuration_get_do_zero_of_workspace() \
    244    (Configuration.do_zero_of_workspace)
     237  _Memory_Zero_before_use
    245238
    246239#define rtems_configuration_get_number_of_initial_extensions() \
  • cpukit/include/rtems/score/memory.h

    r1d43a97 r8ecbc38  
    332332void _Memory_Fill( const Memory_Information *information, int c );
    333333
     334/**
     335 * @brief Indicates if the memory is zeroed during system initialization.
     336 *
     337 * This value is provided via <rtems/confdefs.h> in case
     338 * CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY is defined.
     339 */
     340extern const bool _Memory_Zero_before_use;
     341
     342/**
     343 * @brief Zeros all free memory areas of the system.
     344 */
     345void _Memory_Zero_free_areas( void );
     346
    334347/** @} */
    335348
  • cpukit/include/rtems/sysinit.h

    r1d43a97 r8ecbc38  
    11/*
    2  * Copyright (c) 2015, 2018 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2015, 2020 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    3131#define RTEMS_SYSINIT_MEMORY                     000180
    3232#define RTEMS_SYSINIT_DIRTY_MEMORY               0001c0
     33#define RTEMS_SYSINIT_ZERO_MEMORY                0001e0
    3334#define RTEMS_SYSINIT_ISR_STACK                  000200
    3435#define RTEMS_SYSINIT_PER_CPU_DATA               000220
  • cpukit/sapi/src/sysinitverbose.c

    r1d43a97 r8ecbc38  
    4949SYSINIT_VERBOSE( MEMORY );
    5050SYSINIT_VERBOSE( DIRTY_MEMORY );
     51SYSINIT_VERBOSE( ZERO_MEMORY );
    5152SYSINIT_VERBOSE( ISR_STACK );
    5253SYSINIT_VERBOSE( PER_CPU_DATA );
     
    193194}
    194195
     196static void _Sysinit_Verbose_ZERO_MEMORY( void )
     197{
     198  if ( !SYSINIT_IS_ADJACENT( DIRTY_MEMORY, ZERO_MEMORY ) ) {
     199    printk( "sysinit: ZERO_MEMORY: done\n" );
     200  }
     201}
     202
    195203static void _Sysinit_Verbose_ISR_STACK( void )
    196204{
    197   if ( !SYSINIT_IS_ADJACENT( DIRTY_MEMORY, ISR_STACK ) ) {
     205  if ( !SYSINIT_IS_ADJACENT( ZERO_MEMORY, ISR_STACK ) ) {
    198206    printk( "sysinit: ISR_STACK: done\n" );
    199207  }
  • cpukit/score/src/wkspace.c

    r1d43a97 r8ecbc38  
    9191  Heap_Initialization_or_extend_handler init_or_extend;
    9292  uintptr_t                             remaining;
    93   bool                                  do_zero;
    9493  bool                                  unified;
    9594  uintptr_t                             page_size;
     
    102101
    103102  init_or_extend = _Heap_Initialize;
    104   do_zero = rtems_configuration_get_do_zero_of_workspace();
    105103  unified = rtems_configuration_get_unified_work_area();
    106104  overhead = _Heap_Area_overhead( page_size );
     
    112110    area = _Memory_Get_area( mem, i );
    113111    free_size = _Memory_Get_free_size( area );
    114 
    115     if ( do_zero ) {
    116       memset( _Memory_Get_free_begin( area ), 0, free_size );
    117     }
    118112
    119113    if ( free_size > overhead ) {
  • testsuites/sptests/sp54/init.c

    r1d43a97 r8ecbc38  
    5151  fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_task_ident" );
    5252
     53  rtems_test_assert( rtems_configuration_get_do_zero_of_workspace() );
     54
    5355  TEST_END();
    5456  rtems_test_exit(0);
Note: See TracChangeset for help on using the changeset viewer.