Changeset 1bf878f7 in rtems


Ignore:
Timestamp:
07/14/22 13:06:02 (8 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
1e360d3
Parents:
4b911a75
git-author:
Sebastian Huber <sebastian.huber@…> (07/14/22 13:06:02)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/15/22 08:46:02)
Message:

score: Extend memory dirty/zero actions

Dirty or zero also the part of the .noinit section used by RTEMS.

Close #4678.

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/memory.h

    r4b911a75 r1bf878f7  
    1111 * SPDX-License-Identifier: BSD-2-Clause
    1212 *
    13  * Copyright (C) 2019 embedded brains GmbH
     13 * Copyright (C) 2019, 2022 embedded brains GmbH
    1414 *
    1515 * Redistribution and use in source and binary forms, with or without
     
    353353void _Memory_Dirty_free_areas( void );
    354354
     355/**
     356 * @brief This symbol marks the begin of the non-initialized section used by
     357 *   RTEMS.
     358 */
     359extern char _Memory_Noinit_begin[];
     360
     361/**
     362 * @brief This symbol marks the end of the non-initialized section used by
     363 *   RTEMS.
     364 */
     365extern char _Memory_Noinit_end[];
     366
    355367/** @} */
    356368
  • cpukit/score/src/memorydirtyfreeareas.c

    r4b911a75 r1bf878f7  
    1111 * SPDX-License-Identifier: BSD-2-Clause
    1212 *
    13  * Copyright (C) 2020 embedded brains GmbH
     13 * Copyright (C) 2020, 2022 embedded brains GmbH
    1414 *
    1515 * Redistribution and use in source and binary forms, with or without
     
    4141#include <rtems/score/memory.h>
    4242
     43#include <string.h>
     44
    4345void _Memory_Dirty_free_areas( void )
    4446{
    4547  _Memory_Fill( _Memory_Get(), 0xcf );
     48  memset(
     49    _Memory_Noinit_begin,
     50    0xcf,
     51    (uintptr_t) _Memory_Noinit_end - (uintptr_t) _Memory_Noinit_begin
     52  );
    4653}
  • cpukit/score/src/memoryzerofreeareas.c

    r4b911a75 r1bf878f7  
    1111 * SPDX-License-Identifier: BSD-2-Clause
    1212 *
    13  * Copyright (C) 2020 embedded brains GmbH
     13 * Copyright (C) 2020, 2022 embedded brains GmbH
    1414 *
    1515 * Redistribution and use in source and binary forms, with or without
     
    4141#include <rtems/score/memory.h>
    4242
     43#include <string.h>
     44
    4345void _Memory_Zero_free_areas( void )
    4446{
    4547  _Memory_Fill( _Memory_Get(), 0 );
     48  memset(
     49    _Memory_Noinit_begin,
     50    0,
     51    (uintptr_t) _Memory_Noinit_end - (uintptr_t) _Memory_Noinit_begin
     52  );
    4653}
  • spec/build/cpukit/librtemscpu.yml

    r4b911a75 r1bf878f7  
    14361436- cpukit/score/src/memorydirtyfreeareas.c
    14371437- cpukit/score/src/memoryfill.c
     1438- cpukit/score/src/memorynoinit.c
    14381439- cpukit/score/src/memoryzerobeforeuse.c
    14391440- cpukit/score/src/memoryzerofreeareas.c
  • testsuites/sptests/sp54/init.c

    r4b911a75 r1bf878f7  
    3838#endif
    3939
     40#include <rtems/sysinit.h>
     41#include <rtems/score/memory.h>
     42#include <rtems/score/thread.h>
     43
    4044#include <tmacros.h>
    4145
     
    4852  rtems_id                             id;
    4953  const rtems_api_configuration_table *config;
    50 
    51   /*
    52    *  It is possible that since this thread prints and there is no idle
    53    *  task, that the system could fail miserably. :(
    54    */
    55   TEST_BEGIN();
    5654
    5755  puts( "Init - use valid id of API class with no objects" );
     
    8179}
    8280
     81static void check_dirty_memory( void )
     82{
     83  unsigned char *p;
     84
     85  TEST_BEGIN();
     86
     87  p = _Memory_Allocate( _Memory_Get(), sizeof( *p ), RTEMS_ALIGNOF( *p ) );
     88  rtems_test_assert( p != NULL );
     89  rtems_test_assert( *p == 0xcf );
     90
     91  p = (unsigned char *) _Thread_Information.Objects.local_table;
     92  rtems_test_assert( *p == 0xcf );
     93}
     94
     95RTEMS_SYSINIT_ITEM(
     96  check_dirty_memory,
     97  RTEMS_SYSINIT_DIRTY_MEMORY,
     98  RTEMS_SYSINIT_ORDER_LAST
     99);
     100
     101static void check_zero_workspace_automatically( void )
     102{
     103  unsigned char *p;
     104
     105  p = _Memory_Allocate( _Memory_Get(), sizeof( *p ), RTEMS_ALIGNOF( *p ) );
     106  rtems_test_assert( p != NULL );
     107  rtems_test_assert( *p == 0 );
     108
     109  p = (unsigned char *) _Thread_Information.Objects.local_table;
     110  rtems_test_assert( *p == 0 );
     111}
     112
     113RTEMS_SYSINIT_ITEM(
     114  check_zero_workspace_automatically,
     115  RTEMS_SYSINIT_ZERO_MEMORY,
     116  RTEMS_SYSINIT_ORDER_LAST
     117);
     118
    83119/* configuration information */
    84120
Note: See TracChangeset for help on using the changeset viewer.