blob: 33d06702057b6da02b3e0303a503ac4fe9044767 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <bspopts.h>
#include <bsp/start.h>
#include <bsp/linker-symbols.h>
static void BSP_START_TEXT_SECTION copy(int *dst, const int *src, int n)
{
if (src != dst) {
const int *end = dst + (n + sizeof(int) - 1) / sizeof(int);
while (dst != end) {
*dst = *src;
++src;
++dst;
}
}
}
static void BSP_START_TEXT_SECTION clear_bss(void)
{
int *dst = (int *) bsp_section_bss_begin;
int n = (int) bsp_section_bss_size;
const int *end = dst + (n + sizeof(int) - 1) / sizeof(int);
while (dst != end) {
*dst = 0;
++dst;
}
}
void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
{
/* Copy .text section */
copy(
(int *) bsp_section_text_begin,
(const int *) bsp_section_text_load_begin,
(size_t) bsp_section_text_size
);
/* Copy .rodata section */
copy(
(int *) bsp_section_rodata_begin,
(const int *) bsp_section_rodata_load_begin,
(size_t) bsp_section_rodata_size
);
/* Copy .data section */
copy(
(int *) bsp_section_data_begin,
(const int *) bsp_section_data_load_begin,
(size_t) bsp_section_data_size
);
/* Copy .fast_text section */
copy(
(int *) bsp_section_fast_text_begin,
(const int *) bsp_section_fast_text_load_begin,
(size_t) bsp_section_fast_text_size
);
/* Copy .fast_data section */
copy(
(int *) bsp_section_fast_data_begin,
(const int *) bsp_section_fast_data_load_begin,
(size_t) bsp_section_fast_data_size
);
/* Clear .bss section */
clear_bss();
/* At this point we can use objects outside the .start section */
}
|