summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/shared/bspgetworkarea.c
blob: 302fc0f335b8b20d50cb442c37132aa32f3fd3be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * @file
 *
 * This routine is an implementation of the bsp_work_area_initialize()
 * that can be used by all BSPs following linkcmds conventions
 * regarding heap, stack, and workspace allocation.
 */

/*
 * COPYRIGHT (c) 1989-2008.
 * On-Line Applications Research Corporation (OAR).
 *
 * Copyright (c) 2011-2012 embedded brains GmbH.
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <bsp.h>
#include <bsp/bootcard.h>
#ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN
  #include <rtems/config.h>
#endif

#if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG)
  #define USE_UBOOT
#endif

/*
 *  These are provided by the linkcmds for ALL of the BSPs which use this file.
 */
extern char WorkAreaBase[];

/*
 *  We may get the size information from U-Boot or the linker scripts.
 */
#ifdef USE_UBOOT
  #include <bsp/u-boot.h>
#else
  extern char RamBase[];
  extern char RamSize[];
#endif

void bsp_work_area_initialize(void)
{
  uintptr_t work_base = (uintptr_t) WorkAreaBase;
  uintptr_t ram_end;

  #ifdef USE_UBOOT
    ram_end = (uintptr_t) bsp_uboot_board_info.bi_memstart +
                          bsp_uboot_board_info.bi_memsize;
  #else
    ram_end = (uintptr_t)RamBase + (uintptr_t)RamSize;
  #endif

  #ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN
    work_base += rtems_configuration_get_interrupt_stack_size();
  #endif

  bsp_work_area_initialize_default( (void *) work_base, ram_end - work_base );
}