source: rtems/c/src/lib/libbsp/sparc64/shared/startup/bspgetworkarea.c @ b7d3a2ca

4.115
Last change on this file since b7d3a2ca was 566a1806, checked in by Joel Sherrill <joel.sherrill@…>, on 06/17/10 at 16:20:46

2010-06-17 Joel Sherrill <joel.sherrill@…>

  • ChangeLog?, Makefile.am, acinclude.m4, configure.ac, shared/asm/asm.S, shared/clock/ckinit.c, shared/console/conscfg.c, shared/helenos/LICENSE, shared/helenos/README, shared/helenos/boot/genarch/balloc.c, shared/helenos/boot/genarch/ofw.c, shared/helenos/boot/genarch/ofw_tree.c, shared/helenos/boot/generic/string.c, shared/helenos/boot/include/align.h, shared/helenos/boot/include/balloc.h, shared/helenos/boot/include/gentypes.h, shared/helenos/boot/include/main.h, shared/helenos/boot/include/ofw.h, shared/helenos/boot/include/ofw_tree.h, shared/helenos/boot/include/ofwarch.h, shared/helenos/boot/include/register.h, shared/helenos/boot/include/stack.h, shared/helenos/boot/include/types.h, shared/helenos/boot/sparc64/loader/main.c, shared/helenos/boot/sparc64/loader/ofwarch.c, shared/helenos/boot/sparc64/loader/ofwasm.S, shared/helenos/kernel/genarch/include/ofw/ofw_tree.h, shared/helenos/kernel/generic/include/align.h, shared/helenos/kernel/sparc64/include/arch.h, shared/helenos/kernel/sparc64/include/boot.h, shared/helenos/kernel/sparc64/include/regdef.h, shared/helenos/kernel/sparc64/include/stack.h, shared/helenos/kernel/sparc64/include/mm/cache_spec.h, shared/helenos/kernel/sparc64/include/mm/frame.h, shared/helenos/kernel/sparc64/include/mm/mmu.h, shared/helenos/kernel/sparc64/include/mm/page.h, shared/helenos/kernel/sparc64/include/mm/tlb.h, shared/helenos/kernel/sparc64/include/mm/tte.h, shared/helenos/kernel/sparc64/include/mm/sun4u/frame.h, shared/helenos/kernel/sparc64/include/mm/sun4u/mmu.h, shared/helenos/kernel/sparc64/include/mm/sun4u/page.h, shared/helenos/kernel/sparc64/include/mm/sun4u/tlb.h, shared/helenos/kernel/sparc64/include/mm/sun4u/tte.h, shared/helenos/kernel/sparc64/include/sun4u/arch.h, shared/helenos/kernel/sparc64/src/cache.S, shared/helenos/kernel/sparc64/src/sun4u/takemmu.S, shared/include/asm.h, shared/include/traptable.h, shared/start/start.S, shared/start/trap_table.S, shared/startup/bspgetworkarea.c, shared/startup/bspstart.c, shared/startup/linkcmds, shared/startup/setvec.c: New files.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  This routine is an implementation of the bsp_get_work_area()
3 *  that can be used by all BSPs following linkcmds conventions
4 *  regarding heap, stack, and workspace allocation.
5 *
6 *  COPYRIGHT (c) 1989-2008.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <bsp.h>
17#include <bsp/bootcard.h>
18#ifdef BSP_GET_WORK_AREA_DEBUG
19  #include <rtems/bspIo.h>
20#endif
21
22/*
23 *  These are provided by the linkcmds for ALL of the BSPs which use this file.
24 */
25extern char WorkAreaBase[];
26extern char HeapSize[];
27extern char HeapBase[];
28
29
30/*
31 *  We may get the size information from U-Boot or the linker scripts.
32 */
33#ifdef HAS_UBOOT
34  extern bd_t bsp_uboot_board_info;
35#else
36  extern char RamBase[];
37  extern char RamSize[];
38#endif /* HAS_UBOOT */
39
40/*
41 *  This method returns the base address and size of the area which
42 *  is to be allocated between the RTEMS Workspace and the C Program
43 *  Heap.
44 */
45void bsp_get_work_area(
46  void      **work_area_start,
47  uintptr_t  *work_area_size,
48  void      **heap_start,
49  uintptr_t  *heap_size
50)
51{
52  uintptr_t ram_end;
53
54  #ifdef HAS_UBOOT
55    ram_end = (uintptr_t) bsp_uboot_board_info.bi_memstart +
56                          bsp_uboot_board_info.bi_memsize;
57  #else
58    ram_end = (uintptr_t)RamBase + (uintptr_t)RamSize;
59  #endif
60
61  *work_area_start = WorkAreaBase;
62  *work_area_size  = ram_end - (uintptr_t) WorkAreaBase;
63  *heap_start      = (void*) HeapBase;
64  *heap_size       = (uintptr_t) HeapSize;
65
66  /*
67   *  The following may be helpful in debugging what goes wrong when
68   *  you are allocating the Work Area in a new BSP.
69   */
70  #ifdef BSP_GET_WORK_AREA_DEBUG
71    {
72      void *sp = __builtin_frame_address(0);
73      void *end = *work_area_start + *work_area_size;
74      printk(
75                "bsp_get_work_area\n\r"
76        "work_area_start = 0x%p\n\r"
77        "work_area_size = %d 0x%08x\n\r"
78        "end = 0x%p\n\r"
79        "heap_start = 0x%p\n\r"
80        "heap_size = %d\n\r"
81        "current stack pointer = 0x%p%s\n\r",
82        *work_area_start,
83        *work_area_size,  /* decimal */
84        *work_area_size,  /* hexadecimal */
85        end,
86        *heap_start,
87        *heap_size,
88        sp,
89        ((sp >= *work_area_start && sp <= end) ? " OVERLAPS!" : "")
90     );
91  }
92 #endif
93}
Note: See TracBrowser for help on using the repository browser.