source: rtems/c/src/lib/libbsp/sparc/shared/bspgetworkarea.c @ 47a3cd8

4.115
Last change on this file since 47a3cd8 was 47a3cd8, checked in by Sebastian Huber <sebastian.huber@…>, on 08/09/12 at 14:48:00

score: Work area initialization API change

The work areas (RTEMS work space and C program heap) will be initialized
now in a separate step and are no longer part of
rtems_initialize_data_structures(). Initialization is performed with
tables of Heap_Area entries. This allows usage of scattered memory
areas present on various small scale micro-controllers.

The sbrk() support API changes also. The bsp_sbrk_init() must now deal
with a minimum size for the first memory chunk to take the configured
work space size into account.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  This set of routines are the BSP specific initialization
3 *  support routines.
4 *
5 *  COPYRIGHT (c) 1989-2008.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 */
12
13/* #define BSP_GET_WORK_AREA_DEBUG */
14#include <bsp.h>
15#include <bsp/bootcard.h>
16#ifdef BSP_GET_WORK_AREA_DEBUG
17  #include <rtems/bspIo.h>
18#endif
19
20/* Tells us where to put the workspace in case remote debugger is present.  */
21extern uint32_t rdb_start;
22
23/* Must be aligned to 8, _end is aligned to 8 */
24unsigned int early_mem = (unsigned int)&end;
25
26/*
27 *  This method returns the base address and size of the area which
28 *  is to be allocated between the RTEMS Workspace and the C Program
29 *  Heap.
30 */
31void bsp_work_area_initialize(void)
32{
33  /* must be identical to STACK_SIZE in start.S */
34  #define STACK_SIZE (16 * 1024)
35
36  /* Early dynamic memory allocator is placed just above _end  */
37  void *work_area_start = (void *)early_mem;
38  uintptr_t work_area_size  =
39    (uintptr_t)rdb_start - (uintptr_t)early_mem - STACK_SIZE;
40  early_mem        = ~0; /* Signal bsp_early_malloc not to be used anymore */
41
42  /*
43   *  The following may be helpful in debugging what goes wrong when
44   *  you are allocating the Work Area in a new BSP.
45   */
46  #ifdef BSP_GET_WORK_AREA_DEBUG
47    {
48      void *sp = __builtin_frame_address(0);
49      void *end = *work_area_start + *work_area_size;
50      printk(
51        "work_area_start = 0x%p\n"
52        "work_area_size = %d 0x%08x\n"
53        "end = 0x%p\n"
54        "current stack pointer = 0x%p%s\n",
55        work_area_start,
56        work_area_size,  /* decimal */
57        work_area_size,  /* hexadecimal */
58        end,
59        sp,
60        ((sp >= *work_area_start && sp <= end) ? " OVERLAPS!" : "")
61     );
62     printk( "rdb_start = 0x%08x\n", rdb_start );
63   }
64 #endif
65
66  bsp_work_area_initialize_default(work_area_start, work_area_size);
67}
Note: See TracBrowser for help on using the repository browser.