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$ 27 */ 28 29#include <machine/asm.h> 30 31/* 32 * Entry point to the loader that U-Boot passes control to. 33 */ 34 .text 35 .globl _start 36_start: 37 /* Hint where to look for the API signature */ 38 lis %r11, uboot_address@ha 39 addi %r11, %r11, uboot_address@l 40 stw %r1, 0(%r11) 41 /* Save U-Boot's r14 */ 42 lis %r11, saved_regs@ha 43 addi %r11, %r11, saved_regs@l 44 stw %r14, 0(%r11) 45 /* Disable interrupts */ 46 mfmsr %r11 47 andi. %r11, %r11, ~0x8000@l 48 mtmsr %r11 49 b main 50 51/* 52 * syscall() 53 */ 54ENTRY(syscall) 55 stwu %r1, -16(%r1) 56 mflr %r0 57 stw %r14, 8(%r1) 58 stw %r0, 20(%r1) 59 /* Restore U-Boot's r14 */ 60 lis %r11, saved_regs@ha 61 addi %r11, %r11, saved_regs@l 62 lwz %r14, 0(%r11) 63 /* Enable interrupts */ 64 mfmsr %r11 65 ori %r11, %r11, 0x8000@l 66 mtmsr %r11 67 /* Call into U-Boot */ 68 lis %r11, syscall_ptr@ha 69 addi %r11, %r11, syscall_ptr@l 70 lwz %r11, 0(%r11) 71 mtctr %r11 72 bctrl 73 /* Disable interrupts */ 74 mfmsr %r11 75 andi. %r11, %r11, ~0x8000@l 76 mtmsr %r11 77 /* Epilogue */ 78 lwz %r11, 0(%r1) 79 lwz %r0, 4(%r11) 80 mtlr %r0 81 lwz %r14, 8(%r1) 82 mr %r1, %r11 83 blr 84 85/* 86 * Data section 87 */ 88 .data 89GLOBAL(syscall_ptr) 90 .long 0 91GLOBAL(saved_regs) 92 .long 0 /* R14 */ 93GLOBAL(uboot_address) 94 .long 0 95