This repository was archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootload.c
More file actions
76 lines (64 loc) · 1.25 KB
/
bootload.c
File metadata and controls
76 lines (64 loc) · 1.25 KB
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
#include "main.h"
// this file meets bootloader requirements for targets with bootloaders
#if GCC
extern void _startup(void);
#else
extern asm void _startup(void);
#endif
#if MCF51JM128
#if ! BADGE_BOARD
#error
#endif
#define USER_ENTRY_ADDRESS 0x000039C0
#elif MCF52259
#if ! DEMO_KIT
#error
#endif
#define USER_ENTRY_ADDRESS 0x00004000
#else
#error
#endif
#if GCC
__attribute__((section(".loader_entry_data")))
const byte _UserEntry[]
#else
const byte _UserEntry[] @ USER_ENTRY_ADDRESS
#endif
= {
0x4E,
0x71,
0x4E,
0xF9 // asm NOP(0x4E71), asm JMP(0x4EF9)
};
#if GCC
__attribute__((section(".loader_entry2_data")))
void (* const _UserEntry2[])()
#else
void (* const _UserEntry2[])()@(USER_ENTRY_ADDRESS+4)
#endif
=
{
_startup,
};
extern void pre_main(void);
void pre_main(void)
{
int i;
void **v;
extern far void *_swvect[128]; // 4 bytes per entry
#if MCF51JM128
Q3_NON_NAKED(move.l, #0x00800000,d0);
Q3_NON_NAKED(movec, d0,vbr);
v = (void **)0x00800000;
for (i=0; i<128; i++) {
v[i] = _swvect[i];
}
#else
Q3_NON_NAKED(move.l, #0x20000000,d0);
Q3_NON_NAKED(movec, d0,vbr);
v = (void **)0x20000000;
for (i=0; i<128; i++) {
v[i] = _swvect[i];
}
#endif
}