Added boot carrier for freeldr. I'm at the point where I need to do
[reactos.git] / reactos / boot / freeldr / bootsect / ofwboot.s
1 .section .text
2 _start:
3 .long 0xe00000 + 12
4 .long 0
5 .long 0
6
7 /*
8 * LIFTED FROM arch/macppc/stand/ofwboot/Locore.c
9 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
10 * Copyright (C) 1995, 1996 TooLs GmbH.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by TooLs GmbH.
24 * 4. The name of TooLs GmbH may not be used to endorse or promote products
25 * derived from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE, DATA, OR PROFITS;
33 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 _begin:
40 sync
41 isync
42
43 lis %r1,stack@ha
44 addi %r1,%r1,stack@l
45 addi %r1,%r1,16384 - 0x10
46
47 mfmsr %r8
48 li %r0,0
49 mtmsr %r0
50 isync
51
52 mtibatu 0,%r0
53 mtibatu 1,%r0
54 mtibatu 2,%r0
55 mtibatu 3,%r0
56 mtdbatu 0,%r0
57 mtdbatu 1,%r0
58 mtdbatu 2,%r0
59 mtdbatu 3,%r0
60
61 li %r9,0x12 /* BATL(0, BAT_M, BAT_PP_RW) */
62 mtibatl 0,%r9
63 mtdbatl 0,%r9
64 li %r9,0x1ffe /* BATU(0, BAT_BL_256M, BAT_Vs) */
65 mtibatu 0,%r9
66 mtdbatu 0,%r9
67 isync
68
69 li %r8,0x3030
70 mtmsr %r8
71
72 /* Store ofw call addr */
73 mr %r21,%r5
74 lis %r10,0xe00000@ha
75 stw %r5,ofw_call_addr - _start@l(%r10)
76
77 lis %r4,_binary_freeldr_tmp_end@ha
78 addi %r4,%r4,_binary_freeldr_tmp_end@l
79 lis %r3,_binary_freeldr_tmp_start@ha
80 addi %r3,%r3,_binary_freeldr_tmp_start@l
81
82 lis %r5,0x8000@ha
83 addi %r5,%r5,0x8000@l
84
85 bl copy_bits
86
87 bl zero_registers
88
89 lis %r3,0xe00000@ha
90 addi %r3,%r3,freeldr_banner - _start
91
92 bl ofw_print_string
93
94 bl ofw_print_eol
95
96 /* Zero CTR */
97 mtcr %r31
98
99 lis %r3,0x8000@ha
100 addi %r3,%r3,0x8000@l
101
102 mtlr %r3
103
104 lis %r3,call_ofw@ha
105 addi %r3,%r3,call_ofw - _start
106
107 b call_freeldr
108
109 .align 4
110 call_freeldr:
111 /* Get the address of the functions list --
112 * Note:
113 * Because of little endian switch we must use an even number of
114 * instructions here.. Pad with a nop if needed. */
115 mfmsr %r10
116 ori %r10,%r10,1
117 mtmsr %r10
118
119 nop
120
121 /* Note that this is little-endian from here on */
122 blr
123 nop
124
125 .align 4
126 call_ofw:
127 /* R3 has the function offset to call (n * 4)
128 * Other arg registers are unchanged.
129 * Note that these 4 instructions are in reverse order due to
130 * little-endian convention */
131 andi. %r0,%r0,65534
132 mfmsr %r0
133 mtmsr %r0
134 /* Now normal ordering resumes */
135 subi %r1,%r1,0x100
136
137 stw %r8,4(%r1)
138 stw %r9,8(%r1)
139 stw %r10,12(%r1)
140 mflr %r8
141 stw %r8,16(%r1)
142
143 lis %r10,0xe00000@ha
144 add %r9,%r3,%r10
145 lwz %r3,ofw_functions - _start@l(%r9)
146 mtctr %r3
147
148 mr %r3,%r4
149 mr %r4,%r5
150 mr %r5,%r6
151 mr %r6,%r7
152 mr %r7,%r8
153
154 /* Goto the swapped function */
155 bctrl
156
157 lwz %r8,16(%r1)
158 mtlr %r8
159
160 lwz %r8,4(%r1)
161 lwz %r9,8(%r1)
162 lwz %r10,12(%r1)
163
164 addi %r1,%r1,0x100
165 /* Ok, go back to little endian */
166 mfmsr %r0
167 ori %r0,%r0,1
168 mtmsr %r0
169
170 /* Note that this is little-endian from here on */
171 blr
172 nop
173
174 zero_registers:
175 xor %r2,%r2,%r2
176 mr %r0,%r2
177 mr %r3,%r2
178
179 mr %r4,%r2
180 mr %r5,%r2
181 mr %r6,%r2
182 mr %r7,%r2
183
184 mr %r8,%r2
185 mr %r9,%r2
186 mr %r10,%r2
187 mr %r11,%r2
188
189 mr %r12,%r2
190 mr %r13,%r2
191 mr %r14,%r2
192 mr %r15,%r2
193
194 mr %r12,%r2
195 mr %r13,%r2
196 mr %r14,%r2
197 mr %r15,%r2
198
199 mr %r16,%r2
200 mr %r17,%r2
201 mr %r18,%r2
202 mr %r19,%r2
203
204 mr %r20,%r2
205 mr %r21,%r2
206 mr %r22,%r2
207 mr %r23,%r2
208
209 mr %r24,%r2
210 mr %r25,%r2
211 mr %r26,%r2
212 mr %r27,%r2
213
214 mr %r28,%r2
215 mr %r29,%r2
216 mr %r30,%r2
217 mr %r31,%r2
218
219 blr
220
221 prim_strlen:
222 mr %r5,%r3
223 prim_strlen_loop:
224 lbz %r4,0(%r3)
225 cmpi 0,0,%r4,0
226 beq prim_strlen_done
227 addi %r3,%r3,1
228 b prim_strlen_loop
229
230 prim_strlen_done:
231 sub %r3,%r3,%r5
232 blr
233
234 copy_bits:
235 cmp 0,0,%r3,%r4
236 beqlr
237 lwz %r6,0(%r3)
238 stw %r6,0(%r5)
239 addi %r3,%r3,4
240 addi %r5,%r5,4
241 b copy_bits
242
243 ofw_print_string_hook:
244 bl ofw_print_number
245 bl ofw_exit
246
247 ofw_print_string:
248 /* Reserve some stack space */
249 subi %r1,%r1,32
250
251 /* Save args */
252 stw %r3,0(%r1)
253
254 /* Save the lr, a scratch register */
255 stw %r8,8(%r1)
256 mflr %r8
257 stw %r8,12(%r1)
258
259 /* Load the package name */
260 lis %r3,0xe00000@ha
261 addi %r3,%r3,ofw_chosen_name - _start
262
263 /* Fire */
264 bl ofw_finddevice
265
266 /* Load up for getprop */
267 stw %r3,16(%r1)
268
269 lis %r4,0xe00000@ha
270 addi %r4,%r4,ofw_stdout_name - _start
271
272 addi %r5,%r1,20
273
274 li %r6,4
275
276 bl ofw_getprop
277
278 /* Measure the string and remember the length */
279 lwz %r3,0(%r1)
280 bl prim_strlen
281 mr %r5,%r3
282
283 lwz %r3,20(%r1)
284 lwz %r4,0(%r1)
285
286 /* Write the string */
287 bl ofw_write
288
289 /* Return */
290 lwz %r8,12(%r1)
291 mtlr %r8
292 lwz %r8,8(%r1)
293
294 addi %r1,%r1,32
295 blr
296
297 /* Print 8 hex digits representing a number in r3 */
298 ofw_print_number:
299 subi %r1,%r1,32
300 stw %r8,0(%r1)
301 mflr %r8
302 stw %r8,4(%r1)
303 stw %r9,8(%r1)
304
305 xor %r9,%r9,%r9
306 stw %r9,12(%r1)
307
308 /* Set up and, devide, shift */
309 mr %r8,%r3
310 lis %r6,0xf0000000@ha
311 lis %r7,0x10000000@ha
312 li %r9,8
313
314 ofw_number_loop:
315 nop
316 cmpi 0,0,%r9,0
317 beq ofw_number_return
318 subi %r9,%r9,1
319
320 /* Body: isolate digit, divide, print */
321 and %r5,%r6,%r8
322 divwu %r4,%r5,%r7
323 srwi %r6,%r6,4
324 srwi %r7,%r7,4
325
326 nop
327
328 cmpi 0,0,%r4,10
329 bge ofw_number_letter
330 addi %r4,%r4,'0'
331 b ofw_number_digit_out
332
333 ofw_number_letter:
334 addi %r4,%r4,'A' - 10
335
336 ofw_number_digit_out:
337 stb %r4,12(%r1)
338 addi %r3,%r1,12
339
340 stw %r6,16(%r1)
341 stw %r7,20(%r1)
342 stw %r8,24(%r1)
343 stw %r9,28(%r1)
344
345 bl ofw_print_string
346
347 lwz %r6,16(%r1)
348 lwz %r7,20(%r1)
349 lwz %r8,24(%r1)
350 lwz %r9,28(%r1)
351
352 b ofw_number_loop
353
354 ofw_number_return:
355 /* Return */
356 lwz %r9,8(%r1)
357 lwz %r8,4(%r1)
358 mtlr %r8
359 lwz %r8,0(%r1)
360 addi %r1,%r1,32
361 blr
362
363 ofw_print_eol:
364 subi %r1,%r1,16
365 stw %r8,0(%r1)
366 mflr %r8
367 stw %r8,4(%r1)
368 li %r4,0x0d0a
369 sth %r4,8(%r1)
370 xor %r4,%r4,%r4
371 sth %r4,10(%r1)
372 addi %r3,%r1,8
373 bl ofw_print_string
374 lwz %r8,4(%r1)
375 mtlr %r8
376 lwz %r8,0(%r1)
377 addi %r1,%r1,16
378 blr
379
380 ofw_print_nothing:
381 subi %r1,%r1,16
382 stw %r8,0(%r1)
383 mflr %r8
384 stw %r8,4(%r1)
385 li %r4,0
386 sth %r4,8(%r1)
387 xor %r4,%r4,%r4
388 sth %r4,10(%r1)
389 addi %r3,%r1,8
390 bl ofw_print_string
391 lwz %r8,4(%r1)
392 mtlr %r8
393 lwz %r8,0(%r1)
394 addi %r1,%r1,16
395 blr
396
397 ofw_print_space:
398 subi %r1,%r1,16
399 stw %r8,0(%r1)
400 mflr %r8
401 stw %r8,4(%r1)
402 li %r4,0x2000
403 sth %r4,8(%r1)
404 xor %r4,%r4,%r4
405 sth %r4,10(%r1)
406 addi %r3,%r1,8
407 bl ofw_print_string
408 lwz %r8,4(%r1)
409 mtlr %r8
410 lwz %r8,0(%r1)
411 addi %r1,%r1,16
412 blr
413
414 ofw_print_regs:
415 /* Construct ofw exit call */
416 subi %r1,%r1,0xa0
417
418 stw %r0,0(%r1)
419 stw %r1,4(%r1)
420 stw %r2,8(%r1)
421 stw %r3,12(%r1)
422
423 stw %r4,16(%r1)
424 stw %r5,20(%r1)
425 stw %r6,24(%r1)
426 stw %r7,28(%r1)
427
428 stw %r8,32(%r1)
429 stw %r9,36(%r1)
430 stw %r10,40(%r1)
431 stw %r11,44(%r1)
432
433 stw %r12,48(%r1)
434 stw %r13,52(%r1)
435 stw %r14,56(%r1)
436 stw %r15,60(%r1)
437
438 stw %r16,64(%r1)
439 stw %r17,68(%r1)
440 stw %r18,72(%r1)
441 stw %r19,76(%r1)
442
443 stw %r20,80(%r1)
444 stw %r21,84(%r1)
445 stw %r22,88(%r1)
446 stw %r23,92(%r1)
447
448 stw %r24,96(%r1)
449 stw %r25,100(%r1)
450 stw %r26,104(%r1)
451 stw %r27,108(%r1)
452
453 stw %r28,112(%r1)
454 stw %r29,116(%r1)
455 stw %r30,120(%r1)
456 stw %r31,124(%r1)
457
458 mflr %r0
459 stw %r0,128(%r1)
460 mfcr %r0
461 stw %r0,132(%r1)
462 mfctr %r0
463 stw %r0,136(%r1)
464 mfmsr %r0
465 stw %r0,140(%r1)
466
467 /* Count at zero */
468 xor %r0,%r0,%r0
469 stw %r0,144(%r1)
470 mr %r3,%r1
471 stw %r3,148(%r1)
472
473 /* Body, print the regname, then the register */
474 ofw_register_loop:
475 lwz %r3,144(%r1)
476 cmpi 0,0,%r3,32
477 beq ofw_register_special
478 lis %r3,0xe00000@ha
479 addi %r3,%r3,freeldr_reg_init - _start
480 bl ofw_print_string
481 lwz %r3,144(%r1)
482 bl ofw_print_number
483 bl ofw_print_space
484 lwz %r3,144(%r1)
485 mulli %r3,%r3,4
486 add %r3,%r1,%r3
487 lwz %r3,0(%r3)
488 stw %r3,152(%r1)
489 bl ofw_print_number
490 lwz %r3,144(%r1)
491 addi %r3,%r3,1
492 stw %r3,144(%r1)
493 b done_dump
494
495 dump_optional:
496 bl ofw_print_space
497 bl ofw_print_space
498 lwz %r3,152(%r1)
499 lwz %r3,0(%r3)
500 bl ofw_print_number
501 bl ofw_print_space
502 lwz %r3,152(%r1)
503 lwz %r3,4(%r3)
504 bl ofw_print_number
505 bl ofw_print_space
506 lwz %r3,152(%r1)
507 lwz %r3,8(%r3)
508 bl ofw_print_number
509 bl ofw_print_space
510 lwz %r3,152(%r1)
511 lwz %r3,12(%r3)
512 bl ofw_print_number
513 bl ofw_print_space
514 done_dump:
515 bl ofw_print_eol
516 b ofw_register_loop
517
518 ofw_register_special:
519 /* LR */
520 lis %r3,0xe00000@ha
521 addi %r3,%r3,freeldr_reg_lr - _start
522 bl ofw_print_string
523 bl ofw_print_space
524 lwz %r3,128(%r1)
525 bl ofw_print_number
526 bl ofw_print_eol
527
528 /* CR */
529 lis %r3,0xe00000@ha
530 addi %r3,%r3,freeldr_reg_cr - _start
531 bl ofw_print_string
532 bl ofw_print_space
533 lwz %r3,132(%r1)
534 bl ofw_print_number
535 bl ofw_print_eol
536
537 /* CTR */
538 lis %r3,0xe00000@ha
539 addi %r3,%r3,freeldr_reg_ctr - _start
540 bl ofw_print_string
541 bl ofw_print_space
542 lwz %r3,136(%r1)
543 bl ofw_print_number
544 bl ofw_print_eol
545
546 /* MSR */
547 lis %r3,0xe00000@ha
548 addi %r3,%r3,freeldr_reg_msr - _start
549 bl ofw_print_string
550 bl ofw_print_space
551 lwz %r3,140(%r1)
552 bl ofw_print_number
553 bl ofw_print_eol
554
555 /* Return */
556 lwz %r0,128(%r1)
557 mtlr %r0
558
559 lwz %r0,0(%r1)
560 lwz %r2,8(%r1)
561 lwz %r3,12(%r1)
562
563 lwz %r4,16(%r1)
564 lwz %r5,20(%r1)
565 lwz %r6,24(%r1)
566 lwz %r7,28(%r1)
567
568 addi %r1,%r1,0xa0
569
570 blr
571
572 ofw_finddevice_hook:
573 subi %r1,%r1,32
574 stw %r3,0(%r1)
575 mflr %r3
576 stw %r3,4(%r1)
577 lwz %r3,0(%r1)
578 bl ofw_finddevice
579 stw %r3,0(%r1)
580 lwz %r3,4(%r1)
581 mtlr %r3
582 lwz %r3,0(%r1)
583 addi %r1,%r1,32
584 blr
585
586 ofw_finddevice:
587 /* Reserve stack space ...
588 * 20 bytes for the ofw call,
589 * r8, r9, and lr */
590 subi %r1,%r1,32
591
592 /* Store r8, r9, lr */
593 stw %r8,20(%r1)
594 stw %r9,24(%r1)
595 mflr %r8
596 stw %r8,28(%r1)
597
598 /* Get finddevice name */
599 lis %r8,0xe00000@ha
600 addi %r9,%r8,ofw_finddevice_name - _start
601 stw %r9,0(%r1)
602
603 /* 1 Argument and 1 return */
604 li %r9,1
605 stw %r9,4(%r1)
606 stw %r9,8(%r1)
607
608 stw %r3,12(%r1)
609
610 /* Load up the call address */
611 lwz %r9,ofw_call_addr - _start(%r8)
612 mtlr %r9
613
614 /* Set argument */
615 mr %r3,%r1
616
617 /* Fire */
618 blrl
619
620 lwz %r3,16(%r1)
621
622 /* Restore registers */
623 lwz %r8,28(%r1)
624 mtlr %r8
625 lwz %r9,24(%r1)
626 lwz %r8,20(%r1)
627
628 addi %r1,%r1,32
629
630 /* Return */
631 blr
632
633 ofw_getprop_hook:
634 /* Reserve stack space:
635 * 32 bytes for the ofw call
636 * 12 bytes for r8, r9, lr
637 */
638 /* Reserve stack space ...
639 * 20 bytes for the ofw call,
640 * r8, r9, and lr */
641 subi %r1,%r1,48
642
643 /* Store r8, r9, lr */
644 stw %r8,32(%r1)
645 stw %r9,36(%r1)
646 mflr %r8
647 stw %r8,40(%r1)
648
649 /* Get getprop name */
650 lis %r8,0xe00000@ha
651 addi %r9,%r8,ofw_getprop_name - _start
652 stw %r9,0(%r1)
653
654 /* 4 Argument and 1 return */
655 li %r9,4
656 stw %r9,4(%r1)
657 li %r9,1
658 stw %r9,8(%r1)
659
660 stw %r3,12(%r1) /* Package */
661 stw %r4,16(%r1) /* Property */
662 stw %r5,20(%r1) /* Return buffer */
663 stw %r6,24(%r1) /* Buffer size */
664
665 /* Load up the call address */
666 lwz %r9,ofw_call_addr - _start(%r8)
667 mtlr %r9
668
669 /* Set argument */
670 mr %r3,%r1
671
672 /* Fire */
673 blrl
674
675 /* Workaround to a wierd crash ... not sure what causes it.
676 * XXX investigate me */
677 bl ofw_print_nothing
678
679 /* Return */
680 lwz %r3,28(%r1)
681
682 /* Restore registers */
683 lwz %r8,40(%r1)
684 mtlr %r8
685 lwz %r9,36(%r1)
686 lwz %r8,32(%r1)
687
688 addi %r1,%r1,48
689
690 /* Return */
691 blr
692
693 ofw_getprop:
694 /* Reserve stack space:
695 * 32 bytes for the ofw call
696 * 12 bytes for r8, r9, lr
697 */
698 /* Reserve stack space ...
699 * 20 bytes for the ofw call,
700 * r8, r9, and lr */
701 subi %r1,%r1,48
702
703 /* Store r8, r9, lr */
704 stw %r8,32(%r1)
705 stw %r9,36(%r1)
706 mflr %r8
707 stw %r8,40(%r1)
708
709 /* Get getprop name */
710 lis %r8,0xe00000@ha
711 addi %r9,%r8,ofw_getprop_name - _start
712 stw %r9,0(%r1)
713
714 /* 4 Argument and 1 return */
715 li %r9,4
716 stw %r9,4(%r1)
717 li %r9,1
718 stw %r9,8(%r1)
719
720 stw %r3,12(%r1) /* Package */
721 stw %r4,16(%r1) /* Property */
722 stw %r5,20(%r1) /* Return buffer */
723 stw %r6,24(%r1) /* Buffer size */
724
725 /* Load up the call address */
726 lwz %r9,ofw_call_addr - _start(%r8)
727 mtlr %r9
728
729 /* Set argument */
730 mr %r3,%r1
731
732 /* Fire */
733 blrl
734
735 /* Return */
736 lwz %r3,28(%r1)
737
738 /* Restore registers */
739 lwz %r8,40(%r1)
740
741 mtlr %r8
742 lwz %r9,36(%r1)
743 lwz %r8,32(%r1)
744
745 addi %r1,%r1,48
746
747 /* Return */
748 blr
749
750 ofw_write:
751 /* Reserve stack space:
752 * 28 bytes for the ofw call
753 * 12 bytes for r8, r9, lr
754 */
755 /* Reserve stack space ...
756 * 20 bytes for the ofw call,
757 * r8, r9, and lr */
758 subi %r1,%r1,48
759
760 nop
761
762 /* Store r8, r9, lr */
763 stw %r8,28(%r1)
764 stw %r9,32(%r1)
765 mflr %r8
766 stw %r8,36(%r1)
767
768 /* Get write name */
769 lis %r8,0xe00000@ha
770 addi %r9,%r8,ofw_write_name - _start
771 stw %r9,0(%r1)
772
773 /* 3 Arguments and 1 return */
774 li %r9,3
775 stw %r9,4(%r1)
776 li %r9,1
777 stw %r9,8(%r1)
778
779 stw %r3,12(%r1)
780 stw %r4,16(%r1)
781 stw %r5,20(%r1)
782
783 /* Load up the call address */
784 lwz %r9,ofw_call_addr - _start(%r8)
785 mtlr %r9
786
787 /* Set argument */
788 mr %r3,%r1
789
790 /* Fire */
791 blrl
792
793 /* Return */
794 lwz %r3,24(%r1)
795
796 /* Restore registers */
797 lwz %r8,36(%r1)
798 mtlr %r8
799 lwz %r9,32(%r1)
800 lwz %r8,28(%r1)
801
802 addi %r1,%r1,48
803
804 /* Return */
805 blr
806
807 ofw_read:
808 /* Reserve stack space:
809 * 28 bytes for the ofw call
810 * 12 bytes for r8, r9, lr
811 */
812 /* Reserve stack space ...
813 * 20 bytes for the ofw call,
814 * r8, r9, and lr */
815 subi %r1,%r1,48
816
817 nop
818
819 /* Store r8, r9, lr */
820 stw %r8,28(%r1)
821 stw %r9,32(%r1)
822 mflr %r8
823 stw %r8,36(%r1)
824
825 /* Get read name */
826 lis %r8,0xe00000@ha
827 addi %r9,%r8,ofw_read_name - _start
828 stw %r9,0(%r1)
829
830 /* 3 Arguments and 1 return */
831 li %r9,3
832 stw %r9,4(%r1)
833 li %r9,1
834 stw %r9,8(%r1)
835
836 stw %r3,12(%r1)
837 stw %r4,16(%r1)
838 stw %r5,20(%r1)
839
840 /* Load up the call address */
841 lwz %r9,ofw_call_addr - _start(%r8)
842 mtlr %r9
843
844 /* Set argument */
845 mr %r3,%r1
846
847 /* Fire */
848 blrl
849
850 /* Return */
851 lwz %r3,24(%r1)
852
853 /* Restore registers */
854 lwz %r8,36(%r1)
855 mtlr %r8
856 lwz %r9,32(%r1)
857 lwz %r8,28(%r1)
858
859 addi %r1,%r1,48
860
861 /* Return */
862 blr
863
864 ofw_exit:
865 lis %r3,0xe00000@ha
866 addi %r3,%r3,freeldr_halt - _start
867
868 bl ofw_print_string
869 /*
870 ofw_exit_loop:
871 b ofw_exit_loop
872 */
873 /* Load the exit name */
874 lis %r8,0xe00000@ha
875 addi %r9,%r8,ofw_exit_name - _start
876 stw %r9,0(%r1)
877
878 /* Zero args, zero returns */
879 xor %r9,%r9,%r9
880 stw %r9,4(%r1)
881 stw %r9,8(%r1)
882
883 /* Load up the call address */
884 lwz %r9,ofw_call_addr - _start(%r8)
885 mtlr %r9
886
887 mr %r3,%r1
888
889 /* Fire */
890 blrl
891 /* No return from exit */
892
893 .org 0x1000
894 freeldr_banner:
895 .ascii "ReactOS OpenFirmware Boot Program\r\n\0"
896
897 freeldr_halt:
898 .ascii "ReactOS OpenFirmware Boot Program Halting\r\n\0"
899
900 freeldr_reg_init:
901 .ascii "r\0"
902
903 freeldr_reg_lr:
904 .ascii "lr \0"
905 freeldr_reg_cr:
906 .ascii "cr \0"
907 freeldr_reg_ctr:
908 .ascii "ctr\0"
909 freeldr_reg_msr:
910 .ascii "msr\0"
911
912 ofw_call_addr:
913 .long 0
914
915 ofw_memory_size:
916 .long 0
917 .long 0
918 .long 0
919 .long 0
920
921 ofw_finddevice_name:
922 .ascii "finddevice\0"
923
924 ofw_getprop_name:
925 .ascii "getprop\0"
926
927 ofw_write_name:
928 .ascii "write\0"
929
930 ofw_read_name:
931 .ascii "read\0"
932
933 ofw_exit_name:
934 .ascii "exit\0"
935
936 ofw_chosen_name:
937 .ascii "/chosen\0"
938
939 ofw_stdout_name:
940 .ascii "stdout\0"
941
942 ofw_memory_name:
943 .ascii "/memory@0\0"
944
945 ofw_reg_name:
946 .ascii "reg\0"
947
948 ofw_functions:
949 .long ofw_finddevice_hook
950 .long ofw_getprop_hook
951 .long ofw_write
952 .long ofw_read
953 .long ofw_exit
954 .long ofw_print_regs
955 .long ofw_print_string
956 .long ofw_print_number
957
958 .org 0x2000
959 stack:
960 .space 0x4000