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_HCALL_STATS
19 * precall must preserve all registers. use unused STK_PARM()
20 * areas to save snapshots and opcode.
22 #define HCALL_INST_PRECALL \
23 std r3,STK_PARM(r3)(r1); /* save opcode */ \
24 mftb r0; /* get timebase and */ \
25 std r0,STK_PARM(r5)(r1); /* save for later */ \
27 mfspr r0,SPRN_PURR; /* get PURR and */ \
28 std r0,STK_PARM(r6)(r1); /* save for later */ \
29 END_FTR_SECTION_IFSET(CPU_FTR_PURR);
32 * postcall is performed immediately before function return which
33 * allows liberal use of volatile registers. We branch around this
34 * in early init (eg when populating the MMU hashtable) by using an
35 * unconditional cpu feature.
37 #define HCALL_INST_POSTCALL \
40 END_FTR_SECTION(0, 1); \
41 ld r4,STK_PARM(r3)(r1); /* validate opcode */ \
42 cmpldi cr7,r4,MAX_HCALL_OPCODE; \
45 /* get time and PURR snapshots after hcall */ \
46 mftb r7; /* timebase after */ \
48 mfspr r8,SPRN_PURR; /* PURR after */ \
49 ld r6,STK_PARM(r6)(r1); /* PURR before */ \
50 subf r6,r6,r8; /* delta */ \
51 END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
52 ld r5,STK_PARM(r5)(r1); /* timebase before */ \
53 subf r5,r5,r7; /* time delta */ \
55 /* calculate address of stat structure r4 = opcode */ \
56 srdi r4,r4,2; /* index into array */ \
57 mulli r4,r4,HCALL_STAT_SIZE; \
58 LOAD_REG_ADDR(r7, per_cpu__hcall_stats); \
60 ld r7,PACA_DATA_OFFSET(r13); /* per cpu offset */ \
64 ld r7,HCALL_STAT_CALLS(r4); /* count */ \
66 std r7,HCALL_STAT_CALLS(r4); \
67 ld r7,HCALL_STAT_TB(r4); /* timebase */ \
69 std r7,HCALL_STAT_TB(r4); \
71 ld r7,HCALL_STAT_PURR(r4); /* PURR */ \
73 std r7,HCALL_STAT_PURR(r4); \
74 END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
77 #define HCALL_INST_PRECALL
78 #define HCALL_INST_POSTCALL
83 _GLOBAL(plpar_hcall_norets)
91 HVSC /* invoke the hypervisor */
97 blr /* return r3 = status */
107 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
116 HVSC /* invoke the hypervisor */
118 ld r12,STK_PARM(r4)(r1)
129 blr /* return r3 = status */
132 * plpar_hcall_raw can be called in real mode. kexec/kdump need some
133 * hypervisor calls to be executed in real mode. So plpar_hcall_raw
134 * does not access the per cpu hypervisor call statistics variables,
135 * since these variables may not be present in the RMO region.
137 _GLOBAL(plpar_hcall_raw)
143 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
152 HVSC /* invoke the hypervisor */
154 ld r12,STK_PARM(r4)(r1)
163 blr /* return r3 = status */
165 _GLOBAL(plpar_hcall9)
173 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
181 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
182 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
183 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
185 HVSC /* invoke the hypervisor */
188 ld r12,STK_PARM(r4)(r1)
204 blr /* return r3 = status */