1/* $NetBSD: printf.S,v 1.8 2011/01/10 16:43:29 tsutsui Exp $ */ 2 3/*- 4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jonathan Stone, Michael Hitch and Simon Burge. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <mips/asm.h> 33#include <mips/cpuregs.h> 34#include <machine/dec_prom.h> 35 36 .set noreorder 37LEAF(printf) 38 lw v0, _C_LABEL(callv) # get pointer to call back vectors 39 nop 40 lw t9, 0x30(v0) # offset for callv->_printf 41 nop 42#ifdef __mips_n32 43 /* 44 * If someone calls printf with more than 4 args on n32, 45 * we need to synthesize a o32 call. For now we assume no more than 46 * 8 arguments and no 64bit values. 47 */ 48 subu sp, sp, 48 49 sw a4, 16(sp) 50 sw a5, 20(sp) 51 sw a6, 24(sp) 52 sw a7, 28(sp) 53 sw ra, 44(sp) 54 jalr t9 # call PROM printf 55 nop 56 lw ra, 44(sp) 57 j ra 58 addu sp, sp, 48 59#else 60 j t9 # call PROM printf 61 nop 62#endif 63END(printf) 64