File indexing completed on 2025-05-11 08:22:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef LIBBSP_AARCH64_SHARED_START_H
0038 #define LIBBSP_AARCH64_SHARED_START_H
0039
0040 #include <string.h>
0041
0042 #include <bsp/linker-symbols.h>
0043
0044 #ifdef __cplusplus
0045 extern "C" {
0046 #endif
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 #define BSP_START_TEXT_SECTION __attribute__((section(".bsp_start_text")))
0059
0060 #define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data")))
0061
0062
0063
0064
0065 void _start(void);
0066
0067
0068
0069
0070
0071
0072
0073
0074 void bsp_start_hook_0(void);
0075
0076
0077
0078
0079
0080
0081
0082 void bsp_start_hook_1(void);
0083
0084 BSP_START_TEXT_SECTION static inline void
0085 bsp_start_memcpy_libc(void *dest, const void *src, size_t n)
0086 {
0087 if (dest != src) {
0088 memcpy(dest, src, n);
0089 }
0090 }
0091
0092
0093
0094
0095 BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void)
0096 {
0097
0098 bsp_start_memcpy_libc(
0099 (int *) bsp_section_text_begin,
0100 (const int *) bsp_section_text_load_begin,
0101 (size_t) bsp_section_text_size
0102 );
0103
0104
0105 bsp_start_memcpy_libc(
0106 (int *) bsp_section_rodata_begin,
0107 (const int *) bsp_section_rodata_load_begin,
0108 (size_t) bsp_section_rodata_size
0109 );
0110
0111
0112 bsp_start_memcpy_libc(
0113 (int *) bsp_section_data_begin,
0114 (const int *) bsp_section_data_load_begin,
0115 (size_t) bsp_section_data_size
0116 );
0117
0118
0119 bsp_start_memcpy_libc(
0120 (int *) bsp_section_fast_text_begin,
0121 (const int *) bsp_section_fast_text_load_begin,
0122 (size_t) bsp_section_fast_text_size
0123 );
0124
0125
0126 bsp_start_memcpy_libc(
0127 (int *) bsp_section_fast_data_begin,
0128 (const int *) bsp_section_fast_data_load_begin,
0129 (size_t) bsp_section_fast_data_size
0130 );
0131 }
0132
0133
0134
0135
0136
0137
0138
0139
0140 BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections_compact(void)
0141 {
0142
0143 bsp_start_memcpy_libc(
0144 bsp_section_data_begin,
0145 bsp_section_data_load_begin,
0146 (size_t) bsp_section_data_size
0147 );
0148
0149
0150 bsp_start_memcpy_libc(
0151 bsp_section_fast_text_begin,
0152 bsp_section_fast_text_load_begin,
0153 (size_t) bsp_section_fast_text_size
0154 );
0155
0156
0157 bsp_start_memcpy_libc(
0158 bsp_section_fast_data_begin,
0159 bsp_section_fast_data_load_begin,
0160 (size_t) bsp_section_fast_data_size
0161 );
0162 }
0163
0164 BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void)
0165 {
0166 memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
0167 }
0168
0169 BSP_START_TEXT_SECTION static inline void
0170 AArch64_start_set_vector_base(void)
0171 {
0172 __asm__ volatile (
0173 "msr VBAR_EL1, %[vtable]\n"
0174 : : [vtable] "r" (bsp_start_vector_table_begin)
0175 );
0176 }
0177
0178
0179
0180 #ifdef __cplusplus
0181 }
0182 #endif
0183
0184 #endif