1*ce099b40Smartin/* $NetBSD: start.S,v 1.3 2008/04/28 20:23:29 martin Exp $ */ 2a3ec1726Swdk 3a3ec1726Swdk/* 4a3ec1726Swdk * Copyright (c) 2000 The NetBSD Foundation, Inc. 5a3ec1726Swdk * All rights reserved. 6a3ec1726Swdk * 7a3ec1726Swdk * This code is derived from software contributed to The NetBSD Foundation 8a3ec1726Swdk * by Wayne Knowles 9a3ec1726Swdk * 10a3ec1726Swdk * Redistribution and use in source and binary forms, with or without 11a3ec1726Swdk * modification, are permitted provided that the following conditions 12a3ec1726Swdk * are met: 13a3ec1726Swdk * 1. Redistributions of source code must retain the above copyright 14a3ec1726Swdk * notice, this list of conditions and the following disclaimer. 15a3ec1726Swdk * 2. Redistributions in binary form must reproduce the above copyright 16a3ec1726Swdk * notice, this list of conditions and the following disclaimer in the 17a3ec1726Swdk * documentation and/or other materials provided with the distribution. 18a3ec1726Swdk * 19a3ec1726Swdk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20a3ec1726Swdk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21a3ec1726Swdk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22a3ec1726Swdk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23a3ec1726Swdk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24a3ec1726Swdk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25a3ec1726Swdk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26a3ec1726Swdk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27a3ec1726Swdk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28a3ec1726Swdk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29a3ec1726Swdk * POSSIBILITY OF SUCH DAMAGE. 30a3ec1726Swdk */ 31a3ec1726Swdk 32a3ec1726Swdk#include <mips/asm.h> 33a3ec1726Swdk#include <mips/cpuregs.h> 34a3ec1726Swdk#include <machine/prom.h> 35a3ec1726Swdk 36a3ec1726SwdkLEAF(start) 3716364da1Swdk .set noreorder 38a3ec1726Swdk#ifdef __GP_SUPPORT__ 39a3ec1726Swdk la gp, _C_LABEL (_gp) 40a3ec1726Swdk#endif 41a3ec1726Swdk la sp, start - CALLFRAME_SIZ 42a3ec1726Swdk sw zero, CALLFRAME_RA(sp) # clear ra for debugger 43a3ec1726Swdk sw zero, CALLFRAME_SP(sp) # clear fp for debugger 44a3ec1726Swdk move s0, a0 # save argc 45a3ec1726Swdk move s1, a1 # save argv 46a3ec1726Swdk 47a3ec1726Swdk la a0, _C_LABEL (edata) # clear BSS 48a3ec1726Swdk move a1, zero 49a3ec1726Swdk la a2, _C_LABEL (end) 50a3ec1726Swdk jal _C_LABEL(memset) # memset(edata, 0, end - edata) 51a3ec1726Swdk subu a2, a2, a0 52a3ec1726Swdk 53a3ec1726Swdk move a0, s0 # restore argc 54a3ec1726Swdk jal _C_LABEL(main) # main(argc, argv) 55a3ec1726Swdk move a1, s1 # restore argv 56a3ec1726Swdk 57a3ec1726SwdkXLEAF(_rtt) 5816364da1Swdk la t9, _C_LABEL(prom_restart) # restart... 5916364da1Swdk j t9 6016364da1Swdk move a0, zero 61a3ec1726SwdkEND(start) 62