phyp-hvcall.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  3. *
  4. * Copyright (C) 2010 Andreas Tobler
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19. * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  22. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  23. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. * $FreeBSD$
  28. */
  29. #ifndef _PSERIES_PHYP_HVCALL_H_
  30. #define _PSERIES_PHYP_HVCALL_H_
  31. /* Information taken from: Power.org PAPR, Version 2.4 (December 7, 2009). */
  32. #include <sys/types.h>
  33. /* Return codes. */
  34. #define H_SUCCESS 0
  35. #define H_BUSY 1 /* Hardware Busy -- Retry Later. */
  36. #define H_CLOSED 2 /* Virtual I/O connection is closed. */
  37. #define H_NOT_AVAILABLE 3
  38. #define H_CONSTRAINED 4 /* The request called for resources in excess of
  39. the maximum allowed. The resultant allocation
  40. was constrained to maximum allowed. */
  41. #define H_PARTIAL 5 /* The request completed only partially successful.
  42. Parameters were valid but some specific hcall
  43. function condition prevented fully completing the
  44. architected function, see the specific hcall
  45. definition for possible reasons. */
  46. #define H_IN_PROGRESS 14
  47. #define H_PAGE_REGISTERED 15
  48. #define H_PARTIAL_STORE 16
  49. #define H_PENDING 17
  50. #define H_CONTINUE 18
  51. #define H_LONG_BUSY_ORDER_1_MS 9900 /* This return code is identical to
  52. H_BUSY, but with the added bonus of a
  53. hint to the partition OS. If the
  54. partition OS can delay for 1
  55. millisecond, the hcall will likely
  56. succeed on a new hcall with no further
  57. busy return codes. If the partition OS
  58. cannot handle a delay, they are
  59. certainly free to immediately turn
  60. around and try again. */
  61. #define H_LONG_BUSY_ORDER_10_MS 9901 /* Similar to H_LONG_BUSY_ORDER_1_MS, but
  62. the hint is 10mSec wait this time. */
  63. #define H_LONG_BUSY_ORDER_100_MS 9902 /* Similar to H_LONG_BUSY_ORDER_1_MS, but
  64. the hint is 100mSec wait this time. */
  65. #define H_LONG_BUSY_ORDER_1_S 9903 /* Similar to H_LONG_BUSY_ORDER_1_MS, but
  66. the hint is 1Sec wait this time. */
  67. #define H_LONG_BUSY_ORDER_10_S 9904 /* Similar to H_LONG_BUSY_ORDER_1_MS, but
  68. the hint is 10Sec wait this time. */
  69. #define H_LONG_BUSY_ORDER_100_S 9905 /* Similar to H_LONG_BUSY_ORDER_1_MS, but
  70. the hint is 100Sec wait this time. */
  71. #define H_HARDWARE -1 /* Error. */
  72. #define H_FUNCTION -2 /* Not supported. */
  73. #define H_PRIVILEGE -3 /* Caller not in privileged mode. */
  74. #define H_PARAMETER -4 /* Outside valid range for partition or conflicting. */
  75. #define H_BAD_MODE -5 /* Illegal MSR value. */
  76. #define H_PTEG_FULL -6 /* The requested pteg was full. */
  77. #define H_NOT_FOUND -7 /* The requested entitiy was not found. */
  78. #define H_RESERVED_DABR -8 /* The requested address is reserved by the
  79. hypervisor on this processor. */
  80. #define H_NOMEM -9
  81. #define H_AUTHORITY -10 /* The caller did not have authority to perform the
  82. function. */
  83. #define H_PERMISSION -11 /* The mapping specified by the request does not
  84. allow for the requested transfer. */
  85. #define H_DROPPED -12 /* One or more packets could not be delivered to
  86. their requested destinations. */
  87. #define H_S_PARM -13 /* The source parameter is illegal. */
  88. #define H_D_PARM -14 /* The destination parameter is illegal. */
  89. #define H_R_PARM -15 /* The remote TCE mapping is illegal. */
  90. #define H_RESOURCE -16 /* One or more required resources are in use. */
  91. #define H_ADAPTER_PARM -17 /* Invalid adapter. */
  92. #define H_RH_PARM -18 /* Resource not valid or logical partition
  93. conflicting. */
  94. #define H_RCQ_PARM -19 /* RCQ not valid or logical partition conflicting. */
  95. #define H_SCQ_PARM -20 /* SCQ not valid or logical partition conflicting. */
  96. #define H_EQ_PARM -21 /* EQ not valid or logical partition conflicting. */
  97. #define H_RT_PARM -22 /* Invalid resource type. */
  98. #define H_ST_PARM -23 /* Invalid service type. */
  99. #define H_SIGT_PARM -24 /* Invalid signalling type. */
  100. #define H_TOKEN_PARM -25 /* Invalid token. */
  101. #define H_MLENGTH_PARM -27 /* Invalid memory length. */
  102. #define H_MEM_PARM -28 /* Invalid memory I/O virtual address. */
  103. #define H_MEM_ACCESS_PARM -29 /* Invalid memory access control. */
  104. #define H_ATTR_PARM -30 /* Invalid attribute value. */
  105. #define H_PORT_PARM -31 /* Invalid port number. */
  106. #define H_MCG_PARM -32 /* Invalid multicast group. */
  107. #define H_VL_PARM -33 /* Invalid virtual lane. */
  108. #define H_TSIZE_PARM -34 /* Invalid trace size. */
  109. #define H_TRACE_PARM -35 /* Invalid trace buffer. */
  110. #define H_MASK_PARM -37 /* Invalid mask value. */
  111. #define H_MCG_FULL -38 /* Multicast attachments exceeded. */
  112. #define H_ALIAS_EXIST -39 /* Alias QP already defined. */
  113. #define H_P_COUNTER -40 /* Invalid counter specification. */
  114. #define H_TABLE_FULL -41 /* Resource page table full. */
  115. #define H_ALT_TABLE -42 /* Alternate table already exists / alternate page
  116. table not available. */
  117. #define H_MR_CONDITION -43 /* Invalid memory region condition. */
  118. #define H_NOT_ENOUGH_RESOURCES -44 /* Insufficient resources. */
  119. #define H_R_STATE -45 /* Invalid resource state condition or sequencing
  120. error. */
  121. #define H_RESCINDED -46
  122. #define H_ABORTED -54
  123. #define H_P2 -55
  124. #define H_P3 -56
  125. #define H_P4 -57
  126. #define H_P5 -58
  127. #define H_P6 -59
  128. #define H_P7 -60
  129. #define H_P8 -61
  130. #define H_P9 -62
  131. #define H_NOOP -63
  132. #define H_TOO_BIG -64
  133. #define H_UNSUPPORTED -67 /* Parameter value outside of the range supported
  134. by this implementation. */
  135. /* Flags. */
  136. /* Table 168. Page Frame Table Access flags field definition. */
  137. #define H_EXACT (1UL<<(63-24))
  138. #define H_R_XLATE (1UL<<(63-25))
  139. #define H_READ_4 (1UL<<(63-26))
  140. /* Table 178. CMO Page Usage State flags Definition. */
  141. #define H_PAGE_STATE_CHANGE (1UL<<(63-28))
  142. #define H_PAGE_UNUSED ((1UL<<(63-29)) | (1UL<<(63-30)))
  143. #define H_PAGE_SET_UNUSED (H_PAGE_STATE_CHANGE | H_PAGE_UNUSED)
  144. #define H_PAGE_SET_LOANED (H_PAGE_SET_UNUSED | (1UL<<(63-31)))
  145. #define H_PAGE_SET_ACTIVE H_PAGE_STATE_CHANGE
  146. /* Table 168. Page Frame Table Access flags field definition. */
  147. #define H_AVPN (1UL<<(63-32))
  148. #define H_ANDCOND (1UL<<(63-33))
  149. #define H_ICACHE_INVALIDATE (1UL<<(63-40))
  150. #define H_ICACHE_SYNCHRONIZE (1UL<<(63-41))
  151. #define H_ZERO_PAGE (1UL<<(63-48))
  152. #define H_COPY_PAGE (1UL<<(63-49))
  153. #define H_N (1UL<<(63-61))
  154. #define H_PP1 (1UL<<(63-62))
  155. #define H_PP2 (1UL<<(63-63))
  156. /* H_SET_MODE resource identifiers from 14.5.4.3.5. */
  157. #define H_SET_MODE_RSRC_CIABR 0x1 /* All versions */
  158. #define H_SET_MODE_RSRC_DAWR0 0x2 /* All versions */
  159. #define H_SET_MODE_RSRC_INTR_TRANS_MODE 0x3 /* All versions */
  160. #define H_SET_MODE_RSRC_ILE 0x4 /* PAPR 2.8 / ISA 2.07 */
  161. #define H_SET_MODE_RSRC_DAWR1 0x5 /* ISA 3.1 Future support */
  162. /* pSeries hypervisor opcodes. */
  163. #define H_REMOVE 0x04
  164. #define H_ENTER 0x08
  165. #define H_READ 0x0c
  166. #define H_CLEAR_MOD 0x10
  167. #define H_CLEAR_REF 0x14
  168. #define H_PROTECT 0x18
  169. #define H_GET_TCE 0x1c
  170. #define H_PUT_TCE 0x20
  171. #define H_SET_SPRG0 0x24
  172. #define H_SET_DABR 0x28
  173. #define H_PAGE_INIT 0x2c
  174. #define H_SET_ASR 0x30
  175. #define H_ASR_ON 0x34
  176. #define H_ASR_OFF 0x38
  177. #define H_LOGICAL_CI_LOAD 0x3c
  178. #define H_LOGICAL_CI_STORE 0x40
  179. #define H_LOGICAL_CACHE_LOAD 0x44
  180. #define H_LOGICAL_CACHE_STORE 0x48
  181. #define H_LOGICAL_ICBI 0x4c
  182. #define H_LOGICAL_DCBF 0x50
  183. #define H_GET_TERM_CHAR 0x54
  184. #define H_PUT_TERM_CHAR 0x58
  185. #define H_REAL_TO_LOGICAL 0x5c
  186. #define H_HYPERVISOR_DATA 0x60
  187. #define H_EOI 0x64
  188. #define H_CPPR 0x68
  189. #define H_IPI 0x6c
  190. #define H_IPOLL 0x70
  191. #define H_XIRR 0x74
  192. #define H_MIGRATE_DMA 0x78
  193. #define H_PERFMON 0x7c
  194. #define H_REGISTER_VPA 0xdc
  195. #define H_CEDE 0xe0
  196. #define H_CONFER 0xe4
  197. #define H_PROD 0xe8
  198. #define H_GET_PPP 0xec
  199. #define H_SET_PPP 0xf0
  200. #define H_PURR 0xf4
  201. #define H_PIC 0xf8
  202. #define H_REG_CRQ 0xfc
  203. #define H_FREE_CRQ 0x100
  204. #define H_VIO_SIGNAL 0x104
  205. #define H_SEND_CRQ 0x108
  206. #define H_PUT_RTCE 0x10c
  207. #define H_COPY_RDMA 0x110
  208. #define H_REGISTER_LOGICAL_LAN 0x114
  209. #define H_FREE_LOGICAL_LAN 0x118
  210. #define H_ADD_LOGICAL_LAN_BUFFER 0x11c
  211. #define H_SEND_LOGICAL_LAN 0x120
  212. #define H_BULK_REMOVE 0x124
  213. #define H_WRITE_RDMA 0x128
  214. #define H_READ_RDMA 0x12c
  215. #define H_MULTICAST_CTRL 0x130
  216. #define H_SET_XDABR 0x134
  217. #define H_STUFF_TCE 0x138
  218. #define H_PUT_TCE_INDIRECT 0x13c
  219. #define H_PUT_RTCE_INDIRECT 0x140
  220. #define H_CHANGE_LOGICAL_LAN_MAC 0x14c
  221. #define H_VTERM_PARTNER_INFO 0x150
  222. #define H_REGISTER_VTERM 0x154
  223. #define H_FREE_VTERM 0x158
  224. /* Reserved ....
  225. #define H_RESET_EVENTS 0x15c
  226. #define H_ALLOC_RESOURCE 0x160
  227. #define H_FREE_RESOURCE 0x164
  228. #define H_MODIFY_QP 0x168
  229. #define H_QUERY_QP 0x16c
  230. #define H_REREGISTER_PMR 0x170
  231. #define H_REGISTER_SMR 0x174
  232. #define H_QUERY_MR 0x178
  233. #define H_QUERY_MW 0x17c
  234. #define H_QUERY_HCA 0x180
  235. #define H_QUERY_PORT 0x184
  236. #define H_MODIFY_PORT 0x188
  237. #define H_DEFINE_AQP1 0x18c
  238. #define H_GET_TRACE_BUFFER 0x190
  239. #define H_DEFINE_AQP0 0x194
  240. #define H_RESIZE_MR 0x198
  241. #define H_ATTACH_MCQP 0x19c
  242. #define H_DETACH_MCQP 0x1a0
  243. #define H_CREATE_RPT 0x1a4
  244. #define H_REMOVE_RPT 0x1a8
  245. #define H_REGISTER_RPAGES 0x1ac
  246. #define H_DISABLE_AND_GETC 0x1b0
  247. #define H_ERROR_DATA 0x1b4
  248. #define H_GET_HCA_INFO 0x1b8
  249. #define H_GET_PERF_COUNT 0x1bc
  250. #define H_MANAGE_TRACE 0x1c0
  251. .... */
  252. #define H_FREE_LOGICAL_LAN_BUFFER 0x1d4
  253. #define H_POLL_PENDING 0x1d8
  254. /* Reserved ....
  255. #define H_QUERY_INT_STATE 0x1e4
  256. .... */
  257. #define H_LIOBN_ATTRIBUTES 0x240
  258. #define H_ILLAN_ATTRIBUTES 0x244
  259. #define H_REMOVE_RTCE 0x24c
  260. /* Reserved ...
  261. #define H_MODIFY_HEA_QP 0x250
  262. #define H_QUERY_HEA_QP 0x254
  263. #define H_QUERY_HEA 0x258
  264. #define H_QUERY_HEA_PORT 0x25c
  265. #define H_MODIFY_HEA_PORT 0x260
  266. #define H_REG_BCMC 0x264
  267. #define H_DEREG_BCMC 0x268
  268. #define H_REGISTER_HEA_RPAGES 0x26c
  269. #define H_DISABLE_AND_GET_HEA 0x270
  270. #define H_GET_HEA_INFO 0x274
  271. #define H_ALLOC_HEA_RESOURCE 0x278
  272. #define H_ADD_CONN 0x284
  273. #define H_DEL_CONN 0x288
  274. ... */
  275. #define H_JOIN 0x298
  276. #define H_DONOR_OPERATION 0x29c
  277. #define H_VASI_SIGNAL 0x2a0
  278. #define H_VASI_STATE 0x2a4
  279. #define H_VIOCTL 0x2a8
  280. #define H_VRMASD 0x2ac
  281. #define H_ENABLE_CRQ 0x2b0
  282. /* Reserved ...
  283. #define H_GET_EM_PARMS 0x2b8
  284. ... */
  285. #define H_VPM_STAT 0x2bc
  286. #define H_SET_MPP 0x2d0
  287. #define H_GET_MPP 0x2d4
  288. #define H_MO_PERF 0x2d8
  289. #define H_REG_SUB_CRQ 0x2dc
  290. #define H_FREE_SUB_CRQ 0x2e0
  291. #define H_SEND_SUB_CRQ 0x2e4
  292. #define H_SEND_SUB_CRQ_IND 0x2e8
  293. #define H_HOME_NODE_ASSOC 0x2ec
  294. /* Reserved ... */
  295. #define H_BEST_ENERGY 0x2f4
  296. #define H_REG_SNS 0x2f8
  297. #define H_X_XIRR 0x2fc
  298. #define H_RANDOM 0x300
  299. /* Reserved ... */
  300. #define H_COP_OP 0x304
  301. #define H_STOP_COP_OP 0x308
  302. #define H_GET_MPP_X 0x314
  303. #define H_SET_MODE 0x31C
  304. /* Reserved ... */
  305. #define H_GET_DMA_XLATES_L 0x324
  306. #define MAX_HCALL_OPCODE H_GET_DMA_XLATES_L
  307. int64_t phyp_hcall(uint64_t opcode, ...);
  308. int64_t phyp_pft_hcall(uint64_t opcode, uint64_t flags, uint64_t pteidx,
  309. uint64_t pte_hi, uint64_t pte_lo, uint64_t *pteidx_out, uint64_t *ptelo_out,
  310. uint64_t *r6);
  311. #endif /* _PSERIES_PHYP_HVCALL_H_ */