131d20d5aff54c93615ee4154649074ac29ca864
[reactos.git] / reactos / boot / freeldr / bootsect / ofw_tests / ofwtest.s
1 .section .text
2
3 _start:
4 .long 0xe00000 + 12
5 .long 0
6 .long 0
7
8 .globl ofw_functions_addr
9 .globl ofw_dumpregs
10
11 ofw_functions_addr:
12 .long ofw_functions
13
14 .globl _begin
15 _begin:
16 sync
17 isync
18
19 lis %r1,stack@ha
20 addi %r1,%r1,stack@l
21 addi %r1,%r1,16384 - 0x10
22
23 /* Store ofw call addr */
24 mr %r21,%r5
25 lis %r8,_start@ha
26 addi %r7,%r8,ofw_call_addr - _start
27 stw %r21,0(%r7)
28
29 bl ofw_dumpregs
30
31 foo:
32 b foo
33
34 .align 4
35 call_freeldr:
36 /* Get the address of the functions list --
37 * Note:
38 * Because of little endian switch we must use an even number of
39 * instructions here.. Pad with a nop if needed. */
40 mfmsr %r10
41 ori %r10,%r10,1
42 mtmsr %r10
43
44 nop
45
46 /* Note that this is little-endian from here on */
47 blr
48 nop
49
50 .align 4
51
52 call_ofw:
53 /* R3 has the function offset to call (n * 4)
54 * Other arg registers are unchanged.
55 * Note that these 4 instructions are in reverse order due to
56 * little-endian convention */
57 andi. %r0,%r0,65534
58 mfmsr %r0
59 mtmsr %r0
60 /* Now normal ordering resumes */
61 subi %r1,%r1,0x100
62
63 stw %r8,4(%r1)
64 stw %r9,8(%r1)
65 stw %r10,12(%r1)
66 mflr %r8
67 stw %r8,16(%r1)
68
69 lis %r10,0xe00000@ha
70 add %r9,%r3,%r10
71 lwz %r3,ofw_functions_addr - _start@l(%r9)
72 lwz %r3,0(%r3)
73 mtctr %r3
74
75 mr %r3,%r4
76 mr %r4,%r5
77 mr %r5,%r6
78 mr %r6,%r7
79 mr %r7,%r8
80
81 /* Goto the swapped function */
82 bctrl
83
84 lwz %r8,16(%r1)
85 mtlr %r8
86
87 lwz %r8,4(%r1)
88 lwz %r9,8(%r1)
89 lwz %r10,12(%r1)
90
91 addi %r1,%r1,0x100
92 /* Ok, go back to little endian */
93 mfmsr %r0
94 ori %r0,%r0,1
95 mtmsr %r0
96
97 /* Note that this is little-endian from here on */
98 blr
99 nop
100
101 zero_registers:
102 xor %r2,%r2,%r2
103 mr %r0,%r2
104 mr %r3,%r2
105
106 mr %r4,%r2
107 mr %r5,%r2
108 mr %r6,%r2
109 mr %r7,%r2
110
111 mr %r8,%r2
112 mr %r9,%r2
113 mr %r10,%r2
114 mr %r11,%r2
115
116 mr %r12,%r2
117 mr %r13,%r2
118 mr %r14,%r2
119 mr %r15,%r2
120
121 mr %r12,%r2
122 mr %r13,%r2
123 mr %r14,%r2
124 mr %r15,%r2
125
126 mr %r16,%r2
127 mr %r17,%r2
128 mr %r18,%r2
129 mr %r19,%r2
130
131 mr %r20,%r2
132 mr %r21,%r2
133 mr %r22,%r2
134 mr %r23,%r2
135
136 mr %r24,%r2
137 mr %r25,%r2
138 mr %r26,%r2
139 mr %r27,%r2
140
141 mr %r28,%r2
142 mr %r29,%r2
143 mr %r30,%r2
144 mr %r31,%r2
145
146 blr
147
148 .org 0x1000
149 freeldr_banner:
150 .ascii "ReactOS OpenFirmware Boot Program\r\n\0"
151
152 freeldr_halt:
153 .ascii "ReactOS OpenFirmware Boot Program Halting\r\n\0"
154
155 freeldr_reg_init:
156 .ascii "r\0"
157 freeldr_reg_lr:
158 .ascii "lr \0"
159 freeldr_reg_cr:
160 .ascii "cr \0"
161 freeldr_reg_ctr:
162 .ascii "ctr\0"
163 freeldr_reg_msr:
164 .ascii "msr\0"
165
166 ofw_memory_size:
167 .long 0
168 .long 0
169 .long 0
170 .long 0
171
172 ofw_chosen_name:
173 .ascii "/chosen\0"
174
175 ofw_stdout_name:
176 .ascii "stdout\0"
177
178 ofw_memory_name:
179 .ascii "/memory@0\0"
180
181 ofw_reg_name:
182 .ascii "reg\0"
183
184 .org 0x2000
185 stack:
186 .space 0x4000
187