1/* $NetBSD: srt0.s,v 1.3 1999/06/28 01:20:45 sakamoto Exp $ */ 2 3/*- 4 * Copyright (C) 1995-1997 Gary Thomas (gdt@linuxppc.org) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Gary Thomas. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#define MSR_EE 0x8000 34 35 .text 36 37/* 38 * This code is loaded by the ROM loader at location 0x3100. 39 * Move it to high memory so that it can load the kernel at 0x0000. 40 */ 41#define PEF_LOAD_ADDRESS 0x3100 42 43 .globl _start 44_start: 45 mfmsr 3 /* Turn off interrupts */ 46 li 4,0x3002 47 li 4,0 48 ori 4,4,MSR_EE 49 andc 3,3,4 50 mtmsr 3 51 bl whichCPU 52 cmpi 0,3,0 53 bne 90f 54/* CPU 0 runs here */ 55/* Relocate code to final resting spot */ 56 li 3,PEF_LOAD_ADDRESS 57 lis 4,_start@h 58 ori 4,4,_start@l 59 lis 5,edata@h 60 ori 5,5,edata@l 61 addi 5,5,3 /* Round up - just in case */ 62 sub 5,5,4 /* Compute # longwords to move */ 63 srwi 5,5,2 64 mtctr 5 65 subi 3,3,4 /* Set up for loop */ 66 subi 4,4,4 6700: lwzu 5,4(3) 68 stwu 5,4(4) 69 bdnz 00b 70 lis 3,start_ldr@h 71 ori 3,3,start_ldr@l 72 mtlr 3 /* Easiest way to do an absolute jump */ 73 blr 74start_ldr: 75/* Clear all of BSS */ 76 lis 3,edata@h 77 ori 3,3,edata@l 78 lis 4,end@h 79 ori 4,4,end@l 80 subi 3,3,4 81 subi 4,4,4 82 li 0,0 8350: stwu 0,4(3) 84 cmp 0,3,4 85 bne 50b 8690: 87 bl main 88hang: 89 b hang 90 91/* 92 * end address 93 */ 94 .globl endaddr 95endaddr: 96 lis 3,end@h 97 ori 3,3,end@l 98 lis 4,_start@h 99 ori 4,4,_start@l 100 sub 3,3,4 101 blr 102 103/* 104 * Execute 105 * run(startsym, endsym, args, bootinfo, entry) 106 */ 107 .globl run 108run: 109 mtctr 7 /* Entry point */ 110 bctr 111