1*1c53db49Stsutsui/* $NetBSD: printf.S,v 1.9 2011/03/26 15:49:26 tsutsui Exp $ */ 2360739d5Ssimonb 3360739d5Ssimonb/*- 4360739d5Ssimonb * Copyright (c) 1999 The NetBSD Foundation, Inc. 5360739d5Ssimonb * All rights reserved. 6360739d5Ssimonb * 7360739d5Ssimonb * This code is derived from software contributed to The NetBSD Foundation 8360739d5Ssimonb * by Jonathan Stone, Michael Hitch and Simon Burge. 9360739d5Ssimonb * 10360739d5Ssimonb * Redistribution and use in source and binary forms, with or without 11360739d5Ssimonb * modification, are permitted provided that the following conditions 12360739d5Ssimonb * are met: 13360739d5Ssimonb * 1. Redistributions of source code must retain the above copyright 14360739d5Ssimonb * notice, this list of conditions and the following disclaimer. 15360739d5Ssimonb * 2. Redistributions in binary form must reproduce the above copyright 16360739d5Ssimonb * notice, this list of conditions and the following disclaimer in the 17360739d5Ssimonb * documentation and/or other materials provided with the distribution. 18360739d5Ssimonb * 19360739d5Ssimonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20360739d5Ssimonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21360739d5Ssimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22360739d5Ssimonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23360739d5Ssimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24360739d5Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25360739d5Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26360739d5Ssimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27360739d5Ssimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28360739d5Ssimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29360739d5Ssimonb * POSSIBILITY OF SUCH DAMAGE. 30360739d5Ssimonb */ 31360739d5Ssimonb 32360739d5Ssimonb#include <mips/asm.h> 33360739d5Ssimonb#include <mips/cpuregs.h> 34360739d5Ssimonb#include <machine/dec_prom.h> 35360739d5Ssimonb 36*1c53db49Stsutsui .set reorder # make as(1) handle hazard and BDslot 37360739d5SsimonbLEAF(printf) 38360739d5Ssimonb lw v0, _C_LABEL(callv) # get pointer to call back vectors 39290a34a0Smatt lw t9, 0x30(v0) # offset for callv->_printf 40290a34a0Smatt#ifdef __mips_n32 41290a34a0Smatt /* 42290a34a0Smatt * If someone calls printf with more than 4 args on n32, 43290a34a0Smatt * we need to synthesize a o32 call. For now we assume no more than 44290a34a0Smatt * 8 arguments and no 64bit values. 45290a34a0Smatt */ 46290a34a0Smatt subu sp, sp, 48 47290a34a0Smatt sw a4, 16(sp) 48290a34a0Smatt sw a5, 20(sp) 49290a34a0Smatt sw a6, 24(sp) 50290a34a0Smatt sw a7, 28(sp) 51290a34a0Smatt sw ra, 44(sp) 52290a34a0Smatt jalr t9 # call PROM printf 53290a34a0Smatt lw ra, 44(sp) 54290a34a0Smatt addu sp, sp, 48 55*1c53db49Stsutsui j ra 56290a34a0Smatt#else 57290a34a0Smatt j t9 # call PROM printf 58290a34a0Smatt#endif 59360739d5SsimonbEND(printf) 60