RTEMS  5.0.0
bootcard.h
Go to the documentation of this file.
1 
7 /*
8  * Copyright (c) 2008-2014 embedded brains GmbH. All rights reserved.
9  *
10  * embedded brains GmbH
11  * Dornierstr. 4
12  * 82178 Puchheim
13  * Germany
14  * <rtems@embedded-brains.de>
15  *
16  * The license and distribution terms for this file may be
17  * found in the file LICENSE in this distribution or at
18  * http://www.rtems.org/license/LICENSE.
19  */
20 
21 #ifndef LIBBSP_SHARED_BOOTCARD_H
22 #define LIBBSP_SHARED_BOOTCARD_H
23 
24 #include <string.h>
25 
26 #include <rtems/config.h>
27 #include <rtems/bspIo.h>
28 #include <rtems/malloc.h>
29 #include <rtems/score/wkspace.h>
30 
31 #include <bspopts.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36 
50 extern const char *bsp_boot_cmdline;
51 
52 void bsp_start(void);
53 
54 void bsp_reset(void);
55 
72 void boot_card(const char *cmdline) RTEMS_NO_RETURN;
73 
74 #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
75 
86  ptrdiff_t bsp_sbrk_init(Heap_Area *area, uintptr_t min_size);
87 #endif
88 
89 static inline void bsp_work_area_initialize_default(
90  void *area_begin,
91  uintptr_t area_size
92 )
93 {
94  Heap_Area area = {
95  .begin = area_begin,
96  .size = area_size
97  };
98 
99  #if BSP_DIRTY_MEMORY == 1
100  memset(area.begin, 0xCF, area.size);
101  #endif
102 
103  #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
104  {
105  uintptr_t overhead = _Heap_Area_overhead(CPU_HEAP_ALIGNMENT);
106  uintptr_t work_space_size = rtems_configuration_get_work_space_size();
107  ptrdiff_t sbrk_amount = bsp_sbrk_init(
108  &area,
109  work_space_size
110  + overhead
111  + (rtems_configuration_get_unified_work_area() ? 0 : overhead)
112  );
113 
114  rtems_heap_set_sbrk_amount(sbrk_amount);
115  }
116  #endif
117 
118  /*
119  * The following may be helpful in debugging what goes wrong when
120  * you are allocating the Work Area in a new BSP.
121  */
122  #ifdef BSP_GET_WORK_AREA_DEBUG
123  {
124  void *sp = __builtin_frame_address(0);
125  void *end = (char *) area.begin + area.size;
126  printk(
127  "work_area_start = 0x%p\n"
128  "work_area_size = %lu 0x%08lx\n"
129  "end = 0x%p\n"
130  "current stack pointer = 0x%p%s\n",
131  area.begin,
132  (unsigned long) area.size, /* decimal */
133  (unsigned long) area.size, /* hexadecimal */
134  end,
135  sp,
136  (uintptr_t) sp >= (uintptr_t) area.begin
137  && (uintptr_t) sp <= (uintptr_t) end ?
138  " OVERLAPS!" : ""
139  );
140  }
141  #endif
142 
144 
145  #ifdef BSP_GET_WORK_AREA_DEBUG
146  printk(
147  "heap_start = 0x%p\n"
148  "heap_size = %lu\n",
149  area.begin,
150  (unsigned long) area.size
151  );
152  #endif
153 
154  RTEMS_Malloc_Initialize(&area, 1, NULL);
155 }
156 
157 static inline void bsp_work_area_initialize_with_table(
158  Heap_Area *areas,
159  size_t area_count
160 )
161 {
163  RTEMS_Malloc_Initialize(areas, area_count, _Heap_Extend);
164 }
165 
166 void bsp_work_area_initialize(void);
167 
168 struct Per_CPU_Control;
169 
179 
182 #ifdef __cplusplus
183 }
184 #endif /* __cplusplus */
185 
186 #endif /* LIBBSP_SHARED_BOOTCARD_H */
const char * bsp_boot_cmdline
Global pointer to the command line of boot_card().
Definition: bootcard.c:25
#define sp
stack-pointer */
Definition: regs.h:64
RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead(uintptr_t page_size)
Returns the worst case overhead to manage a memory area.
Definition: heap.h:359
Heap area structure for table based heap initialization and extension.
Definition: heap.h:275
void _Workspace_Handler_initialization(Heap_Area *areas, size_t area_count, Heap_Initialization_or_extend_handler extend)
Initilize workspace handler.
Definition: wkspace.c:155
Per CPU Core Structure.
Definition: percpu.h:290
Information Related to the RAM Workspace.
void bsp_start_on_secondary_processor(struct Per_CPU_Control *cpu_self)
Standard start routine for secondary processors.
Definition: bspsmp.c:85
#define RTEMS_NO_RETURN
Definition: basedefs.h:101
Interface to Kernel Print Methods.
void boot_card(const char *cmdline) RTEMS_NO_RETURN
Standard system initialization procedure.
Definition: bootcard.c:45
uintptr_t _Heap_Extend(Heap_Control *heap, void *area_begin, uintptr_t area_size, uintptr_t unused)
Extends the memory available for the heap heap using the memory area starting at area_begin of size a...
Definition: heapextend.c:119
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
int printk(const char *fmt,...) RTEMS_PRINTFLIKE(1
Kernel Print.