[8dcfc0a] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
[091705c] | 4 | * @ingroup bsp_start |
---|
| 5 | * |
---|
| 6 | * @brief System low level start. |
---|
[8dcfc0a] | 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
[fb0584f] | 10 | * Copyright (c) 2008-2013 embedded brains GmbH. All rights reserved. |
---|
[4c622e5] | 11 | * |
---|
| 12 | * embedded brains GmbH |
---|
| 13 | * Obere Lagerstr. 30 |
---|
| 14 | * 82178 Puchheim |
---|
| 15 | * Germany |
---|
| 16 | * <rtems@embedded-brains.de> |
---|
[8dcfc0a] | 17 | * |
---|
[091705c] | 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.com/license/LICENSE. |
---|
[8dcfc0a] | 21 | */ |
---|
| 22 | |
---|
| 23 | #ifndef LIBBSP_ARM_SHARED_START_H |
---|
| 24 | #define LIBBSP_ARM_SHARED_START_H |
---|
| 25 | |
---|
[fb0584f] | 26 | #include <string.h> |
---|
| 27 | |
---|
| 28 | #include <bsp/linker-symbols.h> |
---|
[8dcfc0a] | 29 | |
---|
[c3dd440] | 30 | #ifdef __cplusplus |
---|
| 31 | extern "C" { |
---|
| 32 | #endif /* __cplusplus */ |
---|
| 33 | |
---|
[091705c] | 34 | /** |
---|
| 35 | * @defgroup bsp_start System Start |
---|
| 36 | * |
---|
| 37 | * @ingroup bsp_kit |
---|
| 38 | * |
---|
| 39 | * @brief System low level start. |
---|
| 40 | * |
---|
| 41 | * @{ |
---|
| 42 | */ |
---|
[9647f7fe] | 43 | |
---|
[a3579d3b] | 44 | #define BSP_START_TEXT_SECTION __attribute__((section(".bsp_start_text"))) |
---|
[c3dd440] | 45 | |
---|
| 46 | #define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data"))) |
---|
| 47 | |
---|
[091705c] | 48 | /** |
---|
| 49 | * @brief System start entry. |
---|
| 50 | */ |
---|
[a3579d3b] | 51 | void _start(void); |
---|
[8dcfc0a] | 52 | |
---|
[091705c] | 53 | /** |
---|
| 54 | * @brief Start entry hook 0. |
---|
| 55 | * |
---|
| 56 | * This hook will be called from the start entry code after all modes and |
---|
| 57 | * stack pointers are initialized but before the copying of the exception |
---|
| 58 | * vectors. |
---|
| 59 | */ |
---|
| 60 | void bsp_start_hook_0(void); |
---|
[8dcfc0a] | 61 | |
---|
[091705c] | 62 | /** |
---|
| 63 | * @brief Start entry hook 1. |
---|
| 64 | * |
---|
| 65 | * This hook will be called from the start entry code after copying of the |
---|
| 66 | * exception vectors but before the call to boot_card(). |
---|
| 67 | */ |
---|
| 68 | void bsp_start_hook_1(void); |
---|
[8dcfc0a] | 69 | |
---|
[091705c] | 70 | /** |
---|
| 71 | * @brief Similar to standard memcpy(). |
---|
| 72 | * |
---|
| 73 | * The memory areas must be word aligned. Copy code will be executed from the |
---|
| 74 | * stack. If @a dest equals @a src nothing will be copied. |
---|
| 75 | */ |
---|
| 76 | void bsp_start_memcpy(int *dest, const int *src, size_t n); |
---|
[8dcfc0a] | 77 | |
---|
[091705c] | 78 | /** |
---|
| 79 | * @brief ARM entry point to bsp_start_memcpy(). |
---|
| 80 | */ |
---|
| 81 | void bsp_start_memcpy_arm(int *dest, const int *src, size_t n); |
---|
[8dcfc0a] | 82 | |
---|
[4c622e5] | 83 | /** |
---|
| 84 | * @brief Copies all standard sections from the load to the runtime area. |
---|
| 85 | */ |
---|
[fb0584f] | 86 | BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void) |
---|
| 87 | { |
---|
| 88 | /* Copy .text section */ |
---|
| 89 | bsp_start_memcpy( |
---|
| 90 | (int *) bsp_section_text_begin, |
---|
| 91 | (const int *) bsp_section_text_load_begin, |
---|
| 92 | (size_t) bsp_section_text_size |
---|
| 93 | ); |
---|
| 94 | |
---|
| 95 | /* Copy .rodata section */ |
---|
| 96 | bsp_start_memcpy( |
---|
| 97 | (int *) bsp_section_rodata_begin, |
---|
| 98 | (const int *) bsp_section_rodata_load_begin, |
---|
| 99 | (size_t) bsp_section_rodata_size |
---|
| 100 | ); |
---|
| 101 | |
---|
| 102 | /* Copy .data section */ |
---|
| 103 | bsp_start_memcpy( |
---|
| 104 | (int *) bsp_section_data_begin, |
---|
| 105 | (const int *) bsp_section_data_load_begin, |
---|
| 106 | (size_t) bsp_section_data_size |
---|
| 107 | ); |
---|
| 108 | |
---|
| 109 | /* Copy .fast_text section */ |
---|
| 110 | bsp_start_memcpy( |
---|
| 111 | (int *) bsp_section_fast_text_begin, |
---|
| 112 | (const int *) bsp_section_fast_text_load_begin, |
---|
| 113 | (size_t) bsp_section_fast_text_size |
---|
| 114 | ); |
---|
| 115 | |
---|
| 116 | /* Copy .fast_data section */ |
---|
| 117 | bsp_start_memcpy( |
---|
| 118 | (int *) bsp_section_fast_data_begin, |
---|
| 119 | (const int *) bsp_section_fast_data_load_begin, |
---|
| 120 | (size_t) bsp_section_fast_data_size |
---|
| 121 | ); |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void) |
---|
| 125 | { |
---|
| 126 | memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size); |
---|
| 127 | } |
---|
[4c622e5] | 128 | |
---|
[091705c] | 129 | /** @} */ |
---|
[8dcfc0a] | 130 | |
---|
[c3dd440] | 131 | #ifdef __cplusplus |
---|
| 132 | } |
---|
| 133 | #endif /* __cplusplus */ |
---|
| 134 | |
---|
[8dcfc0a] | 135 | #endif /* LIBBSP_ARM_SHARED_START_H */ |
---|