1*157a6dd4Stsutsui/* $NetBSD: startprog.S,v 1.8 2011/01/10 15:25:44 tsutsui Exp $ */ 281ff761eSsimonb 381ff761eSsimonb/*- 481ff761eSsimonb * Copyright (c) 1999 The NetBSD Foundation, Inc. 581ff761eSsimonb * All rights reserved. 681ff761eSsimonb * 781ff761eSsimonb * This code is derived from software contributed to The NetBSD Foundation 881ff761eSsimonb * by Jonathan Stone, Michael Hitch and Simon Burge. 981ff761eSsimonb * 1081ff761eSsimonb * Redistribution and use in source and binary forms, with or without 1181ff761eSsimonb * modification, are permitted provided that the following conditions 1281ff761eSsimonb * are met: 1381ff761eSsimonb * 1. Redistributions of source code must retain the above copyright 1481ff761eSsimonb * notice, this list of conditions and the following disclaimer. 1581ff761eSsimonb * 2. Redistributions in binary form must reproduce the above copyright 1681ff761eSsimonb * notice, this list of conditions and the following disclaimer in the 1781ff761eSsimonb * documentation and/or other materials provided with the distribution. 1881ff761eSsimonb * 1981ff761eSsimonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2081ff761eSsimonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2181ff761eSsimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2281ff761eSsimonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2381ff761eSsimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2481ff761eSsimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2581ff761eSsimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2681ff761eSsimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2781ff761eSsimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2881ff761eSsimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2981ff761eSsimonb * POSSIBILITY OF SUCH DAMAGE. 3081ff761eSsimonb */ 3181ff761eSsimonb 3281ff761eSsimonb/* 3381ff761eSsimonb * startprog(entry, stack, argc, argv, prom_magic, prom_ptr, bi_magic, bi_ptr); 3481ff761eSsimonb * 3581ff761eSsimonb * load new stack pointer, then call 3681ff761eSsimonb * entry(argc, argv, prom_magic, prom_ptr, bi_magic, bi_ptr); 3781ff761eSsimonb */ 3881ff761eSsimonb 3981ff761eSsimonb#include <mips/asm.h> 4081ff761eSsimonb 4138b3ed96Stsutsui .set noreorder 4281ff761eSsimonbLEAF(startprog) 43290a34a0Smatt subu sp,sp,CALLFRAME_SIZ 44290a34a0Smatt addu t2,a1,-CALLFRAME_SIZ # new stack value 45290a34a0Smatt move t9,a0 4681ff761eSsimonb move a0,a2 4781ff761eSsimonb move a1,a3 4881ff761eSsimonb 49290a34a0Smatt#ifdef __mips_o32 50851a3a4cStsutsui lw a2,CALLFRAME_SIZ+16(sp) # load everything from old stack we need 51851a3a4cStsutsui lw a3,CALLFRAME_SIZ+20(sp) 52851a3a4cStsutsui lw $8,CALLFRAME_SIZ+24(sp) # use a4/t0 in case N32/N64 kernel 53851a3a4cStsutsui lw $9,CALLFRAME_SIZ+28(sp) # use a5/t1 in case N32/N64 kernel 54290a34a0Smatt#else 55290a34a0Smatt move a2,a4 56290a34a0Smatt move a3,a5 57290a34a0Smatt move a4,a6 58290a34a0Smatt move a5,a7 59290a34a0Smatt#endif 6081ff761eSsimonb 61290a34a0Smatt move sp,t2 # new stack pointer 62290a34a0Smatt sw ra,CALLFRAME_RA(sp) 6381ff761eSsimonb 64290a34a0Smatt sw $8,16(sp) # save on stack for O32 65290a34a0Smatt sw $9,20(sp) # save on stack for O32 66290a34a0Smatt jal ra,t9 6781ff761eSsimonb nop # BDslot 6881ff761eSsimonb 69290a34a0Smatt lw ra,CALLFRAME_RA(sp) # should not get back here! 7081ff761eSsimonb j ra 71290a34a0Smatt addu sp,sp,CALLFRAME_SIZ 7281ff761eSsimonbEND(startprog) 73