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.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
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.
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.
45 addi %r1,%r1,16384 - 0x10
61 li %r9,0x12 /* BATL(0, BAT_M, BAT_PP_RW) */
64 li %r9,0x1ffe /* BATU(0, BAT_BL_256M, BAT_Vs) */
72 /* Store ofw call addr */
75 stw %r5,ofw_call_addr - _start@l(%r10)
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
90 addi %r3,%r3,freeldr_banner - _start
100 addi %r3,%r3,0x8000@l
105 addi %r3,%r3,call_ofw - _start
111 /* Get the address of the functions list --
113 * Because of little endian switch we must use an even number of
114 * instructions here.. Pad with a nop if needed. */
121 /* Note that this is little-endian from here on */
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 */
134 /* Now normal ordering resumes */
145 lwz %r3,ofw_functions - _start@l(%r9)
154 /* Goto the swapped function */
165 /* Ok, go back to little endian */
170 /* Note that this is little-endian from here on */
243 ofw_print_string_hook:
248 /* Reserve some stack space */
254 /* Save the lr, a scratch register */
259 /* Load the package name */
261 addi %r3,%r3,ofw_chosen_name - _start
266 /* Load up for getprop */
270 addi %r4,%r4,ofw_stdout_name - _start
278 /* Measure the string and remember the length */
286 /* Write the string */
297 /* Print 8 hex digits representing a number in r3 */
308 /* Set up and, devide, shift */
310 lis %r6,0xf0000000@ha
311 lis %r7,0x10000000@ha
317 beq ofw_number_return
320 /* Body: isolate digit, divide, print */
329 bge ofw_number_letter
331 b ofw_number_digit_out
334 addi %r4,%r4,'A' - 10
336 ofw_number_digit_out:
415 /* Construct ofw exit call */
473 /* Body, print the regname, then the register */
477 beq ofw_register_special
479 addi %r3,%r3,freeldr_reg_init - _start
518 ofw_register_special:
521 addi %r3,%r3,freeldr_reg_lr - _start
530 addi %r3,%r3,freeldr_reg_cr - _start
539 addi %r3,%r3,freeldr_reg_ctr - _start
548 addi %r3,%r3,freeldr_reg_msr - _start
587 /* Reserve stack space ...
588 * 20 bytes for the ofw call,
592 /* Store r8, r9, lr */
598 /* Get finddevice name */
600 addi %r9,%r8,ofw_finddevice_name - _start
603 /* 1 Argument and 1 return */
610 /* Load up the call address */
611 lwz %r9,ofw_call_addr - _start(%r8)
622 /* Restore registers */
634 /* Reserve stack space:
635 * 32 bytes for the ofw call
636 * 12 bytes for r8, r9, lr
638 /* Reserve stack space ...
639 * 20 bytes for the ofw call,
643 /* Store r8, r9, lr */
649 /* Get getprop name */
651 addi %r9,%r8,ofw_getprop_name - _start
654 /* 4 Argument and 1 return */
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 */
665 /* Load up the call address */
666 lwz %r9,ofw_call_addr - _start(%r8)
675 /* Workaround to a wierd crash ... not sure what causes it.
676 * XXX investigate me */
682 /* Restore registers */
694 /* Reserve stack space:
695 * 32 bytes for the ofw call
696 * 12 bytes for r8, r9, lr
698 /* Reserve stack space ...
699 * 20 bytes for the ofw call,
703 /* Store r8, r9, lr */
709 /* Get getprop name */
711 addi %r9,%r8,ofw_getprop_name - _start
714 /* 4 Argument and 1 return */
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 */
725 /* Load up the call address */
726 lwz %r9,ofw_call_addr - _start(%r8)
738 /* Restore registers */
751 /* Reserve stack space:
752 * 28 bytes for the ofw call
753 * 12 bytes for r8, r9, lr
755 /* Reserve stack space ...
756 * 20 bytes for the ofw call,
762 /* Store r8, r9, lr */
770 addi %r9,%r8,ofw_write_name - _start
773 /* 3 Arguments and 1 return */
783 /* Load up the call address */
784 lwz %r9,ofw_call_addr - _start(%r8)
796 /* Restore registers */
808 /* Reserve stack space:
809 * 28 bytes for the ofw call
810 * 12 bytes for r8, r9, lr
812 /* Reserve stack space ...
813 * 20 bytes for the ofw call,
819 /* Store r8, r9, lr */
827 addi %r9,%r8,ofw_read_name - _start
830 /* 3 Arguments and 1 return */
840 /* Load up the call address */
841 lwz %r9,ofw_call_addr - _start(%r8)
853 /* Restore registers */
866 addi %r3,%r3,freeldr_halt - _start
873 /* Load the exit name */
875 addi %r9,%r8,ofw_exit_name - _start
878 /* Zero args, zero returns */
883 /* Load up the call address */
884 lwz %r9,ofw_call_addr - _start(%r8)
891 /* No return from exit */
895 .ascii "ReactOS OpenFirmware Boot Program\r\n\0"
898 .ascii "ReactOS OpenFirmware Boot Program Halting\r\n\0"
922 .ascii "finddevice\0"
949 .long ofw_finddevice_hook
950 .long ofw_getprop_hook
955 .long ofw_print_string
956 .long ofw_print_number