source: rtems/testsuites/sptests/spfatal09/init.c @ eea21eac

5
Last change on this file since eea21eac was eea21eac, checked in by Sebastian Huber <sebastian.huber@…>, on 12/13/19 at 05:18:36

bsps: Rework work area initialization

The work area initialization was done by the BSP through
bsp_work_area_initialize(). This approach predated the system
initialization through the system initialization linker set. The
workspace and C program heap were unconditionally initialized. The aim
is to support RTEMS application configurations which do not need the
workspace and C program heap. In these configurations, the workspace
and C prgram heap should not get initialized.

Change all bsp_work_area_initialize() to implement _Memory_Get()
instead. Move the dirty memory, sbrk(), per-CPU data, workspace, and
malloc() heap initialization into separate system initialization steps.
This makes it also easier to test the individual initialization steps.

This change adds a dependency to _Heap_Extend() to all BSPs. This
dependency will be removed in a follow up change.

Update #3838.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#include "../spfatal_support/spfatal.h"
6
7/*
8 *  Malloc Initialization Error
9 *
10 *  COPYRIGHT (c) 1989-2010.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#include <rtems/score/memory.h>
19#include <rtems/sysinit.h>
20
21#include <stdlib.h>
22
23#define FATAL_ERROR_TEST_NAME            "9"
24#define FATAL_ERROR_DESCRIPTION          "Bad heap address to malloc"
25#define FATAL_ERROR_EXPECTED_SOURCE      INTERNAL_ERROR_CORE
26#define FATAL_ERROR_EXPECTED_ERROR       INTERNAL_ERROR_NO_MEMORY_FOR_HEAP
27
28static void force_error( void )
29{
30  void *p;
31
32  /* we will not run this far */
33  p = malloc( 1 );
34  RTEMS_OBFUSCATE_VARIABLE( p );
35}
36
37static void consume_all_memory( void )
38{
39  const Memory_Information *mem;
40  size_t                    i;
41
42  mem = _Memory_Get();
43
44  for ( i = 0; i < _Memory_Get_count( mem ); ++i ) {
45    Memory_Area *area;
46
47    area = _Memory_Get_area( mem, i );
48    _Memory_Consume( area, _Memory_Get_free_size( area ) );
49  }
50}
51
52RTEMS_SYSINIT_ITEM(
53  consume_all_memory,
54  RTEMS_SYSINIT_MALLOC,
55  RTEMS_SYSINIT_ORDER_FIRST
56);
57
58#include "../spfatal_support/spfatalimpl.h"
Note: See TracBrowser for help on using the repository browser.