1 #ifndef _PSERIES_PLPAR_WRAPPERS_H
2 #define _PSERIES_PLPAR_WRAPPERS_H
4 #include <asm/hvcall.h>
7 static inline long poll_pending(void)
9 return plpar_hcall_norets(H_POLL_PENDING);
12 static inline long cede_processor(void)
14 return plpar_hcall_norets(H_CEDE);
17 static inline long vpa_call(unsigned long flags, unsigned long cpu,
20 /* flags are in bits 16-18 (counting from most significant bit) */
21 flags = flags << (63 - 18);
23 return plpar_hcall_norets(H_REGISTER_VPA, flags, cpu, vpa);
26 static inline long unregister_vpa(unsigned long cpu, unsigned long vpa)
28 return vpa_call(0x5, cpu, vpa);
31 static inline long register_vpa(unsigned long cpu, unsigned long vpa)
33 return vpa_call(0x1, cpu, vpa);
36 static inline long unregister_slb_shadow(unsigned long cpu, unsigned long vpa)
38 return vpa_call(0x7, cpu, vpa);
41 static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
43 return vpa_call(0x3, cpu, vpa);
46 static inline long plpar_page_set_loaned(unsigned long vpa)
48 unsigned long cmo_page_sz = cmo_get_page_size();
52 for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
53 rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa + i, 0);
55 for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
56 plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE,
57 vpa + i - cmo_page_sz, 0);
62 static inline long plpar_page_set_active(unsigned long vpa)
64 unsigned long cmo_page_sz = cmo_get_page_size();
68 for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
69 rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa + i, 0);
71 for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
72 plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED,
73 vpa + i - cmo_page_sz, 0);
78 extern void vpa_init(int cpu);
80 static inline long plpar_pte_enter(unsigned long flags,
81 unsigned long hpte_group, unsigned long hpte_v,
82 unsigned long hpte_r, unsigned long *slot)
85 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
87 rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r);
94 static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex,
95 unsigned long avpn, unsigned long *old_pteh_ret,
96 unsigned long *old_ptel_ret)
99 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
101 rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn);
103 *old_pteh_ret = retbuf[0];
104 *old_ptel_ret = retbuf[1];
109 /* plpar_pte_remove_raw can be called in real mode. It calls plpar_hcall_raw */
110 static inline long plpar_pte_remove_raw(unsigned long flags, unsigned long ptex,
111 unsigned long avpn, unsigned long *old_pteh_ret,
112 unsigned long *old_ptel_ret)
115 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
117 rc = plpar_hcall_raw(H_REMOVE, retbuf, flags, ptex, avpn);
119 *old_pteh_ret = retbuf[0];
120 *old_ptel_ret = retbuf[1];
125 static inline long plpar_pte_read(unsigned long flags, unsigned long ptex,
126 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
129 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
131 rc = plpar_hcall(H_READ, retbuf, flags, ptex);
133 *old_pteh_ret = retbuf[0];
134 *old_ptel_ret = retbuf[1];
139 /* plpar_pte_read_raw can be called in real mode. It calls plpar_hcall_raw */
140 static inline long plpar_pte_read_raw(unsigned long flags, unsigned long ptex,
141 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
144 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
146 rc = plpar_hcall_raw(H_READ, retbuf, flags, ptex);
148 *old_pteh_ret = retbuf[0];
149 *old_ptel_ret = retbuf[1];
154 static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
157 return plpar_hcall_norets(H_PROTECT, flags, ptex, avpn);
160 static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba,
161 unsigned long *tce_ret)
164 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
166 rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba);
168 *tce_ret = retbuf[0];
173 static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba,
174 unsigned long tceval)
176 return plpar_hcall_norets(H_PUT_TCE, liobn, ioba, tceval);
179 static inline long plpar_tce_put_indirect(unsigned long liobn,
180 unsigned long ioba, unsigned long page, unsigned long count)
182 return plpar_hcall_norets(H_PUT_TCE_INDIRECT, liobn, ioba, page, count);
185 static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba,
186 unsigned long tceval, unsigned long count)
188 return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count);
191 static inline long plpar_get_term_char(unsigned long termno,
192 unsigned long *len_ret, char *buf_ret)
195 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
196 unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */
198 rc = plpar_hcall(H_GET_TERM_CHAR, retbuf, termno);
200 *len_ret = retbuf[0];
207 static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
210 unsigned long *lbuf = (unsigned long *)buffer; /* TODO: alignment? */
211 return plpar_hcall_norets(H_PUT_TERM_CHAR, termno, len, lbuf[0],
215 static inline long plpar_eoi(unsigned long xirr)
217 return plpar_hcall_norets(H_EOI, xirr);
220 static inline long plpar_cppr(unsigned long cppr)
222 return plpar_hcall_norets(H_CPPR, cppr);
225 static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
227 return plpar_hcall_norets(H_IPI, servernum, mfrr);
230 static inline long plpar_xirr(unsigned long *xirr_ret)
233 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
235 rc = plpar_hcall(H_XIRR, retbuf);
237 *xirr_ret = retbuf[0];
242 #endif /* _PSERIES_PLPAR_WRAPPERS_H */