ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ppc64 / kernel / pSeries_hvCall.S
1 /*
2  * arch/ppc64/kernel/pSeries_hvCall.S
3  *
4  *
5  * This file contains the generic code to perform a call to the
6  * pSeries LPAR hypervisor.
7  * NOTE: this file will go away when we move to inline this work.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version
12  * 2 of the License, or (at your option) any later version.
13  */
14 #include <linux/sys.h>
15 #include <asm/unistd.h>
16 #include <asm/errno.h>
17 #include <asm/processor.h>
18 #include <asm/page.h>
19 #include <asm/cache.h>
20 #include <asm/ppc_asm.h>
21         
22 /*
23  * hcall interface to pSeries LPAR
24  */
25 #define HVSC .long 0x44000022
26
27 /* long plpar_hcall(unsigned long opcode,        R3 
28                  unsigned long arg1,             R4 
29                  unsigned long arg2,             R5 
30                  unsigned long arg3,             R6 
31                  unsigned long arg4,             R7 
32                  unsigned long *out1,            R8 
33                  unsigned long *out2,            R9
34                  unsigned long *out3);           R10
35  */
36
37         .text
38 _GLOBAL(plpar_hcall)
39         mfcr    r0
40         std     r0,-8(r1)
41         stdu    r1,-32(r1)
42
43         std     r8,-8(r1)       /* Save out ptrs. */
44         std     r9,-16(r1)
45         std     r10,-24(r1)
46         
47         HVSC                    /* invoke the hypervisor */
48
49         ld      r10,-8(r1)      /* Fetch r4-r7 ret args. */
50         std     r4,0(r10)
51         ld      r10,-16(r1)
52         std     r5,0(r10)
53         ld      r10,-24(r1)
54         std     r6,0(r10)
55
56         ld      r1,0(r1)
57         ld      r0,-8(r1)
58         mtcrf   0xff,r0
59         blr                     /* return r3 = status */
60
61
62 /* Simple interface with no output values (other than status) */
63 _GLOBAL(plpar_hcall_norets)
64         mfcr    r0
65         std     r0,-8(r1)
66         HVSC                    /* invoke the hypervisor */
67         ld      r0,-8(r1)
68         mtcrf   0xff,r0
69         blr                     /* return r3 = status */
70
71
72 /* long plpar_hcall_8arg_2ret(unsigned long opcode,              R3 
73                              unsigned long arg1,                 R4 
74                              unsigned long arg2,                 R5 
75                              unsigned long arg3,                 R6 
76                              unsigned long arg4,                 R7 
77                              unsigned long arg5,                 R8 
78                              unsigned long arg6,                 R9 
79                              unsigned long arg7,                 R10 
80                              unsigned long arg8,                 112(R1)
81                              unsigned long *out1);               120(R1)
82
83  */
84
85         .text
86 _GLOBAL(plpar_hcall_8arg_2ret)
87         mfcr    r0
88
89         ld              r11, 112(r1) /* put arg8 and out1 in R11 and R12 */
90         ld              r12, 120(r1)
91
92         std     r0,-8(r1)
93         stdu    r1,-32(r1)
94
95         std     r12,-8(r1)      /* Save out ptr */
96         
97         HVSC                    /* invoke the hypervisor */
98
99         ld      r10,-8(r1)      /* Fetch r4 ret arg */
100         std     r4,0(r10)
101
102         ld      r1,0(r1)
103         ld      r0,-8(r1)
104         mtcrf   0xff,r0
105         blr                     /* return r3 = status */
106
107
108 /* long plpar_hcall_4out(unsigned long opcode,   R3 
109                  unsigned long arg1,             R4 
110                  unsigned long arg2,             R5 
111                  unsigned long arg3,             R6 
112                  unsigned long arg4,             R7 
113                  unsigned long *out1,   (r4)     R8 
114                  unsigned long *out2,   (r5)     R9
115                  unsigned long *out3,   (r6)     R10
116                  unsigned long *out4);  (r7)     112(R1). From Parameter save area. 
117  */
118 _GLOBAL(plpar_hcall_4out)
119         mfcr    r0
120         std     r0,-8(r1)
121         ld      r14,112(r1)
122         stdu    r1,-48(r1) 
123
124         std     r8,32(r1)       /* Save out ptrs. */
125         std     r9,24(r1)
126         std     r10,16(r1)
127         std     r14,8(r1)
128         
129         HVSC                    /* invoke the hypervisor */
130
131         ld      r14,32(r1)      /* Fetch r4-r7 ret args. */
132         std     r4,0(r14)
133         ld      r14,24(r1)
134         std     r5,0(r14)
135         ld      r14,16(r1)
136         std     r6,0(r14)
137         ld      r14,8(r1)
138         std     r7,0(r14)
139
140         ld      r1,0(r1) 
141         ld      r0,-8(r1)
142         mtcrf   0xff,r0
143         blr                     /* return r3 = status */