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