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.org/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. */ |
---|
21 | extern uint32_t rdb_start; |
---|
22 | |
---|
23 | /* |
---|
24 | * This method returns the base address and size of the area which |
---|
25 | * is to be allocated between the RTEMS Workspace and the C Program |
---|
26 | * Heap. |
---|
27 | */ |
---|
28 | void bsp_work_area_initialize(void) |
---|
29 | { |
---|
30 | /* must be identical to STACK_SIZE in start.S */ |
---|
31 | #define STACK_SIZE (16 * 1024) |
---|
32 | |
---|
33 | /* Early dynamic memory allocator is placed just above _end */ |
---|
34 | void *work_area_start = (void *)&end; |
---|
35 | uintptr_t work_area_size = |
---|
36 | (uintptr_t)rdb_start - (uintptr_t)&end - STACK_SIZE; |
---|
37 | |
---|
38 | /* |
---|
39 | * The following may be helpful in debugging what goes wrong when |
---|
40 | * you are allocating the Work Area in a new BSP. |
---|
41 | */ |
---|
42 | #ifdef BSP_GET_WORK_AREA_DEBUG |
---|
43 | { |
---|
44 | void *sp = __builtin_frame_address(0); |
---|
45 | void *end = *work_area_start + *work_area_size; |
---|
46 | printk( |
---|
47 | "work_area_start = 0x%p\n" |
---|
48 | "work_area_size = %d 0x%08x\n" |
---|
49 | "end = 0x%p\n" |
---|
50 | "current stack pointer = 0x%p%s\n", |
---|
51 | work_area_start, |
---|
52 | work_area_size, /* decimal */ |
---|
53 | work_area_size, /* hexadecimal */ |
---|
54 | end, |
---|
55 | sp, |
---|
56 | ((sp >= *work_area_start && sp <= end) ? " OVERLAPS!" : "") |
---|
57 | ); |
---|
58 | printk( "rdb_start = 0x%08x\n", rdb_start ); |
---|
59 | } |
---|
60 | #endif |
---|
61 | |
---|
62 | bsp_work_area_initialize_default(work_area_start, work_area_size); |
---|
63 | } |
---|