Merge branch 'linux-next' of git://git.infradead.org/ubi-2.6
[deliverable/linux.git] / arch / powerpc / platforms / pseries / plpar_wrappers.h
CommitLineData
a1218720
ME
1#ifndef _PSERIES_PLPAR_WRAPPERS_H
2#define _PSERIES_PLPAR_WRAPPERS_H
3
4#include <asm/hvcall.h>
370e4587 5#include <asm/page.h>
a1218720
ME
6
7static inline long poll_pending(void)
8{
b9377ffc 9 return plpar_hcall_norets(H_POLL_PENDING);
a1218720
ME
10}
11
69ddb57c
GS
12static inline u8 get_cede_latency_hint(void)
13{
14 return get_lppaca()->gpr5_dword.fields.cede_latency_hint;
15}
16
17static inline void set_cede_latency_hint(u8 latency_hint)
18{
19 get_lppaca()->gpr5_dword.fields.cede_latency_hint = latency_hint;
20}
21
a1218720
ME
22static inline long cede_processor(void)
23{
b9377ffc 24 return plpar_hcall_norets(H_CEDE);
a1218720
ME
25}
26
69ddb57c
GS
27static inline long extended_cede_processor(unsigned long latency_hint)
28{
29 long rc;
30 u8 old_latency_hint = get_cede_latency_hint();
31
32 set_cede_latency_hint(latency_hint);
33 rc = cede_processor();
34 set_cede_latency_hint(old_latency_hint);
35
36 return rc;
37}
38
40765d2b 39static inline long vpa_call(unsigned long flags, unsigned long cpu,
a1218720
ME
40 unsigned long vpa)
41{
40765d2b
ME
42 /* flags are in bits 16-18 (counting from most significant bit) */
43 flags = flags << (63 - 18);
44
45 return plpar_hcall_norets(H_REGISTER_VPA, flags, cpu, vpa);
46}
47
48static inline long unregister_vpa(unsigned long cpu, unsigned long vpa)
49{
50 return vpa_call(0x5, cpu, vpa);
51}
52
53static inline long register_vpa(unsigned long cpu, unsigned long vpa)
54{
55 return vpa_call(0x1, cpu, vpa);
a1218720
ME
56}
57
2f6093c8
MN
58static inline long unregister_slb_shadow(unsigned long cpu, unsigned long vpa)
59{
60 return vpa_call(0x7, cpu, vpa);
61}
62
63static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
64{
65 return vpa_call(0x3, cpu, vpa);
66}
67
fc59a3fc
JK
68static inline long unregister_dtl(unsigned long cpu, unsigned long vpa)
69{
70 return vpa_call(0x6, cpu, vpa);
71}
72
73static inline long register_dtl(unsigned long cpu, unsigned long vpa)
74{
75 return vpa_call(0x2, cpu, vpa);
76}
77
86630a32
BK
78static inline long plpar_page_set_loaned(unsigned long vpa)
79{
370e4587
BK
80 unsigned long cmo_page_sz = cmo_get_page_size();
81 long rc = 0;
82 int i;
83
84 for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
85 rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa + i, 0);
86
87 for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
88 plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE,
89 vpa + i - cmo_page_sz, 0);
90
91 return rc;
86630a32
BK
92}
93
94static inline long plpar_page_set_active(unsigned long vpa)
95{
370e4587
BK
96 unsigned long cmo_page_sz = cmo_get_page_size();
97 long rc = 0;
98 int i;
99
100 for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
101 rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa + i, 0);
102
103 for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
104 plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED,
105 vpa + i - cmo_page_sz, 0);
106
107 return rc;
86630a32
BK
108}
109
40765d2b 110extern void vpa_init(int cpu);
a1218720 111
b9377ffc
AB
112static inline long plpar_pte_enter(unsigned long flags,
113 unsigned long hpte_group, unsigned long hpte_v,
114 unsigned long hpte_r, unsigned long *slot)
115{
116 long rc;
117 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
118
119 rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r);
120
121 *slot = retbuf[0];
122
123 return rc;
124}
125
a1218720
ME
126static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex,
127 unsigned long avpn, unsigned long *old_pteh_ret,
128 unsigned long *old_ptel_ret)
129{
b9377ffc
AB
130 long rc;
131 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
132
133 rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn);
134
135 *old_pteh_ret = retbuf[0];
136 *old_ptel_ret = retbuf[1];
137
138 return rc;
a1218720
ME
139}
140
b4aea36b
MK
141/* plpar_pte_remove_raw can be called in real mode. It calls plpar_hcall_raw */
142static inline long plpar_pte_remove_raw(unsigned long flags, unsigned long ptex,
143 unsigned long avpn, unsigned long *old_pteh_ret,
144 unsigned long *old_ptel_ret)
145{
146 long rc;
147 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
148
149 rc = plpar_hcall_raw(H_REMOVE, retbuf, flags, ptex, avpn);
150
151 *old_pteh_ret = retbuf[0];
152 *old_ptel_ret = retbuf[1];
153
154 return rc;
155}
156
a1218720
ME
157static inline long plpar_pte_read(unsigned long flags, unsigned long ptex,
158 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
159{
b9377ffc
AB
160 long rc;
161 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
162
163 rc = plpar_hcall(H_READ, retbuf, flags, ptex);
164
165 *old_pteh_ret = retbuf[0];
166 *old_ptel_ret = retbuf[1];
167
168 return rc;
a1218720
ME
169}
170
b7abc5c5
SS
171/* plpar_pte_read_raw can be called in real mode. It calls plpar_hcall_raw */
172static inline long plpar_pte_read_raw(unsigned long flags, unsigned long ptex,
173 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
174{
175 long rc;
176 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
177
178 rc = plpar_hcall_raw(H_READ, retbuf, flags, ptex);
179
180 *old_pteh_ret = retbuf[0];
181 *old_ptel_ret = retbuf[1];
182
183 return rc;
184}
185
a1218720
ME
186static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
187 unsigned long avpn)
188{
189 return plpar_hcall_norets(H_PROTECT, flags, ptex, avpn);
190}
191
192static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba,
193 unsigned long *tce_ret)
194{
b9377ffc
AB
195 long rc;
196 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
197
198 rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba);
199
200 *tce_ret = retbuf[0];
201
202 return rc;
a1218720
ME
203}
204
205static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba,
206 unsigned long tceval)
207{
208 return plpar_hcall_norets(H_PUT_TCE, liobn, ioba, tceval);
209}
210
211static inline long plpar_tce_put_indirect(unsigned long liobn,
212 unsigned long ioba, unsigned long page, unsigned long count)
213{
214 return plpar_hcall_norets(H_PUT_TCE_INDIRECT, liobn, ioba, page, count);
215}
216
217static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba,
218 unsigned long tceval, unsigned long count)
219{
220 return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count);
221}
222
223static inline long plpar_get_term_char(unsigned long termno,
224 unsigned long *len_ret, char *buf_ret)
225{
b9377ffc
AB
226 long rc;
227 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
a1218720 228 unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */
b9377ffc
AB
229
230 rc = plpar_hcall(H_GET_TERM_CHAR, retbuf, termno);
231
232 *len_ret = retbuf[0];
233 lbuf[0] = retbuf[1];
234 lbuf[1] = retbuf[2];
235
236 return rc;
a1218720
ME
237}
238
239static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
240 const char *buffer)
241{
242 unsigned long *lbuf = (unsigned long *)buffer; /* TODO: alignment? */
243 return plpar_hcall_norets(H_PUT_TERM_CHAR, termno, len, lbuf[0],
244 lbuf[1]);
245}
246
b9377ffc
AB
247static inline long plpar_eoi(unsigned long xirr)
248{
249 return plpar_hcall_norets(H_EOI, xirr);
250}
251
252static inline long plpar_cppr(unsigned long cppr)
253{
254 return plpar_hcall_norets(H_CPPR, cppr);
255}
256
257static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
258{
259 return plpar_hcall_norets(H_IPI, servernum, mfrr);
260}
261
262static inline long plpar_xirr(unsigned long *xirr_ret)
263{
264 long rc;
265 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
266
267 rc = plpar_hcall(H_XIRR, retbuf);
268
269 *xirr_ret = retbuf[0];
270
271 return rc;
272}
273
a1218720 274#endif /* _PSERIES_PLPAR_WRAPPERS_H */
This page took 0.54799 seconds and 5 git commands to generate.