aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/fw/lib/call_o32.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/fw/lib/call_o32.S')
-rw-r--r--arch/mips/fw/lib/call_o32.S57
1 files changed, 35 insertions, 22 deletions
diff --git a/arch/mips/fw/lib/call_o32.S b/arch/mips/fw/lib/call_o32.S
index b308b2a0613e..4703fe4dbd9a 100644
--- a/arch/mips/fw/lib/call_o32.S
+++ b/arch/mips/fw/lib/call_o32.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * O32 interface for the 64 (or N32) ABI. 2 * O32 interface for the 64 (or N32) ABI.
3 * 3 *
4 * Copyright (C) 2002 Maciej W. Rozycki 4 * Copyright (C) 2002, 2014 Maciej W. Rozycki
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -12,28 +12,37 @@
12#include <asm/asm.h> 12#include <asm/asm.h>
13#include <asm/regdef.h> 13#include <asm/regdef.h>
14 14
15/* O32 register size. */
16#define O32_SZREG 4
15/* Maximum number of arguments supported. Must be even! */ 17/* Maximum number of arguments supported. Must be even! */
16#define O32_ARGC 32 18#define O32_ARGC 32
17/* Number of static registers we save. */ 19/* Number of static registers we save. */
18#define O32_STATC 11 20#define O32_STATC 11
19/* Frame size for static register */ 21/* Argument area frame size. */
20#define O32_FRAMESZ (SZREG * O32_STATC) 22#define O32_ARGSZ (O32_SZREG * O32_ARGC)
21/* Frame size on new stack */ 23/* Static register save area frame size. */
22#define O32_FRAMESZ_NEW (SZREG + 4 * O32_ARGC) 24#define O32_STATSZ (SZREG * O32_STATC)
25/* Stack pointer register save area frame size. */
26#define O32_SPSZ SZREG
27/* Combined area frame size. */
28#define O32_FRAMESZ (O32_ARGSZ + O32_SPSZ + O32_STATSZ)
29/* Switched stack frame size. */
30#define O32_NFRAMESZ (O32_ARGSZ + O32_SPSZ)
23 31
24 .text 32 .text
25 33
26/* 34/*
27 * O32 function call dispatcher, for interfacing 32-bit ROM routines. 35 * O32 function call dispatcher, for interfacing 32-bit ROM routines.
28 * 36 *
29 * The standard 64 (N32) calling sequence is supported, with a0 37 * The standard 64 (N32) calling sequence is supported, with a0 holding
30 * holding a function pointer, a1 a new stack pointer, a2-a7 -- its 38 * a function pointer, a1 a pointer to the new stack to call the
31 * first six arguments and the stack -- remaining ones (up to O32_ARGC, 39 * function with or 0 if no stack switching is requested, a2-a7 -- the
32 * including a2-a7). Static registers, gp and fp are preserved, v0 holds 40 * function call's first six arguments, and the stack -- the remaining
33 * a result. This code relies on the called o32 function for sp and ra 41 * arguments (up to O32_ARGC, including a2-a7). Static registers, gp
34 * restoration and this dispatcher has to be placed in a KSEGx (or KUSEG) 42 * and fp are preserved, v0 holds the result. This code relies on the
35 * address space. Any pointers passed have to point to addresses within 43 * called o32 function for sp and ra restoration and this dispatcher has
36 * one of these spaces as well. 44 * to be placed in a KSEGx (or KUSEG) address space. Any pointers
45 * passed have to point to addresses within one of these spaces as well.
37 */ 46 */
38NESTED(call_o32, O32_FRAMESZ, ra) 47NESTED(call_o32, O32_FRAMESZ, ra)
39 REG_SUBU sp,O32_FRAMESZ 48 REG_SUBU sp,O32_FRAMESZ
@@ -51,32 +60,36 @@ NESTED(call_o32, O32_FRAMESZ, ra)
51 REG_S s0,O32_FRAMESZ-11*SZREG(sp) 60 REG_S s0,O32_FRAMESZ-11*SZREG(sp)
52 61
53 move jp,a0 62 move jp,a0
54 REG_SUBU s0,a1,O32_FRAMESZ_NEW 63
55 REG_S sp,O32_FRAMESZ_NEW-1*SZREG(s0) 64 move fp,sp
65 beqz a1,0f
66 REG_SUBU fp,a1,O32_NFRAMESZ
670:
68 REG_S sp,O32_NFRAMESZ-1*SZREG(fp)
56 69
57 sll a0,a2,zero 70 sll a0,a2,zero
58 sll a1,a3,zero 71 sll a1,a3,zero
59 sll a2,a4,zero 72 sll a2,a4,zero
60 sll a3,a5,zero 73 sll a3,a5,zero
61 sw a6,0x10(s0) 74 sw a6,4*O32_SZREG(fp)
62 sw a7,0x14(s0) 75 sw a7,5*O32_SZREG(fp)
63 76
64 PTR_LA t0,O32_FRAMESZ(sp) 77 PTR_LA t0,O32_FRAMESZ(sp)
65 PTR_LA t1,0x18(s0) 78 PTR_LA t1,6*O32_SZREG(fp)
66 li t2,O32_ARGC-6 79 li t2,O32_ARGC-6
671: 801:
68 lw t3,(t0) 81 lw t3,(t0)
69 REG_ADDU t0,SZREG 82 REG_ADDU t0,SZREG
70 sw t3,(t1) 83 sw t3,(t1)
71 REG_SUBU t2,1 84 REG_SUBU t2,1
72 REG_ADDU t1,4 85 REG_ADDU t1,O32_SZREG
73 bnez t2,1b 86 bnez t2,1b
74 87
75 move sp,s0 88 move sp,fp
76 89
77 jalr jp 90 jalr jp
78 91
79 REG_L sp,O32_FRAMESZ_NEW-1*SZREG(sp) 92 REG_L sp,O32_NFRAMESZ-1*SZREG(sp)
80 93
81 REG_L s0,O32_FRAMESZ-11*SZREG(sp) 94 REG_L s0,O32_FRAMESZ-11*SZREG(sp)
82 REG_L s1,O32_FRAMESZ-10*SZREG(sp) 95 REG_L s1,O32_FRAMESZ-10*SZREG(sp)