xref: /freebsd/stand/uboot/arch/powerpc/start.S (revision b3e76948)
19dc70af8SWarner Losh/*-
29dc70af8SWarner Losh * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
39dc70af8SWarner Losh * All rights reserved.
49dc70af8SWarner Losh *
59dc70af8SWarner Losh * Redistribution and use in source and binary forms, with or without
69dc70af8SWarner Losh * modification, are permitted provided that the following conditions
79dc70af8SWarner Losh * are met:
89dc70af8SWarner Losh * 1. Redistributions of source code must retain the above copyright
99dc70af8SWarner Losh *    notice, this list of conditions and the following disclaimer.
109dc70af8SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright
119dc70af8SWarner Losh *    notice, this list of conditions and the following disclaimer in the
129dc70af8SWarner Losh *    documentation and/or other materials provided with the distribution.
139dc70af8SWarner Losh *
149dc70af8SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
159dc70af8SWarner Losh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
169dc70af8SWarner Losh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
179dc70af8SWarner Losh * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
189dc70af8SWarner Losh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199dc70af8SWarner Losh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
209dc70af8SWarner Losh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
219dc70af8SWarner Losh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
229dc70af8SWarner Losh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
239dc70af8SWarner Losh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
249dc70af8SWarner Losh * SUCH DAMAGE.
259dc70af8SWarner Losh */
269dc70af8SWarner Losh
279dc70af8SWarner Losh#include <machine/asm.h>
289dc70af8SWarner Losh
299dc70af8SWarner Losh/*
309dc70af8SWarner Losh * Entry point to the loader that U-Boot passes control to.
319dc70af8SWarner Losh */
329dc70af8SWarner Losh	.text
339dc70af8SWarner Losh	.globl	_start
349dc70af8SWarner Losh_start:
359dc70af8SWarner Losh	/* Hint where to look for the API signature */
369dc70af8SWarner Losh	lis	%r11, uboot_address@ha
379dc70af8SWarner Losh	addi	%r11, %r11, uboot_address@l
389dc70af8SWarner Losh	stw	%r1, 0(%r11)
399dc70af8SWarner Losh	/* Save U-Boot's r14 and r30 */
409dc70af8SWarner Losh	lis	%r11, saved_regs@ha
419dc70af8SWarner Losh	addi	%r11, %r11, saved_regs@l
429dc70af8SWarner Losh	stw	%r14, 0(%r11)
439dc70af8SWarner Losh	stw	%r30, 4(%r11)
449dc70af8SWarner Losh	/* Disable interrupts */
459dc70af8SWarner Losh	mfmsr	%r11
469dc70af8SWarner Losh	andi.	%r11, %r11, ~0x8000@l
479dc70af8SWarner Losh	mtmsr	%r11
489dc70af8SWarner Losh	b	main
499dc70af8SWarner Losh
509dc70af8SWarner Losh/*
519dc70af8SWarner Losh * syscall()
529dc70af8SWarner Losh */
539dc70af8SWarner LoshENTRY(syscall)
549dc70af8SWarner Losh	stwu	%r1, -32(%r1)
559dc70af8SWarner Losh	mflr	%r0
569dc70af8SWarner Losh	stw	%r14, 8(%r1)
579dc70af8SWarner Losh	stw	%r30, 12(%r1)
589dc70af8SWarner Losh	stw	%r0, 36(%r1)
599dc70af8SWarner Losh	/* Restore U-Boot's r14 and r30 */
609dc70af8SWarner Losh	lis	%r11, saved_regs@ha
619dc70af8SWarner Losh	addi	%r11, %r11, saved_regs@l
629dc70af8SWarner Losh	lwz	%r14, 0(%r11)
639dc70af8SWarner Losh	lwz	%r30, 4(%r11)
649dc70af8SWarner Losh	/* Enable interrupts */
659dc70af8SWarner Losh	mfmsr	%r11
669dc70af8SWarner Losh	ori	%r11, %r11, 0x8000@l
679dc70af8SWarner Losh	mtmsr	%r11
689dc70af8SWarner Losh	/* Call into U-Boot */
699dc70af8SWarner Losh	lis	%r11, syscall_ptr@ha
709dc70af8SWarner Losh	addi	%r11, %r11, syscall_ptr@l
719dc70af8SWarner Losh	lwz	%r11, 0(%r11)
729dc70af8SWarner Losh	mtctr	%r11
739dc70af8SWarner Losh	bctrl
749dc70af8SWarner Losh	/* Disable interrupts */
759dc70af8SWarner Losh	mfmsr	%r11
769dc70af8SWarner Losh	andi.	%r11, %r11, ~0x8000@l
779dc70af8SWarner Losh	mtmsr	%r11
789dc70af8SWarner Losh	/* Epilogue */
799dc70af8SWarner Losh	lwz	%r11, 0(%r1)
809dc70af8SWarner Losh	lwz	%r0, 4(%r11)
819dc70af8SWarner Losh	mtlr	%r0
829dc70af8SWarner Losh	lwz	%r14, 8(%r1)
839dc70af8SWarner Losh	lwz	%r30, 12(%r1)
849dc70af8SWarner Losh	mr	%r1, %r11
859dc70af8SWarner Losh	blr
869dc70af8SWarner LoshEND(syscall)
879dc70af8SWarner Losh
889dc70af8SWarner Losh/*
899dc70af8SWarner Losh * Data section
909dc70af8SWarner Losh */
919dc70af8SWarner Losh	.data
929dc70af8SWarner LoshGLOBAL(syscall_ptr)
939dc70af8SWarner Losh	.long	0
949dc70af8SWarner LoshGLOBAL(saved_regs)
959dc70af8SWarner Losh	.long	0	/* R14 */
969dc70af8SWarner Losh	.long	0	/* R30 */
979dc70af8SWarner LoshGLOBAL(uboot_address)
989dc70af8SWarner Losh	.long	0
99