source: rtems/bsps/shared/start/bspgetworkarea-default.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.6 KB
Line 
1/**
2 * @file
3 *
4 * This routine is an implementation of the _Memory_Get()
5 * that can be used by all BSPs following linkcmds conventions
6 * regarding heap, stack, and workspace allocation.
7 */
8
9/*
10 * COPYRIGHT (c) 1989-2008.
11 * On-Line Applications Research Corporation (OAR).
12 *
13 * Copyright (c) 2011-2012 embedded brains GmbH.
14 *
15 * The license and distribution terms for this file may be
16 * found in the file LICENSE in this distribution or at
17 * http://www.rtems.org/license/LICENSE.
18 */
19
20#include <bsp.h>
21#include <bsp/bootcard.h>
22
23#if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG)
24  #define USE_UBOOT
25#endif
26
27/*
28 *  These are provided by the linkcmds for ALL of the BSPs which use this file.
29 */
30extern char WorkAreaBase[];
31
32/*
33 *  We may get the size information from U-Boot or the linker scripts.
34 */
35#ifdef USE_UBOOT
36#include <bsp/u-boot.h>
37#include <rtems/sysinit.h>
38
39static Memory_Area _Memory_Areas[ 1 ];
40
41static void bsp_memory_initialize( void )
42{
43  char *end;
44
45  end = (char *) bsp_uboot_board_info.bi_memstart
46    + bsp_uboot_board_info.bi_memsize;
47  _Memory_Initialize( &_Memory_Areas[ 0 ], WorkAreaBase, end );
48}
49
50RTEMS_SYSINIT_ITEM(
51  bsp_memory_initialize,
52  RTEMS_SYSINIT_MEMORY,
53  RTEMS_SYSINIT_ORDER_MIDDLE
54);
55#else /* !USE_UBOOT */
56extern char RamEnd[];
57
58static Memory_Area _Memory_Areas[] = {
59  MEMORY_INITIALIZER(WorkAreaBase, RamEnd)
60};
61#endif /* USE_UBOOT */
62
63static const Memory_Information _Memory_Information =
64  MEMORY_INFORMATION_INITIALIZER( _Memory_Areas );
65
66const Memory_Information *_Memory_Get( void )
67{
68  return &_Memory_Information;
69}
Note: See TracBrowser for help on using the repository browser.