xref: /netbsd-src/sys/arch/sgimips/stand/common/start.S (revision 23347d39ed32835d3b56fee0427953d4f958b460)
1*23347d39Smatt/*	$NetBSD: start.S,v 1.6 2011/02/20 07:59:52 matt Exp $	*/
24e63f44fSthorpej
34e63f44fSthorpej/*-
44e63f44fSthorpej * Copyright (c) 1999 The NetBSD Foundation, Inc.
54e63f44fSthorpej * All rights reserved.
64e63f44fSthorpej *
74e63f44fSthorpej * This code is derived from software contributed to The NetBSD Foundation
84e63f44fSthorpej * by Jonathan Stone, Michael Hitch and Simon Burge.
94e63f44fSthorpej *
104e63f44fSthorpej * Redistribution and use in source and binary forms, with or without
114e63f44fSthorpej * modification, are permitted provided that the following conditions
124e63f44fSthorpej * are met:
134e63f44fSthorpej * 1. Redistributions of source code must retain the above copyright
144e63f44fSthorpej *    notice, this list of conditions and the following disclaimer.
154e63f44fSthorpej * 2. Redistributions in binary form must reproduce the above copyright
164e63f44fSthorpej *    notice, this list of conditions and the following disclaimer in the
174e63f44fSthorpej *    documentation and/or other materials provided with the distribution.
184e63f44fSthorpej *
194e63f44fSthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
204e63f44fSthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
214e63f44fSthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
224e63f44fSthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
234e63f44fSthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
244e63f44fSthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
254e63f44fSthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
264e63f44fSthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
274e63f44fSthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
284e63f44fSthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
294e63f44fSthorpej * POSSIBILITY OF SUCH DAMAGE.
304e63f44fSthorpej */
314e63f44fSthorpej
324e63f44fSthorpej/*
334e63f44fSthorpej * Copyright (c) 1992, 1993
344e63f44fSthorpej *	The Regents of the University of California.  All rights reserved.
354e63f44fSthorpej *
364e63f44fSthorpej * This code is derived from software contributed to Berkeley by
374e63f44fSthorpej * Ralph Campbell.
384e63f44fSthorpej *
394e63f44fSthorpej * Redistribution and use in source and binary forms, with or without
404e63f44fSthorpej * modification, are permitted provided that the following conditions
414e63f44fSthorpej * are met:
424e63f44fSthorpej * 1. Redistributions of source code must retain the above copyright
434e63f44fSthorpej *    notice, this list of conditions and the following disclaimer.
444e63f44fSthorpej * 2. Redistributions in binary form must reproduce the above copyright
454e63f44fSthorpej *    notice, this list of conditions and the following disclaimer in the
464e63f44fSthorpej *    documentation and/or other materials provided with the distribution.
47aad01611Sagc * 3. Neither the name of the University nor the names of its contributors
484e63f44fSthorpej *    may be used to endorse or promote products derived from this software
494e63f44fSthorpej *    without specific prior written permission.
504e63f44fSthorpej *
514e63f44fSthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
524e63f44fSthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
534e63f44fSthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
544e63f44fSthorpej * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
554e63f44fSthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
564e63f44fSthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
574e63f44fSthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
584e63f44fSthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
594e63f44fSthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
604e63f44fSthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
614e63f44fSthorpej * SUCH DAMAGE.
624e63f44fSthorpej *
634e63f44fSthorpej *	@(#)start.s	8.2 (Berkeley) 1/21/94
644e63f44fSthorpej */
654e63f44fSthorpej
664e63f44fSthorpej/*
674e63f44fSthorpej * start.s -
684e63f44fSthorpej *
694e63f44fSthorpej *	Contains code that is the first executed at boot time.
704e63f44fSthorpej *
714e63f44fSthorpej *	Copyright (C) 1989 Digital Equipment Corporation.
724e63f44fSthorpej *	Permission to use, copy, modify, and distribute this software and
734e63f44fSthorpej *	its documentation for any purpose and without fee is hereby granted,
744e63f44fSthorpej *	provided that the above copyright notice appears in all copies.
754e63f44fSthorpej *	Digital Equipment Corporation makes no representations about the
764e63f44fSthorpej *	suitability of this software for any purpose.  It is provided "as is"
774e63f44fSthorpej *	without express or implied warranty.
784e63f44fSthorpej *
794e63f44fSthorpej * from: Header: /sprite/src/boot/decprom/ds3100.md/RCS/start.s,
804e63f44fSthorpej *	v 1.1 90/02/16 16:19:39 shirriff Exp  SPRITE (DECWRL)
814e63f44fSthorpej */
824e63f44fSthorpej
834e63f44fSthorpej#include <mips/asm.h>
844e63f44fSthorpej#include <mips/cpuregs.h>
854e63f44fSthorpej
86*23347d39Smatt#include "assym.h"
874e63f44fSthorpej
884e63f44fSthorpej	.globl	start
894e63f44fSthorpejstart:
904e63f44fSthorpej	.set	noreorder
914e63f44fSthorpej#ifdef __GP_SUPPORT__
92*23347d39Smatt	PTR_LA	gp, _C_LABEL (_gp)
934e63f44fSthorpej#endif
94*23347d39Smatt	/*
95*23347d39Smatt	 * We assume the bootprom isn't expecting us to preserve the saved
96*23347d39Smatt	 * registers.
97*23347d39Smatt	 */
98*23347d39Smatt	move	s0, a0				# save argc
99*23347d39Smatt	move	s1, a1				# save argv
100*23347d39Smatt	move	s2, a2				# save envp
101*23347d39Smatt	move	s3, ra				# save RA
102*23347d39Smatt	PTR_LA	v0, 0x80001000			# ARCBIOS_SPB
103*23347d39Smatt	PTR_LA	a0, _C_LABEL (edata)		# clear BSS
104*23347d39Smatt	INT_L	v0, SPB_FirmwareVector(v0)	# FirmwareVector
1054e63f44fSthorpej	move	a1, zero
106*23347d39Smatt	PTR_S	v0, _C_LABEL(ARCBIOS)		# save ARCBIOS
107*23347d39Smatt	PTR_LA	a2, _C_LABEL (end)
1084e63f44fSthorpej	jal	_C_LABEL(memset)		# memset(edata, 0, end - edata)
109*23347d39Smatt	 PTR_SUBU a2, a2, a0
110*23347d39Smatt	move	a0, s0				# restore argc
111*23347d39Smatt	move	a1, s1				# restore argv
112*23347d39Smatt	move	a2, s2				# restore envp
113*23347d39Smatt	j	_C_LABEL(main)			# main(argc, argv)
114*23347d39Smatt	 move	ra, s3				# restore RA
1154e63f44fSthorpej
1164e63f44fSthorpej	.globl	_rtt
1174e63f44fSthorpej_rtt:
1184e63f44fSthorpej	j	ra				# XXXX return to PROM?
1194e63f44fSthorpej
1204e63f44fSthorpej	.data
1214e63f44fSthorpej	.global	ARCBIOS
122*23347d39SmattARCBIOS: PTR_WORD	0
123