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 unregister_dtl(unsigned long cpu
, unsigned long vpa
)
48 return vpa_call(0x6, cpu
, vpa
);
51 static inline long register_dtl(unsigned long cpu
, unsigned long vpa
)
53 return vpa_call(0x2, cpu
, vpa
);
56 static inline long plpar_page_set_loaned(unsigned long vpa
)
58 unsigned long cmo_page_sz
= cmo_get_page_size();
62 for (i
= 0; !rc
&& i
< PAGE_SIZE
; i
+= cmo_page_sz
)
63 rc
= plpar_hcall_norets(H_PAGE_INIT
, H_PAGE_SET_LOANED
, vpa
+ i
, 0);
65 for (i
-= cmo_page_sz
; rc
&& i
!= 0; i
-= cmo_page_sz
)
66 plpar_hcall_norets(H_PAGE_INIT
, H_PAGE_SET_ACTIVE
,
67 vpa
+ i
- cmo_page_sz
, 0);
72 static inline long plpar_page_set_active(unsigned long vpa
)
74 unsigned long cmo_page_sz
= cmo_get_page_size();
78 for (i
= 0; !rc
&& i
< PAGE_SIZE
; i
+= cmo_page_sz
)
79 rc
= plpar_hcall_norets(H_PAGE_INIT
, H_PAGE_SET_ACTIVE
, vpa
+ i
, 0);
81 for (i
-= cmo_page_sz
; rc
&& i
!= 0; i
-= cmo_page_sz
)
82 plpar_hcall_norets(H_PAGE_INIT
, H_PAGE_SET_LOANED
,
83 vpa
+ i
- cmo_page_sz
, 0);
88 extern void vpa_init(int cpu
);
90 static inline long plpar_pte_enter(unsigned long flags
,
91 unsigned long hpte_group
, unsigned long hpte_v
,
92 unsigned long hpte_r
, unsigned long *slot
)
95 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
97 rc
= plpar_hcall(H_ENTER
, retbuf
, flags
, hpte_group
, hpte_v
, hpte_r
);
104 static inline long plpar_pte_remove(unsigned long flags
, unsigned long ptex
,
105 unsigned long avpn
, unsigned long *old_pteh_ret
,
106 unsigned long *old_ptel_ret
)
109 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
111 rc
= plpar_hcall(H_REMOVE
, retbuf
, flags
, ptex
, avpn
);
113 *old_pteh_ret
= retbuf
[0];
114 *old_ptel_ret
= retbuf
[1];
119 /* plpar_pte_remove_raw can be called in real mode. It calls plpar_hcall_raw */
120 static inline long plpar_pte_remove_raw(unsigned long flags
, unsigned long ptex
,
121 unsigned long avpn
, unsigned long *old_pteh_ret
,
122 unsigned long *old_ptel_ret
)
125 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
127 rc
= plpar_hcall_raw(H_REMOVE
, retbuf
, flags
, ptex
, avpn
);
129 *old_pteh_ret
= retbuf
[0];
130 *old_ptel_ret
= retbuf
[1];
135 static inline long plpar_pte_read(unsigned long flags
, unsigned long ptex
,
136 unsigned long *old_pteh_ret
, unsigned long *old_ptel_ret
)
139 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
141 rc
= plpar_hcall(H_READ
, retbuf
, flags
, ptex
);
143 *old_pteh_ret
= retbuf
[0];
144 *old_ptel_ret
= retbuf
[1];
149 /* plpar_pte_read_raw can be called in real mode. It calls plpar_hcall_raw */
150 static inline long plpar_pte_read_raw(unsigned long flags
, unsigned long ptex
,
151 unsigned long *old_pteh_ret
, unsigned long *old_ptel_ret
)
154 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
156 rc
= plpar_hcall_raw(H_READ
, retbuf
, flags
, ptex
);
158 *old_pteh_ret
= retbuf
[0];
159 *old_ptel_ret
= retbuf
[1];
164 static inline long plpar_pte_protect(unsigned long flags
, unsigned long ptex
,
167 return plpar_hcall_norets(H_PROTECT
, flags
, ptex
, avpn
);
170 static inline long plpar_tce_get(unsigned long liobn
, unsigned long ioba
,
171 unsigned long *tce_ret
)
174 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
176 rc
= plpar_hcall(H_GET_TCE
, retbuf
, liobn
, ioba
);
178 *tce_ret
= retbuf
[0];
183 static inline long plpar_tce_put(unsigned long liobn
, unsigned long ioba
,
184 unsigned long tceval
)
186 return plpar_hcall_norets(H_PUT_TCE
, liobn
, ioba
, tceval
);
189 static inline long plpar_tce_put_indirect(unsigned long liobn
,
190 unsigned long ioba
, unsigned long page
, unsigned long count
)
192 return plpar_hcall_norets(H_PUT_TCE_INDIRECT
, liobn
, ioba
, page
, count
);
195 static inline long plpar_tce_stuff(unsigned long liobn
, unsigned long ioba
,
196 unsigned long tceval
, unsigned long count
)
198 return plpar_hcall_norets(H_STUFF_TCE
, liobn
, ioba
, tceval
, count
);
201 static inline long plpar_get_term_char(unsigned long termno
,
202 unsigned long *len_ret
, char *buf_ret
)
205 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
206 unsigned long *lbuf
= (unsigned long *)buf_ret
; /* TODO: alignment? */
208 rc
= plpar_hcall(H_GET_TERM_CHAR
, retbuf
, termno
);
210 *len_ret
= retbuf
[0];
217 static inline long plpar_put_term_char(unsigned long termno
, unsigned long len
,
220 unsigned long *lbuf
= (unsigned long *)buffer
; /* TODO: alignment? */
221 return plpar_hcall_norets(H_PUT_TERM_CHAR
, termno
, len
, lbuf
[0],
225 static inline long plpar_eoi(unsigned long xirr
)
227 return plpar_hcall_norets(H_EOI
, xirr
);
230 static inline long plpar_cppr(unsigned long cppr
)
232 return plpar_hcall_norets(H_CPPR
, cppr
);
235 static inline long plpar_ipi(unsigned long servernum
, unsigned long mfrr
)
237 return plpar_hcall_norets(H_IPI
, servernum
, mfrr
);
240 static inline long plpar_xirr(unsigned long *xirr_ret
)
243 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
245 rc
= plpar_hcall(H_XIRR
, retbuf
);
247 *xirr_ret
= retbuf
[0];
252 #endif /* _PSERIES_PLPAR_WRAPPERS_H */