/*1* O32 interface for the 64 (or N32) ABI.2*3* Copyright (C) 2002 Maciej W. Rozycki4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License7* as published by the Free Software Foundation; either version8* 2 of the License, or (at your option) any later version.9*/1011#include <asm/asm.h>12#include <asm/regdef.h>1314/* Maximum number of arguments supported. Must be even! */15#define O32_ARGC 3216/* Number of static registers we save. */17#define O32_STATC 1118/* Frame size for static register */19#define O32_FRAMESZ (SZREG * O32_STATC)20/* Frame size on new stack */21#define O32_FRAMESZ_NEW (SZREG + 4 * O32_ARGC)2223.text2425/*26* O32 function call dispatcher, for interfacing 32-bit ROM routines.27*28* The standard 64 (N32) calling sequence is supported, with a029* holding a function pointer, a1 a new stack pointer, a2-a7 -- its30* first six arguments and the stack -- remaining ones (up to O32_ARGC,31* including a2-a7). Static registers, gp and fp are preserved, v0 holds32* a result. This code relies on the called o32 function for sp and ra33* restoration and this dispatcher has to be placed in a KSEGx (or KUSEG)34* address space. Any pointers passed have to point to addresses within35* one of these spaces as well.36*/37NESTED(call_o32, O32_FRAMESZ, ra)38REG_SUBU sp,O32_FRAMESZ3940REG_S ra,O32_FRAMESZ-1*SZREG(sp)41REG_S fp,O32_FRAMESZ-2*SZREG(sp)42REG_S gp,O32_FRAMESZ-3*SZREG(sp)43REG_S s7,O32_FRAMESZ-4*SZREG(sp)44REG_S s6,O32_FRAMESZ-5*SZREG(sp)45REG_S s5,O32_FRAMESZ-6*SZREG(sp)46REG_S s4,O32_FRAMESZ-7*SZREG(sp)47REG_S s3,O32_FRAMESZ-8*SZREG(sp)48REG_S s2,O32_FRAMESZ-9*SZREG(sp)49REG_S s1,O32_FRAMESZ-10*SZREG(sp)50REG_S s0,O32_FRAMESZ-11*SZREG(sp)5152move jp,a053REG_SUBU s0,a1,O32_FRAMESZ_NEW54REG_S sp,O32_FRAMESZ_NEW-1*SZREG(s0)5556sll a0,a2,zero57sll a1,a3,zero58sll a2,a4,zero59sll a3,a5,zero60sw a6,0x10(s0)61sw a7,0x14(s0)6263PTR_LA t0,O32_FRAMESZ(sp)64PTR_LA t1,0x18(s0)65li t2,O32_ARGC-6661:67lw t3,(t0)68REG_ADDU t0,SZREG69sw t3,(t1)70REG_SUBU t2,171REG_ADDU t1,472bnez t2,1b7374move sp,s07576jalr jp7778REG_L sp,O32_FRAMESZ_NEW-1*SZREG(sp)7980REG_L s0,O32_FRAMESZ-11*SZREG(sp)81REG_L s1,O32_FRAMESZ-10*SZREG(sp)82REG_L s2,O32_FRAMESZ-9*SZREG(sp)83REG_L s3,O32_FRAMESZ-8*SZREG(sp)84REG_L s4,O32_FRAMESZ-7*SZREG(sp)85REG_L s5,O32_FRAMESZ-6*SZREG(sp)86REG_L s6,O32_FRAMESZ-5*SZREG(sp)87REG_L s7,O32_FRAMESZ-4*SZREG(sp)88REG_L gp,O32_FRAMESZ-3*SZREG(sp)89REG_L fp,O32_FRAMESZ-2*SZREG(sp)90REG_L ra,O32_FRAMESZ-1*SZREG(sp)9192REG_ADDU sp,O32_FRAMESZ93jr ra94END(call_o32)959697