startprog.S revision 1.7
11.7Stsutsui/* $NetBSD: startprog.S,v 1.7 2011/01/07 14:50:27 tsutsui Exp $ */ 21.2Ssimonb 31.2Ssimonb/*- 41.2Ssimonb * Copyright (c) 1999 The NetBSD Foundation, Inc. 51.2Ssimonb * All rights reserved. 61.2Ssimonb * 71.2Ssimonb * This code is derived from software contributed to The NetBSD Foundation 81.2Ssimonb * by Jonathan Stone, Michael Hitch and Simon Burge. 91.2Ssimonb * 101.2Ssimonb * Redistribution and use in source and binary forms, with or without 111.2Ssimonb * modification, are permitted provided that the following conditions 121.2Ssimonb * are met: 131.2Ssimonb * 1. Redistributions of source code must retain the above copyright 141.2Ssimonb * notice, this list of conditions and the following disclaimer. 151.2Ssimonb * 2. Redistributions in binary form must reproduce the above copyright 161.2Ssimonb * notice, this list of conditions and the following disclaimer in the 171.2Ssimonb * documentation and/or other materials provided with the distribution. 181.2Ssimonb * 191.2Ssimonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.2Ssimonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.2Ssimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.2Ssimonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.2Ssimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.2Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.2Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.2Ssimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.2Ssimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.2Ssimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.2Ssimonb * POSSIBILITY OF SUCH DAMAGE. 301.2Ssimonb */ 311.2Ssimonb 321.1Ssimonb/* 331.1Ssimonb * startprog(entry, stack, argc, argv, prom_magic, prom_ptr, bi_magic, bi_ptr); 341.1Ssimonb * 351.1Ssimonb * load new stack pointer, then call 361.1Ssimonb * entry(argc, argv, prom_magic, prom_ptr, bi_magic, bi_ptr); 371.1Ssimonb */ 381.1Ssimonb 391.1Ssimonb#include <mips/asm.h> 401.1Ssimonb 411.7Stsutsui .set noreorder 421.1SsimonbLEAF(startprog) 431.5Smatt subu sp,sp,CALLFRAME_SIZ 441.5Smatt addu t2,a1,-CALLFRAME_SIZ # new stack value 451.5Smatt move t9,a0 461.1Ssimonb move a0,a2 471.1Ssimonb move a1,a3 481.1Ssimonb 491.5Smatt#ifdef __mips_o32 501.6Stsutsui lw a2,CALLFRAME_SIZ+16(sp) # load everything from old stack we need 511.6Stsutsui lw a3,CALLFRAME_SIZ+20(sp) 521.6Stsutsui lw $8,CALLFRAME_SIZ+24(sp) # use a4/t0 in case N32/N64 kernel 531.6Stsutsui lw $9,CALLFRAME_SIZ+28(sp) # use a5/t1 in case N32/N64 kernel 541.5Smatt#else 551.5Smatt move a2,a4 561.5Smatt move a3,a5 571.5Smatt move a4,a6 581.5Smatt move a5,a7 591.5Smatt#endif 601.5Smatt 611.5Smatt move sp,t2 # new stack pointer 621.5Smatt sw ra,CALLFRAME_RA(sp) 631.5Smatt 641.5Smatt sw $8,16(sp) # save on stack for O32 651.5Smatt sw $9,20(sp) # save on stack for O32 661.5Smatt jal ra,t9 671.1Ssimonb nop # BDslot 681.1Ssimonb 691.5Smatt lw ra,CALLFRAME_RA(sp) # should not get back here! 701.1Ssimonb j ra 711.5Smatt addu sp,sp,CALLFRAME_SIZ 721.1SsimonbEND(startprog) 73