summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/gen5200/startup/bspgetworkarea.c
blob: 935088ed06db77d657146c5cf53ae53b2e3619c9 (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
/*
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id$
 */

#include <bsp.h>
#include <bsp/bootcard.h>
#include <stdint.h>

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

#if defined(HAS_UBOOT)
  extern bd_t *uboot_bdinfo_ptr;
#endif

/*
 *  This method returns the base address and size of the area which
 *  is to be allocated between the RTEMS Workspace and the C Program
 *  Heap.
 */

void bsp_get_work_area(
  void   **work_area_start,
  size_t  *work_area_size,
  void   **heap_start,
  size_t  *heap_size
)
{
  #ifdef HAS_UBOOT
    char *ram_end = (char *) uboot_bdinfo_ptr->bi_memstart +
                                 uboot_bdinfo_ptr->bi_memsize;
  #else /* HAS_UBOOT */
    char *ram_end = (uintptr_t)RamBase + (uintptr_t)RamSize;
  #endif /* HAS_UBOOT */

  *work_area_start = bsp_work_area_start;
  *work_area_size = ram_end - bsp_work_area_start;
  *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
  *heap_size = HeapSize;
}