RTEMS  5.1
start.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2008-2013 embedded brains GmbH. All rights reserved.
11  *
12  * embedded brains GmbH
13  * Obere Lagerstr. 30
14  * 82178 Puchheim
15  * Germany
16  * <rtems@embedded-brains.de>
17  *
18  * The license and distribution terms for this file may be
19  * found in the file LICENSE in this distribution or at
20  * http://www.rtems.org/license/LICENSE.
21  */
22 
23 #ifndef LIBBSP_ARM_SHARED_START_H
24 #define LIBBSP_ARM_SHARED_START_H
25 
26 #include <string.h>
27 
28 #include <bsp/linker-symbols.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
44 #define BSP_START_TEXT_SECTION __attribute__((section(".bsp_start_text")))
45 
46 #define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data")))
47 
48 /*
49 * Many ARM boot loaders pass arguments to loaded OS kernel
50 */
51 #ifdef BSP_START_HOOKS_WITH_LOADER_ARGS
52 #define BSP_START_HOOKS_LOADER_ARGS int saved_psr, int saved_machid, int saved_dtb_adr
53 #else
54 #define BSP_START_HOOKS_LOADER_ARGS void
55 #endif
56 
60 void _start(void);
61 
69 void bsp_start_hook_0(BSP_START_HOOKS_LOADER_ARGS);
70 
77 void bsp_start_hook_1(BSP_START_HOOKS_LOADER_ARGS);
78 
85 void bsp_start_memcpy(int *dest, const int *src, size_t n);
86 
90 void bsp_start_memcpy_arm(int *dest, const int *src, size_t n);
91 
95 BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void)
96 {
97  /* Copy .text section */
99  (int *) bsp_section_text_begin,
100  (const int *) bsp_section_text_load_begin,
101  (size_t) bsp_section_text_size
102  );
103 
104  /* Copy .rodata section */
106  (int *) bsp_section_rodata_begin,
107  (const int *) bsp_section_rodata_load_begin,
108  (size_t) bsp_section_rodata_size
109  );
110 
111  /* Copy .data section */
113  (int *) bsp_section_data_begin,
114  (const int *) bsp_section_data_load_begin,
115  (size_t) bsp_section_data_size
116  );
117 
118  /* Copy .fast_text section */
120  (int *) bsp_section_fast_text_begin,
121  (const int *) bsp_section_fast_text_load_begin,
122  (size_t) bsp_section_fast_text_size
123  );
124 
125  /* Copy .fast_data section */
127  (int *) bsp_section_fast_data_begin,
128  (const int *) bsp_section_fast_data_load_begin,
129  (size_t) bsp_section_fast_data_size
130  );
131 }
132 
133 BSP_START_TEXT_SECTION static inline void
134 bsp_start_memcpy_libc(void *dest, const void *src, size_t n)
135 {
136  if (dest != src) {
137  memcpy(dest, src, n);
138  }
139 }
140 
148 BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections_compact(void)
149 {
150  /* Copy .data section */
151  bsp_start_memcpy_libc(
152  bsp_section_data_begin,
153  bsp_section_data_load_begin,
154  (size_t) bsp_section_data_size
155  );
156 
157  /* Copy .fast_text section */
158  bsp_start_memcpy_libc(
159  bsp_section_fast_text_begin,
160  bsp_section_fast_text_load_begin,
161  (size_t) bsp_section_fast_text_size
162  );
163 
164  /* Copy .fast_data section */
165  bsp_start_memcpy_libc(
166  bsp_section_fast_data_begin,
167  bsp_section_fast_data_load_begin,
168  (size_t) bsp_section_fast_data_size
169  );
170 }
171 
172 BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void)
173 {
174  memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
175 }
176 
179 #ifdef __cplusplus
180 }
181 #endif /* __cplusplus */
182 
183 #endif /* LIBBSP_ARM_SHARED_START_H */
void _start(void)
System start entry.
void bsp_start_hook_0(BSP_START_HOOKS_LOADER_ARGS)
Start entry hook 0.
void bsp_start_memcpy(int *dest, const int *src, size_t n)
Similar to standard memcpy().
void bsp_start_hook_1(BSP_START_HOOKS_LOADER_ARGS)
Start entry hook 1.
void bsp_start_memcpy_arm(int *dest, const int *src, size_t n)
ARM entry point to bsp_start_memcpy().