2 * This file contains the generic code to perform a call to the
3 * pSeries LPAR hypervisor.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
10 #include <asm/hvcall.h>
11 #include <asm/processor.h>
12 #include <asm/ppc_asm.h>
13 #include <asm/asm-offsets.h>
15 #define STK_PARM(i) (48 + ((i)-3)*8)
17 #ifdef CONFIG_TRACEPOINTS
21 .globl hcall_tracepoint_refcount
22 hcall_tracepoint_refcount:
28 * precall must preserve all registers. use unused STK_PARM()
29 * areas to save snapshots and opcode. We branch around this
30 * in early init (eg when populating the MMU hashtable) by using an
31 * unconditional cpu feature.
33 #define HCALL_INST_PRECALL(FIRST_REG) \
36 END_FTR_SECTION(0, 1); \
37 ld r12,hcall_tracepoint_refcount@toc(r2); \
41 std r3,STK_PARM(r3)(r1); \
42 std r4,STK_PARM(r4)(r1); \
43 std r5,STK_PARM(r5)(r1); \
44 std r6,STK_PARM(r6)(r1); \
45 std r7,STK_PARM(r7)(r1); \
46 std r8,STK_PARM(r8)(r1); \
47 std r9,STK_PARM(r9)(r1); \
48 std r10,STK_PARM(r10)(r1); \
50 addi r4,r1,STK_PARM(FIRST_REG); \
51 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
52 bl .__trace_hcall_entry; \
53 addi r1,r1,STACK_FRAME_OVERHEAD; \
55 ld r3,STK_PARM(r3)(r1); \
56 ld r4,STK_PARM(r4)(r1); \
57 ld r5,STK_PARM(r5)(r1); \
58 ld r6,STK_PARM(r6)(r1); \
59 ld r7,STK_PARM(r7)(r1); \
60 ld r8,STK_PARM(r8)(r1); \
61 ld r9,STK_PARM(r9)(r1); \
62 ld r10,STK_PARM(r10)(r1); \
67 * postcall is performed immediately before function return which
68 * allows liberal use of volatile registers. We branch around this
69 * in early init (eg when populating the MMU hashtable) by using an
70 * unconditional cpu feature.
72 #define __HCALL_INST_POSTCALL \
75 END_FTR_SECTION(0, 1); \
76 ld r12,hcall_tracepoint_refcount@toc(r2); \
80 ld r6,STK_PARM(r3)(r1); \
81 std r3,STK_PARM(r3)(r1); \
85 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
86 bl .__trace_hcall_exit; \
87 addi r1,r1,STACK_FRAME_OVERHEAD; \
89 ld r3,STK_PARM(r3)(r1); \
93 #define HCALL_INST_POSTCALL_NORETS \
97 #define HCALL_INST_POSTCALL(BUFREG) \
102 #define HCALL_INST_PRECALL(FIRST_ARG)
103 #define HCALL_INST_POSTCALL_NORETS
104 #define HCALL_INST_POSTCALL(BUFREG)
109 _GLOBAL(plpar_hcall_norets)
115 HCALL_INST_PRECALL(r4)
117 HVSC /* invoke the hypervisor */
119 HCALL_INST_POSTCALL_NORETS
123 blr /* return r3 = status */
131 HCALL_INST_PRECALL(r5)
133 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
142 HVSC /* invoke the hypervisor */
144 ld r12,STK_PARM(r4)(r1)
150 HCALL_INST_POSTCALL(r12)
155 blr /* return r3 = status */
158 * plpar_hcall_raw can be called in real mode. kexec/kdump need some
159 * hypervisor calls to be executed in real mode. So plpar_hcall_raw
160 * does not access the per cpu hypervisor call statistics variables,
161 * since these variables may not be present in the RMO region.
163 _GLOBAL(plpar_hcall_raw)
169 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
178 HVSC /* invoke the hypervisor */
180 ld r12,STK_PARM(r4)(r1)
189 blr /* return r3 = status */
191 _GLOBAL(plpar_hcall9)
197 HCALL_INST_PRECALL(r5)
199 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
207 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
208 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
209 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
211 HVSC /* invoke the hypervisor */
214 ld r12,STK_PARM(r4)(r1)
225 HCALL_INST_POSTCALL(r12)
230 blr /* return r3 = status */