1
2
3
4
5
6
7
8
9 #include "bare.h"
10 #include <asm/ptrace.h>
11
12 .data
13 .globl C_LABEL(romvec)
14 .globl C_LABEL(idp_ptr)
15
16 C_LABEL(romvec):
17 .word 0
18 C_LABEL(idp_ptr):
19 .word 0
20
21 .text
22 .align 8
23 .globl C_LABEL(first_adr_in_text)
24
25 C_LABEL(first_adr_in_text):
26
27
28 .globl C_LABEL(b_block)
29 .globl C_LABEL(b_block_size)
30 .globl C_LABEL(b_block_cksum)
31
32 b start_of_execution
33 nop
34
35 .align 8
36 C_LABEL(b_block):
37 .skip (BOOTBLOCK_NENTRIES * BOOTBLOCK_ENTSIZE)
38
39 C_LABEL(b_block_size):
40 .word 0
41
42 C_LABEL(b_block_cksum):
43 .word 0
44
45
46
47
48
49
50
51 start_of_execution:
52 sethi %hi(C_LABEL(first_adr_in_text)), %o1 ! This is our top
53 or %o1, %lo(C_LABEL(first_adr_in_text)), %o1 ! of stack too.
54 sub %o1, REGWIN_SZ, %o1
55 add %o1, 0x7, %o1
56 andn %o1, 0x7, %o1
57 save %o1, 0x0, %sp ! save is an add
58 here:
59 call there
60 sethi %hi(here), %o4
61 there:
62 sub %o7, here-C_LABEL(first_adr_in_text), %o5
63 or %o4, %lo(here), %o4
64 cmp %o4, %o7
65 be loaded_ok
66 nop
67
68
69 set C_LABEL(edata)+4, %o3
70 set C_LABEL(first_adr_in_text), %o2
71 sub %o3, %o2, %o3
72 rel_loop:
73 ld [%o5], %o4
74 add %o5, 0x4, %o5
75 st %o4, [%o2]
76 subcc %o3, 0x4, %o3
77 bg rel_loop
78 add %o2, 0x4, %o2
79
80
81 sethi %hi(loaded_ok), %o2
82 or %o2, %lo(loaded_ok), %o2
83 jmp %o2
84 nop
85
86 loaded_ok:
87
88 sethi %hi(C_LABEL(romvec)), %o1
89 or %o1, %lo(C_LABEL(romvec)), %o1
90 st %i0, [%o1]
91
92
93 rd %psr, %o1
94
95 #if 0
96 andn %o1, PSR_PIL, %o1
97 sethi %hi(SANE_PSR), %g4
98 or %g4, %lo(SANE_PSR), %g4
99 or %o1, %g4, %o1
100 #endif
101
102
103 sethi %hi(0xffffffff), %g2
104 rd %wim, %g3
105 or %g2, %lo(0xffffffff), %g2
106 wr %g2, 0x0, %wim
107 WRITE_PAUSE
108
109 rd %wim, %g4
110 WRITE_PAUSE
111
112 wr %g3, 0x0, %wim
113 WRITE_PAUSE
114
115
116 wr %o1, 0x0, %psr
117 WRITE_PAUSE
118
119 or %g0, 0x0, %g3
120 1:
121 srl %g4, 0x1, %g4
122 subcc %g4, 0x0, %g0
123 bne 1b
124 add %g3, 0x1, %g3
125
126
127 sethi %hi(C_LABEL(nwindows)), %o4
128 st %g3, [%o4 + %lo(C_LABEL(nwindows))]
129
130
131
132
133 sethi %hi(C_LABEL(end)), %g1
134 or %g1, %lo(C_LABEL(end)), %g1
135 add %g1, 0x4, %g1
136 sethi %hi(C_LABEL(edata)), %g2
137 or %g2, %lo(C_LABEL(edata)), %g2
138
139
140 bzero_bss_loop:
141 st %g0, [%g2]
142 add %g2, 0x4, %g2
143 cmp %g2, %g1
144 bl bzero_bss_loop
145 nop
146
147 call C_LABEL(init_me) ! Fun with empirical constants and prom
148 nop
149
150
151 get_me_out_of_here:
152 set C_LABEL(romvec), %g2
153 ld [%g2], %g2
154 ld [%g2 + 0x74], %g2
155 restore
156 call %g2
157 nop
158
159
160