Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6] / arch / powerpc / platforms / pseries / plpar_wrappers.h
1 #ifndef _PSERIES_PLPAR_WRAPPERS_H
2 #define _PSERIES_PLPAR_WRAPPERS_H
3
4 #include <asm/hvcall.h>
5
6 static inline long poll_pending(void)
7 {
8         return plpar_hcall_norets(H_POLL_PENDING);
9 }
10
11 static inline long prod_processor(void)
12 {
13         return plpar_hcall_norets(H_PROD);
14 }
15
16 static inline long cede_processor(void)
17 {
18         return plpar_hcall_norets(H_CEDE);
19 }
20
21 static inline long vpa_call(unsigned long flags, unsigned long cpu,
22                 unsigned long vpa)
23 {
24         /* flags are in bits 16-18 (counting from most significant bit) */
25         flags = flags << (63 - 18);
26
27         return plpar_hcall_norets(H_REGISTER_VPA, flags, cpu, vpa);
28 }
29
30 static inline long unregister_vpa(unsigned long cpu, unsigned long vpa)
31 {
32         return vpa_call(0x5, cpu, vpa);
33 }
34
35 static inline long register_vpa(unsigned long cpu, unsigned long vpa)
36 {
37         return vpa_call(0x1, cpu, vpa);
38 }
39
40 static inline long unregister_slb_shadow(unsigned long cpu, unsigned long vpa)
41 {
42         return vpa_call(0x7, cpu, vpa);
43 }
44
45 static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
46 {
47         return vpa_call(0x3, cpu, vpa);
48 }
49
50 extern void vpa_init(int cpu);
51
52 static inline long plpar_pte_enter(unsigned long flags,
53                 unsigned long hpte_group, unsigned long hpte_v,
54                 unsigned long hpte_r, unsigned long *slot)
55 {
56         long rc;
57         unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
58
59         rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r);
60
61         *slot = retbuf[0];
62
63         return rc;
64 }
65
66 static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex,
67                 unsigned long avpn, unsigned long *old_pteh_ret,
68                 unsigned long *old_ptel_ret)
69 {
70         long rc;
71         unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
72
73         rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn);
74
75         *old_pteh_ret = retbuf[0];
76         *old_ptel_ret = retbuf[1];
77
78         return rc;
79 }
80
81 static inline long plpar_pte_read(unsigned long flags, unsigned long ptex,
82                 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
83 {
84         long rc;
85         unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
86
87         rc = plpar_hcall(H_READ, retbuf, flags, ptex);
88
89         *old_pteh_ret = retbuf[0];
90         *old_ptel_ret = retbuf[1];
91
92         return rc;
93 }
94
95 static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
96                 unsigned long avpn)
97 {
98         return plpar_hcall_norets(H_PROTECT, flags, ptex, avpn);
99 }
100
101 static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba,
102                 unsigned long *tce_ret)
103 {
104         long rc;
105         unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
106
107         rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba);
108
109         *tce_ret = retbuf[0];
110
111         return rc;
112 }
113
114 static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba,
115                 unsigned long tceval)
116 {
117         return plpar_hcall_norets(H_PUT_TCE, liobn, ioba, tceval);
118 }
119
120 static inline long plpar_tce_put_indirect(unsigned long liobn,
121                 unsigned long ioba, unsigned long page, unsigned long count)
122 {
123         return plpar_hcall_norets(H_PUT_TCE_INDIRECT, liobn, ioba, page, count);
124 }
125
126 static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba,
127                 unsigned long tceval, unsigned long count)
128 {
129         return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count);
130 }
131
132 static inline long plpar_get_term_char(unsigned long termno,
133                 unsigned long *len_ret, char *buf_ret)
134 {
135         long rc;
136         unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
137         unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */
138
139         rc = plpar_hcall(H_GET_TERM_CHAR, retbuf, termno);
140
141         *len_ret = retbuf[0];
142         lbuf[0] = retbuf[1];
143         lbuf[1] = retbuf[2];
144
145         return rc;
146 }
147
148 static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
149                 const char *buffer)
150 {
151         unsigned long *lbuf = (unsigned long *)buffer;  /* TODO: alignment? */
152         return plpar_hcall_norets(H_PUT_TERM_CHAR, termno, len, lbuf[0],
153                         lbuf[1]);
154 }
155
156 static inline long plpar_eoi(unsigned long xirr)
157 {
158         return plpar_hcall_norets(H_EOI, xirr);
159 }
160
161 static inline long plpar_cppr(unsigned long cppr)
162 {
163         return plpar_hcall_norets(H_CPPR, cppr);
164 }
165
166 static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
167 {
168         return plpar_hcall_norets(H_IPI, servernum, mfrr);
169 }
170
171 static inline long plpar_xirr(unsigned long *xirr_ret)
172 {
173         long rc;
174         unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
175
176         rc = plpar_hcall(H_XIRR, retbuf);
177
178         *xirr_ret = retbuf[0];
179
180         return rc;
181 }
182
183 #endif /* _PSERIES_PLPAR_WRAPPERS_H */