source: rtems/testsuites/smptests/smpfatal09/init.c @ 7c19e50

5
Last change on this file since 7c19e50 was 7c19e50, checked in by Sebastian Huber <sebastian.huber@…>, on 12/18/18 at 07:45:06

score: Fix per-CPU data allocation

Allocate the per-CPU data for secondary processors directly from the
heap areas before heap initialization and not via
_Workspace_Allocate_aligned(). This avoids dependency on the workspace
allocator. It fixes also a problem on some platforms (e.g. QorIQ) where
at this early point in the system initialization the top of the RAM is
used by low-level startup code on secondary processors (boot pages).

Update #3507.

  • Property mode set to 100644
File size: 2.6 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/wkspace.h>
35
36#include <tmacros.h>
37
38static PER_CPU_DATA_ITEM(int, i) = 123;
39
40const char rtems_test_name[] = "SMPFATAL 9";
41
42static void Init( rtems_task_argument arg )
43{
44  Heap_Area area = { .begin = NULL, .size = 0 };
45  int i;
46
47  TEST_BEGIN();
48  i = *PER_CPU_DATA_GET( _Per_CPU_Get_snapshot(), int, i );
49  RTEMS_OBFUSCATE_VARIABLE( i );
50  rtems_test_assert( i == 123 );
51
52  _Workspace_Handler_initialization( &area, 1, NULL );
53  rtems_test_assert( 0 );
54}
55
56static void fatal_extension(
57  rtems_fatal_source source,
58  bool always_set_to_false,
59  rtems_fatal_code code
60)
61{
62  if (
63    source == INTERNAL_ERROR_CORE
64      && !always_set_to_false
65      && code == INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA
66  ) {
67    TEST_END();
68  }
69}
70
71#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
72
73#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
74
75#define CONFIGURE_INITIAL_EXTENSIONS \
76  { .fatal = fatal_extension }, \
77  RTEMS_TEST_INITIAL_EXTENSION
78
79#define CONFIGURE_MAXIMUM_PROCESSORS 2
80
81#define CONFIGURE_MAXIMUM_TASKS 1
82
83#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
84
85#define CONFIGURE_INIT
86
87#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.