start.S revision 176372
1/*- 2 * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/boot/powerpc/uboot/start.S 176372 2008-02-17 20:38:22Z marcel $ 27 */ 28 29#include <machine/asm.h> 30 31#define STACK_SIZE 8192 32 33/* 34 * Entry point to the loader that U-Boot passes control to. 35 */ 36 .text 37 .globl _start 38_start: 39 /* Fix up a stack */ 40 lis %r1, stack@ha 41 addi %r1, %r1, stack@l 42 addi %r1, %r1, (STACK_SIZE - 32) 43 /* Save U-Boot's r14 and r29 */ 44 lis %r11, saved_regs@ha 45 addi %r11, %r11, saved_regs@l 46 stw %r14, 0(%r11) 47 stw %r29, 4(%r11) 48 b main 49 50/* 51 * syscall() 52 */ 53ENTRY(syscall) 54 stwu %r1, -16(%r1) 55 mflr %r0 56 stw %r14, 8(%r1) 57 stw %r29, 12(%r1) 58 stw %r0, 20(%r1) 59 /* Restore U-Boot's r14 and r29 */ 60 lis %r11, saved_regs@ha 61 addi %r11, %r11, saved_regs@l 62 lwz %r14, 0(%r11) 63 lwz %r29, 4(%r11) 64 /* Call into u-Boot */ 65 lis %r11, syscall_ptr@ha 66 addi %r11, %r11, syscall_ptr@l 67 lwz %r11, 0(%r11) 68 mtctr %r11 69 bctrl 70 /* Epilogue */ 71 lwz %r11, 0(%r1) 72 lwz %r0, 4(%r11) 73 mtlr %r0 74 lwz %r14, 8(%r1) 75 lwz %r29, 12(%r1) 76 mr %r1, %r11 77 blr 78 79/* 80 * Data section 81 */ 82 .data 83 .align 4 84stack: 85 .space STACK_SIZE 86 87GLOBAL(syscall_ptr) 88 .long 0 89GLOBAL(saved_regs) 90 .long 0 /* R14 */ 91 .long 0 /* R29 */ 92 93