Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 1 | #ifndef _PSERIES_PLPAR_WRAPPERS_H |
| 2 | #define _PSERIES_PLPAR_WRAPPERS_H |
| 3 | |
| 4 | #include <asm/hvcall.h> |
Brian King | 370e458 | 2008-08-16 05:09:33 +1000 | [diff] [blame] | 5 | #include <asm/page.h> |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 6 | |
| 7 | static inline long poll_pending(void) |
| 8 | { |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 9 | return plpar_hcall_norets(H_POLL_PENDING); |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 10 | } |
| 11 | |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 12 | static inline long cede_processor(void) |
| 13 | { |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 14 | return plpar_hcall_norets(H_CEDE); |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 15 | } |
| 16 | |
Michael Ellerman | 40765d2 | 2005-11-03 19:34:38 +1100 | [diff] [blame] | 17 | static inline long vpa_call(unsigned long flags, unsigned long cpu, |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 18 | unsigned long vpa) |
| 19 | { |
Michael Ellerman | 40765d2 | 2005-11-03 19:34:38 +1100 | [diff] [blame] | 20 | /* flags are in bits 16-18 (counting from most significant bit) */ |
| 21 | flags = flags << (63 - 18); |
| 22 | |
| 23 | return plpar_hcall_norets(H_REGISTER_VPA, flags, cpu, vpa); |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 24 | } |
| 25 | |
Michael Ellerman | 40765d2 | 2005-11-03 19:34:38 +1100 | [diff] [blame] | 26 | static inline long unregister_vpa(unsigned long cpu, unsigned long vpa) |
| 27 | { |
| 28 | return vpa_call(0x5, cpu, vpa); |
| 29 | } |
| 30 | |
| 31 | static inline long register_vpa(unsigned long cpu, unsigned long vpa) |
| 32 | { |
| 33 | return vpa_call(0x1, cpu, vpa); |
| 34 | } |
| 35 | |
Michael Neuling | 2f6093c | 2006-08-07 16:19:19 +1000 | [diff] [blame] | 36 | static inline long unregister_slb_shadow(unsigned long cpu, unsigned long vpa) |
| 37 | { |
| 38 | return vpa_call(0x7, cpu, vpa); |
| 39 | } |
| 40 | |
| 41 | static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa) |
| 42 | { |
| 43 | return vpa_call(0x3, cpu, vpa); |
| 44 | } |
| 45 | |
Brian King | 86630a3 | 2008-07-24 04:29:16 +1000 | [diff] [blame] | 46 | static inline long plpar_page_set_loaned(unsigned long vpa) |
| 47 | { |
Brian King | 370e458 | 2008-08-16 05:09:33 +1000 | [diff] [blame] | 48 | unsigned long cmo_page_sz = cmo_get_page_size(); |
| 49 | long rc = 0; |
| 50 | int i; |
| 51 | |
| 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); |
| 54 | |
| 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); |
| 58 | |
| 59 | return rc; |
Brian King | 86630a3 | 2008-07-24 04:29:16 +1000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static inline long plpar_page_set_active(unsigned long vpa) |
| 63 | { |
Brian King | 370e458 | 2008-08-16 05:09:33 +1000 | [diff] [blame] | 64 | unsigned long cmo_page_sz = cmo_get_page_size(); |
| 65 | long rc = 0; |
| 66 | int i; |
| 67 | |
| 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); |
| 70 | |
| 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); |
| 74 | |
| 75 | return rc; |
Brian King | 86630a3 | 2008-07-24 04:29:16 +1000 | [diff] [blame] | 76 | } |
| 77 | |
Michael Ellerman | 40765d2 | 2005-11-03 19:34:38 +1100 | [diff] [blame] | 78 | extern void vpa_init(int cpu); |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 79 | |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 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) |
| 83 | { |
| 84 | long rc; |
| 85 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
| 86 | |
| 87 | rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r); |
| 88 | |
| 89 | *slot = retbuf[0]; |
| 90 | |
| 91 | return rc; |
| 92 | } |
| 93 | |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 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) |
| 97 | { |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 98 | long rc; |
| 99 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
| 100 | |
| 101 | rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn); |
| 102 | |
| 103 | *old_pteh_ret = retbuf[0]; |
| 104 | *old_ptel_ret = retbuf[1]; |
| 105 | |
| 106 | return rc; |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 107 | } |
| 108 | |
Mohan Kumar M | b4aea36 | 2007-03-21 11:21:32 +0530 | [diff] [blame] | 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) |
| 113 | { |
| 114 | long rc; |
| 115 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
| 116 | |
| 117 | rc = plpar_hcall_raw(H_REMOVE, retbuf, flags, ptex, avpn); |
| 118 | |
| 119 | *old_pteh_ret = retbuf[0]; |
| 120 | *old_ptel_ret = retbuf[1]; |
| 121 | |
| 122 | return rc; |
| 123 | } |
| 124 | |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 125 | static inline long plpar_pte_read(unsigned long flags, unsigned long ptex, |
| 126 | unsigned long *old_pteh_ret, unsigned long *old_ptel_ret) |
| 127 | { |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 128 | long rc; |
| 129 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
| 130 | |
| 131 | rc = plpar_hcall(H_READ, retbuf, flags, ptex); |
| 132 | |
| 133 | *old_pteh_ret = retbuf[0]; |
| 134 | *old_ptel_ret = retbuf[1]; |
| 135 | |
| 136 | return rc; |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 137 | } |
| 138 | |
Sachin P. Sant | b7abc5c | 2007-06-14 15:31:34 +1000 | [diff] [blame] | 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) |
| 142 | { |
| 143 | long rc; |
| 144 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
| 145 | |
| 146 | rc = plpar_hcall_raw(H_READ, retbuf, flags, ptex); |
| 147 | |
| 148 | *old_pteh_ret = retbuf[0]; |
| 149 | *old_ptel_ret = retbuf[1]; |
| 150 | |
| 151 | return rc; |
| 152 | } |
| 153 | |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 154 | static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex, |
| 155 | unsigned long avpn) |
| 156 | { |
| 157 | return plpar_hcall_norets(H_PROTECT, flags, ptex, avpn); |
| 158 | } |
| 159 | |
| 160 | static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba, |
| 161 | unsigned long *tce_ret) |
| 162 | { |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 163 | long rc; |
| 164 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
| 165 | |
| 166 | rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba); |
| 167 | |
| 168 | *tce_ret = retbuf[0]; |
| 169 | |
| 170 | return rc; |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba, |
| 174 | unsigned long tceval) |
| 175 | { |
| 176 | return plpar_hcall_norets(H_PUT_TCE, liobn, ioba, tceval); |
| 177 | } |
| 178 | |
| 179 | static inline long plpar_tce_put_indirect(unsigned long liobn, |
| 180 | unsigned long ioba, unsigned long page, unsigned long count) |
| 181 | { |
| 182 | return plpar_hcall_norets(H_PUT_TCE_INDIRECT, liobn, ioba, page, count); |
| 183 | } |
| 184 | |
| 185 | static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba, |
| 186 | unsigned long tceval, unsigned long count) |
| 187 | { |
| 188 | return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count); |
| 189 | } |
| 190 | |
| 191 | static inline long plpar_get_term_char(unsigned long termno, |
| 192 | unsigned long *len_ret, char *buf_ret) |
| 193 | { |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 194 | long rc; |
| 195 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 196 | unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */ |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 197 | |
| 198 | rc = plpar_hcall(H_GET_TERM_CHAR, retbuf, termno); |
| 199 | |
| 200 | *len_ret = retbuf[0]; |
| 201 | lbuf[0] = retbuf[1]; |
| 202 | lbuf[1] = retbuf[2]; |
| 203 | |
| 204 | return rc; |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | static inline long plpar_put_term_char(unsigned long termno, unsigned long len, |
| 208 | const char *buffer) |
| 209 | { |
| 210 | unsigned long *lbuf = (unsigned long *)buffer; /* TODO: alignment? */ |
| 211 | return plpar_hcall_norets(H_PUT_TERM_CHAR, termno, len, lbuf[0], |
| 212 | lbuf[1]); |
| 213 | } |
| 214 | |
Anton Blanchard | b9377ff | 2006-07-19 08:01:28 +1000 | [diff] [blame] | 215 | static inline long plpar_eoi(unsigned long xirr) |
| 216 | { |
| 217 | return plpar_hcall_norets(H_EOI, xirr); |
| 218 | } |
| 219 | |
| 220 | static inline long plpar_cppr(unsigned long cppr) |
| 221 | { |
| 222 | return plpar_hcall_norets(H_CPPR, cppr); |
| 223 | } |
| 224 | |
| 225 | static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr) |
| 226 | { |
| 227 | return plpar_hcall_norets(H_IPI, servernum, mfrr); |
| 228 | } |
| 229 | |
| 230 | static inline long plpar_xirr(unsigned long *xirr_ret) |
| 231 | { |
| 232 | long rc; |
| 233 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; |
| 234 | |
| 235 | rc = plpar_hcall(H_XIRR, retbuf); |
| 236 | |
| 237 | *xirr_ret = retbuf[0]; |
| 238 | |
| 239 | return rc; |
| 240 | } |
| 241 | |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 242 | #endif /* _PSERIES_PLPAR_WRAPPERS_H */ |