source: rtems/bsps/arm/include/bsp/start.h @ ba619b7f

Last change on this file since ba619b7f was ba619b7f, checked in by Joel Sherrill <joel@…>, on 03/01/22 at 21:38:20

bsps/arm/: Scripted embedded brains header file clean up

Updates #4625.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup arm_start
5 *
6 * @brief ARM system low level start.
7 */
8
9/*
10 * Copyright (c) 2008-2013 embedded brains GmbH.  All rights reserved.
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef LIBBSP_ARM_SHARED_START_H
18#define LIBBSP_ARM_SHARED_START_H
19
20#include <string.h>
21
22#include <bsp/linker-symbols.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif /* __cplusplus */
27
28/**
29 * @defgroup arm_start System Start
30 *
31 * @ingroup RTEMSBSPsARMShared
32 *
33 * @brief ARM system low level start.
34 *
35 * @{
36 */
37
38#define BSP_START_TEXT_SECTION __attribute__((section(".bsp_start_text")))
39
40#define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data")))
41
42/**
43* @brief System start entry.
44*/
45void _start(void);
46
47/**
48* @brief Start entry hook 0.
49*
50* This hook will be called from the start entry code after all modes and
51* stack pointers are initialized but before the copying of the exception
52* vectors.
53*/
54void bsp_start_hook_0(void);
55
56/**
57* @brief Start entry hook 1.
58*
59* This hook will be called from the start entry code after copying of the
60* exception vectors but before the call to boot_card().
61*/
62void bsp_start_hook_1(void);
63
64/**
65 * @brief Similar to standard memcpy().
66 *
67 * The memory areas must be word aligned.  Copy code will be executed from the
68 * stack.  If @a dest equals @a src nothing will be copied.
69 */
70void bsp_start_memcpy(int *dest, const int *src, size_t n);
71
72/**
73 * @brief ARM entry point to bsp_start_memcpy().
74 */
75void bsp_start_memcpy_arm(int *dest, const int *src, size_t n);
76
77/**
78 * @brief Copies all standard sections from the load to the runtime area.
79 */
80BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void)
81{
82  /* Copy .text section */
83  bsp_start_memcpy(
84    (int *) bsp_section_text_begin,
85    (const int *) bsp_section_text_load_begin,
86    (size_t) bsp_section_text_size
87  );
88
89  /* Copy .rodata section */
90  bsp_start_memcpy(
91    (int *) bsp_section_rodata_begin,
92    (const int *) bsp_section_rodata_load_begin,
93    (size_t) bsp_section_rodata_size
94  );
95
96  /* Copy .data section */
97  bsp_start_memcpy(
98    (int *) bsp_section_data_begin,
99    (const int *) bsp_section_data_load_begin,
100    (size_t) bsp_section_data_size
101  );
102
103  /* Copy .fast_text section */
104  bsp_start_memcpy(
105    (int *) bsp_section_fast_text_begin,
106    (const int *) bsp_section_fast_text_load_begin,
107    (size_t) bsp_section_fast_text_size
108  );
109
110  /* Copy .fast_data section */
111  bsp_start_memcpy(
112    (int *) bsp_section_fast_data_begin,
113    (const int *) bsp_section_fast_data_load_begin,
114    (size_t) bsp_section_fast_data_size
115  );
116}
117
118BSP_START_TEXT_SECTION static inline void
119bsp_start_memcpy_libc(void *dest, const void *src, size_t n)
120{
121  if (dest != src) {
122    memcpy(dest, src, n);
123  }
124}
125
126/**
127 * @brief Copies the .data, .fast_text and .fast_data sections from the load to
128 * the runtime area using the C library memcpy().
129 *
130 * Works only in case the .start, .text and .rodata sections reside in one
131 * memory region.
132 */
133BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections_compact(void)
134{
135  /* Copy .data section */
136  bsp_start_memcpy_libc(
137    bsp_section_data_begin,
138    bsp_section_data_load_begin,
139    (size_t) bsp_section_data_size
140  );
141
142  /* Copy .fast_text section */
143  bsp_start_memcpy_libc(
144    bsp_section_fast_text_begin,
145    bsp_section_fast_text_load_begin,
146    (size_t) bsp_section_fast_text_size
147  );
148
149  /* Copy .fast_data section */
150  bsp_start_memcpy_libc(
151    bsp_section_fast_data_begin,
152    bsp_section_fast_data_load_begin,
153    (size_t) bsp_section_fast_data_size
154  );
155}
156
157BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void)
158{
159  memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
160}
161
162/** @} */
163
164#ifdef __cplusplus
165}
166#endif /* __cplusplus */
167
168#endif /* LIBBSP_ARM_SHARED_START_H */
Note: See TracBrowser for help on using the repository browser.