Add Tercel PHY reset synchronization
[microwatt.git] / rust_lib_demo / head.S
1 /* Copyright 2013-2014 IBM Corp.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 * implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define STACK_TOP 0x1f000
18
19 #define FIXUP_ENDIAN \
20 tdi 0,0,0x48; /* Reverse endian of b . + 8 */ \
21 b 191f; /* Skip trampoline if endian is good */ \
22 .long 0xa600607d; /* mfmsr r11 */ \
23 .long 0x01006b69; /* xori r11,r11,1 */ \
24 .long 0x05009f42; /* bcl 20,31,$+4 */ \
25 .long 0xa602487d; /* mflr r10 */ \
26 .long 0x14004a39; /* addi r10,r10,20 */ \
27 .long 0xa64b5a7d; /* mthsrr0 r10 */ \
28 .long 0xa64b7b7d; /* mthsrr1 r11 */ \
29 .long 0x2402004c; /* hrfid */ \
30 191:
31
32
33 /* Load an immediate 64-bit value into a register */
34 #define LOAD_IMM64(r, e) \
35 lis r,(e)@highest; \
36 ori r,r,(e)@higher; \
37 rldicr r,r, 32, 31; \
38 oris r,r, (e)@h; \
39 ori r,r, (e)@l;
40
41 .section ".head","ax"
42
43 . = 0
44 .global _start
45 _start:
46 FIXUP_ENDIAN
47 b boot_entry
48
49 .global boot_entry
50 boot_entry:
51 /* setup stack */
52 LOAD_IMM64(%r1, STACK_TOP - 0x100)
53 LOAD_IMM64(%r12, main)
54 mtctr %r12,
55 bctrl
56 b .
57
58 #define EXCEPTION(nr) \
59 .= nr ;\
60 b .
61
62 /* More exception stubs */
63 EXCEPTION(0x300)
64 EXCEPTION(0x380)
65 EXCEPTION(0x400)
66 EXCEPTION(0x480)
67 EXCEPTION(0x500)
68 EXCEPTION(0x600)
69 EXCEPTION(0x700)
70 EXCEPTION(0x800)
71 EXCEPTION(0x900)
72 EXCEPTION(0x980)
73 EXCEPTION(0xa00)
74 EXCEPTION(0xb00)
75 EXCEPTION(0xc00)
76 EXCEPTION(0xd00)
77 EXCEPTION(0xe00)
78 EXCEPTION(0xe20)
79 EXCEPTION(0xe40)
80 EXCEPTION(0xe60)
81 EXCEPTION(0xe80)
82 EXCEPTION(0xf00)
83 EXCEPTION(0xf20)
84 EXCEPTION(0xf40)
85 EXCEPTION(0xf60)
86 EXCEPTION(0xf80)
87 #if 0
88 EXCEPTION(0x1000)
89 EXCEPTION(0x1100)
90 EXCEPTION(0x1200)
91 EXCEPTION(0x1300)
92 EXCEPTION(0x1400)
93 EXCEPTION(0x1500)
94 EXCEPTION(0x1600)
95 #endif