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) 2020 On-Line Applications Research Corporation (OAR)
13 * Written by Kinsey Moore <kinsey.moore@oarcorp.com>
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef LIBBSP_AARCH64_SHARED_START_H
38#define LIBBSP_AARCH64_SHARED_START_H
39
40#include <string.h>
41
42#include <bsp/linker-symbols.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif /* __cplusplus */
47
58#define BSP_START_TEXT_SECTION __attribute__((section(".bsp_start_text")))
59
60#define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data")))
61
65void _start(void);
66
74void bsp_start_hook_0(void);
75
82void bsp_start_hook_1(void);
83
84BSP_START_TEXT_SECTION static inline void
85bsp_start_memcpy_libc(void *dest, const void *src, size_t n)
86{
87 if (dest != src) {
88 memcpy(dest, src, n);
89 }
90}
91
95BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void)
96{
97 /* Copy .text section */
98 bsp_start_memcpy_libc(
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 */
105 bsp_start_memcpy_libc(
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 */
112 bsp_start_memcpy_libc(
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 */
119 bsp_start_memcpy_libc(
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 */
126 bsp_start_memcpy_libc(
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
140BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections_compact(void)
141{
142 /* Copy .data section */
143 bsp_start_memcpy_libc(
144 bsp_section_data_begin,
145 bsp_section_data_load_begin,
146 (size_t) bsp_section_data_size
147 );
148
149 /* Copy .fast_text section */
150 bsp_start_memcpy_libc(
151 bsp_section_fast_text_begin,
152 bsp_section_fast_text_load_begin,
153 (size_t) bsp_section_fast_text_size
154 );
155
156 /* Copy .fast_data section */
157 bsp_start_memcpy_libc(
158 bsp_section_fast_data_begin,
159 bsp_section_fast_data_load_begin,
160 (size_t) bsp_section_fast_data_size
161 );
162}
163
164BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void)
165{
166 memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
167}
168
169BSP_START_TEXT_SECTION static inline void
170AArch64_start_set_vector_base(void)
171{
172 __asm__ volatile (
173 "msr VBAR_EL1, %[vtable]\n"
174 : : [vtable] "r" (bsp_start_vector_table_begin)
175 );
176}
177
180#ifdef __cplusplus
181}
182#endif /* __cplusplus */
183
184#endif /* LIBBSP_AARCH64_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
This header file provides interfaces to BSP-specific linker symbols and sections.