-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.c
116 lines (89 loc) · 1.53 KB
/
start.c
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
static void * memcpy_start(void * dst, const void * src, size_t length);
static void * memset_start(void * ptr1, int c, size_t length);
int main(void);
extern const uint8_t _text_sec_end;
extern uint8_t _data_sec_start;
extern uint8_t _data_sec_end;
extern uint8_t _bss_sec_start;
extern uint8_t _bss_sec_end;
void start(void)
{
volatile long x;
for (x = 0; x < 1000000; x++)
x;
memcpy_start(&_data_sec_start, &_text_sec_end, &_data_sec_end - &_data_sec_start);
memset_start(&_bss_sec_start, 0, &_bss_sec_end - &_bss_sec_start);
main();
while (true)
{
}
}
static void * memcpy_start(void * dst, const void * src, size_t length)
{
uint8_t * dst2 = dst;
const uint8_t * src2 = src;
for (size_t i = 0; i < length; i++)
dst2[i] = src2[i];
return dst;
}
static void * memset_start(void * ptr1, int c, size_t length)
{
uint8_t * ptr2 = ptr1;
for (size_t i = 0; i < length; i++)
ptr2[i] = c;
return ptr1;
}
uint32_t int_vec_table[0x62] __attribute__((section(".intvectable") )) =
{
0x2001C000,
(uint32_t)&start,
(uint32_t)&start,
(uint32_t)&start,
0,
0,
0,
0,
0,
0,
0,
(uint32_t)&start,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};