RTEMS 6.1-rc7
Loading...
Searching...
No Matches
start.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2008, 2013 embedded brains GmbH & Co. KG
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef LIBBSP_ARM_SHARED_START_H
37#define LIBBSP_ARM_SHARED_START_H
38
39#include <string.h>
40
41#include <bsp/linker-symbols.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
57#define BSP_START_TEXT_SECTION __attribute__((section(".bsp_start_text")))
58
59#define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data")))
60
64void _start(void);
65
73void bsp_start_hook_0(void);
74
80
87void bsp_start_hook_1(void);
88
95void bsp_start_memcpy(int *dest, const int *src, size_t n);
96
100void bsp_start_memcpy_arm(int *dest, const int *src, size_t n);
101
105BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void)
106{
107 /* Copy .text section */
109 (int *) bsp_section_text_begin,
110 (const int *) bsp_section_text_load_begin,
111 (size_t) bsp_section_text_size
112 );
113
114 /* Copy .rodata section */
116 (int *) bsp_section_rodata_begin,
117 (const int *) bsp_section_rodata_load_begin,
118 (size_t) bsp_section_rodata_size
119 );
120
121 /* Copy .data section */
123 (int *) bsp_section_data_begin,
124 (const int *) bsp_section_data_load_begin,
125 (size_t) bsp_section_data_size
126 );
127
128 /* Copy .fast_text section */
130 (int *) bsp_section_fast_text_begin,
131 (const int *) bsp_section_fast_text_load_begin,
132 (size_t) bsp_section_fast_text_size
133 );
134
135 /* Copy .fast_data section */
137 (int *) bsp_section_fast_data_begin,
138 (const int *) bsp_section_fast_data_load_begin,
139 (size_t) bsp_section_fast_data_size
140 );
141}
142
143BSP_START_TEXT_SECTION static inline void
144bsp_start_memcpy_libc(void *dest, const void *src, size_t n)
145{
146 if (dest != src) {
147 memcpy(dest, src, n);
148 }
149}
150
158BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections_compact(void)
159{
160 /* Copy .data section */
161 bsp_start_memcpy_libc(
162 bsp_section_data_begin,
163 bsp_section_data_load_begin,
164 (size_t) bsp_section_data_size
165 );
166
167 /* Copy .fast_text section */
168 bsp_start_memcpy_libc(
169 bsp_section_fast_text_begin,
170 bsp_section_fast_text_load_begin,
171 (size_t) bsp_section_fast_text_size
172 );
173
174 /* Copy .fast_data section */
175 bsp_start_memcpy_libc(
176 bsp_section_fast_data_begin,
177 bsp_section_fast_data_load_begin,
178 (size_t) bsp_section_fast_data_size
179 );
180}
181
182BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void)
183{
184 memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
185}
186
189#ifdef __cplusplus
190}
191#endif /* __cplusplus */
192
193#endif /* LIBBSP_ARM_SHARED_START_H */
void bsp_start_hook_1(void)
Start entry hook 1.
Definition: bspstarthooks.c:47
void _start(void)
System start entry.
void bsp_start_hook_0(void)
Start entry hook 0.
Definition: bspstarthooks.c:49
void bsp_start_memcpy_arm(int *dest, const int *src, size_t n)
ARM entry point to bsp_start_memcpy().
void bsp_start_memcpy(int *dest, const int *src, size_t n)
Similar to standard memcpy().
void bsp_start_hook_0_done(void)
Can be used by bsp_start_hook_0() to jump back to the start code instead of using the link register.
This header file provides interfaces to BSP-specific linker symbols and sections.