source: rtems/testsuites/smptests/smpfatal09/init.c @ eea21eac

5
Last change on this file since eea21eac was eea21eac, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 13, 2019 at 5:18:36 AM

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: 3.0 KB
Line 
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2018 embedded brains GmbH
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#include <rtems.h>
33#include <rtems/score/percpudata.h>
34#include <rtems/score/memory.h>
35#include <rtems/sysinit.h>
36
37#include <tmacros.h>
38
39static PER_CPU_DATA_ITEM(int, i) = 123;
40
41const char rtems_test_name[] = "SMPFATAL 9";
42
43static void Init( rtems_task_argument arg )
44{
45  (void) arg;
46}
47
48static void consume_all_memory( void )
49{
50  const Memory_Information *mem;
51  size_t                    i;
52
53  mem = _Memory_Get();
54
55  for ( i = 0; i < _Memory_Get_count( mem ); ++i ) {
56    Memory_Area *area;
57
58    area = _Memory_Get_area( mem, i );
59    _Memory_Consume( area, _Memory_Get_free_size( area ) );
60  }
61}
62
63static void begin_test( void )
64{
65  int i;
66
67  TEST_BEGIN();
68  i = *PER_CPU_DATA_GET( _Per_CPU_Get_snapshot(), int, i );
69  RTEMS_OBFUSCATE_VARIABLE( i );
70  rtems_test_assert( i == 123 );
71
72  consume_all_memory();
73}
74
75RTEMS_SYSINIT_ITEM(
76  begin_test,
77  RTEMS_SYSINIT_PER_CPU_DATA,
78  RTEMS_SYSINIT_ORDER_FIRST
79);
80
81static void fatal_extension(
82  rtems_fatal_source source,
83  bool always_set_to_false,
84  rtems_fatal_code code
85)
86{
87  if (
88    source == INTERNAL_ERROR_CORE
89      && !always_set_to_false
90      && code == INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA
91  ) {
92    TEST_END();
93  }
94}
95
96#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
97
98#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
99
100#define CONFIGURE_INITIAL_EXTENSIONS \
101  { .fatal = fatal_extension }, \
102  RTEMS_TEST_INITIAL_EXTENSION
103
104#define CONFIGURE_MAXIMUM_PROCESSORS 2
105
106#define CONFIGURE_MAXIMUM_TASKS 1
107
108#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
109
110#define CONFIGURE_INIT
111
112#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.