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 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | /* #define BSP_GET_WORK_AREA_DEBUG */ |
---|
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 | /* Tells us where to put the workspace in case remote debugger is present. */ |
---|
23 | extern uint32_t rdb_start; |
---|
24 | |
---|
25 | /* |
---|
26 | * This method returns the base address and size of the area which |
---|
27 | * is to be allocated between the RTEMS Workspace and the C Program |
---|
28 | * Heap. |
---|
29 | */ |
---|
30 | void bsp_get_work_area( |
---|
31 | void **work_area_start, |
---|
32 | uintptr_t *work_area_size, |
---|
33 | void **heap_start, |
---|
34 | uintptr_t *heap_size |
---|
35 | ) |
---|
36 | { |
---|
37 | /* must be identical to STACK_SIZE in start.S */ |
---|
38 | #define STACK_SIZE (16 * 1024) |
---|
39 | |
---|
40 | *work_area_start = &end; |
---|
41 | *work_area_size = (void *)rdb_start - (void *)&end - STACK_SIZE; |
---|
42 | *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA; |
---|
43 | *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT; |
---|
44 | |
---|
45 | /* |
---|
46 | * The following may be helpful in debugging what goes wrong when |
---|
47 | * you are allocating the Work Area in a new BSP. |
---|
48 | */ |
---|
49 | #ifdef BSP_GET_WORK_AREA_DEBUG |
---|
50 | { |
---|
51 | void *sp = __builtin_frame_address(0); |
---|
52 | void *end = *work_area_start + *work_area_size; |
---|
53 | printk( |
---|
54 | "work_area_start = 0x%p\n" |
---|
55 | "work_area_size = %d 0x%08x\n" |
---|
56 | "end = 0x%p\n" |
---|
57 | "heap_start = 0x%p\n" |
---|
58 | "heap_size = %d\n" |
---|
59 | "current stack pointer = 0x%p%s\n", |
---|
60 | *work_area_start, |
---|
61 | *work_area_size, /* decimal */ |
---|
62 | *work_area_size, /* hexadecimal */ |
---|
63 | end, |
---|
64 | *heap_start, |
---|
65 | *heap_size, |
---|
66 | sp, |
---|
67 | ((sp >= *work_area_start && sp <= end) ? " OVERLAPS!" : "") |
---|
68 | ); |
---|
69 | printk( "rdb_start = 0x%08x\n", rdb_start ); |
---|
70 | } |
---|
71 | #endif |
---|
72 | } |
---|