hypervisor.h 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209
  1. #ifndef _SPARC64_HYPERVISOR_H
  2. #define _SPARC64_HYPERVISOR_H
  3. /* Sun4v hypervisor interfaces and defines.
  4. *
  5. * Hypervisor calls are made via traps to software traps number 0x80
  6. * and above. Registers %o0 to %o5 serve as argument, status, and
  7. * return value registers.
  8. *
  9. * There are two kinds of these traps. First there are the normal
  10. * "fast traps" which use software trap 0x80 and encode the function
  11. * to invoke by number in register %o5. Argument and return value
  12. * handling is as follows:
  13. *
  14. * -----------------------------------------------
  15. * | %o5 | function number | undefined |
  16. * | %o0 | argument 0 | return status |
  17. * | %o1 | argument 1 | return value 1 |
  18. * | %o2 | argument 2 | return value 2 |
  19. * | %o3 | argument 3 | return value 3 |
  20. * | %o4 | argument 4 | return value 4 |
  21. * -----------------------------------------------
  22. *
  23. * The second type are "hyper-fast traps" which encode the function
  24. * number in the software trap number itself. So these use trap
  25. * numbers > 0x80. The register usage for hyper-fast traps is as
  26. * follows:
  27. *
  28. * -----------------------------------------------
  29. * | %o0 | argument 0 | return status |
  30. * | %o1 | argument 1 | return value 1 |
  31. * | %o2 | argument 2 | return value 2 |
  32. * | %o3 | argument 3 | return value 3 |
  33. * | %o4 | argument 4 | return value 4 |
  34. * -----------------------------------------------
  35. *
  36. * Registers providing explicit arguments to the hypervisor calls
  37. * are volatile across the call. Upon return their values are
  38. * undefined unless explicitly specified as containing a particular
  39. * return value by the specific call. The return status is always
  40. * returned in register %o0, zero indicates a successful execution of
  41. * the hypervisor call and other values indicate an error status as
  42. * defined below. So, for example, if a hyper-fast trap takes
  43. * arguments 0, 1, and 2, then %o0, %o1, and %o2 are volatile across
  44. * the call and %o3, %o4, and %o5 would be preserved.
  45. *
  46. * If the hypervisor trap is invalid, or the fast trap function number
  47. * is invalid, HV_EBADTRAP will be returned in %o0. Also, all 64-bits
  48. * of the argument and return values are significant.
  49. */
  50. /* Trap numbers. */
  51. #define HV_FAST_TRAP 0x80
  52. #define HV_MMU_MAP_ADDR_TRAP 0x83
  53. #define HV_MMU_UNMAP_ADDR_TRAP 0x84
  54. #define HV_TTRACE_ADDENTRY_TRAP 0x85
  55. #define HV_CORE_TRAP 0xff
  56. /* Error codes. */
  57. #define HV_EOK 0 /* Successful return */
  58. #define HV_ENOCPU 1 /* Invalid CPU id */
  59. #define HV_ENORADDR 2 /* Invalid real address */
  60. #define HV_ENOINTR 3 /* Invalid interrupt id */
  61. #define HV_EBADPGSZ 4 /* Invalid pagesize encoding */
  62. #define HV_EBADTSB 5 /* Invalid TSB description */
  63. #define HV_EINVAL 6 /* Invalid argument */
  64. #define HV_EBADTRAP 7 /* Invalid function number */
  65. #define HV_EBADALIGN 8 /* Invalid address alignment */
  66. #define HV_EWOULDBLOCK 9 /* Cannot complete w/o blocking */
  67. #define HV_ENOACCESS 10 /* No access to resource */
  68. #define HV_EIO 11 /* I/O error */
  69. #define HV_ECPUERROR 12 /* CPU in error state */
  70. #define HV_ENOTSUPPORTED 13 /* Function not supported */
  71. #define HV_ENOMAP 14 /* No mapping found */
  72. #define HV_ETOOMANY 15 /* Too many items specified */
  73. /* mach_exit()
  74. * TRAP: HV_FAST_TRAP
  75. * FUNCTION: HV_FAST_MACH_EXIT
  76. * ARG0: exit code
  77. * ERRORS: This service does not return.
  78. *
  79. * Stop all CPUs in the virtual domain and place them into the stopped
  80. * state. The 64-bit exit code may be passed to a service entity as
  81. * the domain's exit status. On systems without a service entity, the
  82. * domain will undergo a reset, and the boot firmware will be
  83. * reloaded.
  84. *
  85. * This function will never return to the guest that invokes it.
  86. *
  87. * Note: By convention an exit code of zero denotes a successful exit by
  88. * the guest code. A non-zero exit code denotes a guest specific
  89. * error indication.
  90. *
  91. */
  92. #define HV_FAST_MACH_EXIT 0x00
  93. /* Domain services. */
  94. /* mach_desc()
  95. * TRAP: HV_FAST_TRAP
  96. * FUNCTION: HV_FAST_MACH_DESC
  97. * ARG0: buffer
  98. * ARG1: length
  99. * RET0: status
  100. * RET1: length
  101. * ERRORS: HV_EBADALIGN Buffer is badly aligned
  102. * HV_ENORADDR Buffer is to an illegal real address.
  103. * HV_EINVAL Buffer length is too small for complete
  104. * machine description.
  105. *
  106. * Copy the most current machine description into the buffer indicated
  107. * by the real address in ARG0. The buffer provided must be 16 byte
  108. * aligned. Upon success or HV_EINVAL, this service returns the
  109. * actual size of the machine description in the RET1 return value.
  110. *
  111. * Note: A method of determining the appropriate buffer size for the
  112. * machine description is to first call this service with a buffer
  113. * length of 0 bytes.
  114. */
  115. #define HV_FAST_MACH_DESC 0x01
  116. /* mach_exit()
  117. * TRAP: HV_FAST_TRAP
  118. * FUNCTION: HV_FAST_MACH_SIR
  119. * ERRORS: This service does not return.
  120. *
  121. * Perform a software initiated reset of the virtual machine domain.
  122. * All CPUs are captured as soon as possible, all hardware devices are
  123. * returned to the entry default state, and the domain is restarted at
  124. * the SIR (trap type 0x04) real trap table (RTBA) entry point on one
  125. * of the CPUs. The single CPU restarted is selected as determined by
  126. * platform specific policy. Memory is preserved across this
  127. * operation.
  128. */
  129. #define HV_FAST_MACH_SIR 0x02
  130. /* mach_set_soft_state()
  131. * TRAP: HV_FAST_TRAP
  132. * FUNCTION: HV_FAST_MACH_SET_SOFT_STATE
  133. * ARG0: software state
  134. * ARG1: software state description pointer
  135. * RET0: status
  136. * ERRORS: EINVAL software state not valid or software state
  137. * description is not NULL terminated
  138. * ENORADDR software state description pointer is not a
  139. * valid real address
  140. * EBADALIGNED software state description is not correctly
  141. * aligned
  142. *
  143. * This allows the guest to report it's soft state to the hypervisor. There
  144. * are two primary components to this state. The first part states whether
  145. * the guest software is running or not. The second containts optional
  146. * details specific to the software.
  147. *
  148. * The software state argument is defined below in HV_SOFT_STATE_*, and
  149. * indicates whether the guest is operating normally or in a transitional
  150. * state.
  151. *
  152. * The software state description argument is a real address of a data buffer
  153. * of size 32-bytes aligned on a 32-byte boundary. It is treated as a NULL
  154. * terminated 7-bit ASCII string of up to 31 characters not including the
  155. * NULL termination.
  156. */
  157. #define HV_FAST_MACH_SET_SOFT_STATE 0x03
  158. #define HV_SOFT_STATE_NORMAL 0x01
  159. #define HV_SOFT_STATE_TRANSITION 0x02
  160. /* mach_get_soft_state()
  161. * TRAP: HV_FAST_TRAP
  162. * FUNCTION: HV_FAST_MACH_GET_SOFT_STATE
  163. * ARG0: software state description pointer
  164. * RET0: status
  165. * RET1: software state
  166. * ERRORS: ENORADDR software state description pointer is not a
  167. * valid real address
  168. * EBADALIGNED software state description is not correctly
  169. * aligned
  170. *
  171. * Retrieve the current value of the guest's software state. The rules
  172. * for the software state pointer are the same as for mach_set_soft_state()
  173. * above.
  174. */
  175. #define HV_FAST_MACH_GET_SOFT_STATE 0x04
  176. /* CPU services.
  177. *
  178. * CPUs represent devices that can execute software threads. A single
  179. * chip that contains multiple cores or strands is represented as
  180. * multiple CPUs with unique CPU identifiers. CPUs are exported to
  181. * OBP via the machine description (and to the OS via the OBP device
  182. * tree). CPUs are always in one of three states: stopped, running,
  183. * or error.
  184. *
  185. * A CPU ID is a pre-assigned 16-bit value that uniquely identifies a
  186. * CPU within a logical domain. Operations that are to be performed
  187. * on multiple CPUs specify them via a CPU list. A CPU list is an
  188. * array in real memory, of which each 16-bit word is a CPU ID. CPU
  189. * lists are passed through the API as two arguments. The first is
  190. * the number of entries (16-bit words) in the CPU list, and the
  191. * second is the (real address) pointer to the CPU ID list.
  192. */
  193. /* cpu_start()
  194. * TRAP: HV_FAST_TRAP
  195. * FUNCTION: HV_FAST_CPU_START
  196. * ARG0: CPU ID
  197. * ARG1: PC
  198. * ARG1: RTBA
  199. * ARG1: target ARG0
  200. * RET0: status
  201. * ERRORS: ENOCPU Invalid CPU ID
  202. * EINVAL Target CPU ID is not in the stopped state
  203. * ENORADDR Invalid PC or RTBA real address
  204. * EBADALIGN Unaligned PC or unaligned RTBA
  205. * EWOULDBLOCK Starting resources are not available
  206. *
  207. * Start CPU with given CPU ID with PC in %pc and with a real trap
  208. * base address value of RTBA. The indicated CPU must be in the
  209. * stopped state. The supplied RTBA must be aligned on a 256 byte
  210. * boundary. On successful completion, the specified CPU will be in
  211. * the running state and will be supplied with "target ARG0" in %o0
  212. * and RTBA in %tba.
  213. */
  214. #define HV_FAST_CPU_START 0x10
  215. /* cpu_stop()
  216. * TRAP: HV_FAST_TRAP
  217. * FUNCTION: HV_FAST_CPU_STOP
  218. * ARG0: CPU ID
  219. * RET0: status
  220. * ERRORS: ENOCPU Invalid CPU ID
  221. * EINVAL Target CPU ID is the current cpu
  222. * EINVAL Target CPU ID is not in the running state
  223. * EWOULDBLOCK Stopping resources are not available
  224. * ENOTSUPPORTED Not supported on this platform
  225. *
  226. * The specified CPU is stopped. The indicated CPU must be in the
  227. * running state. On completion, it will be in the stopped state. It
  228. * is not legal to stop the current CPU.
  229. *
  230. * Note: As this service cannot be used to stop the current cpu, this service
  231. * may not be used to stop the last running CPU in a domain. To stop
  232. * and exit a running domain, a guest must use the mach_exit() service.
  233. */
  234. #define HV_FAST_CPU_STOP 0x11
  235. /* cpu_yield()
  236. * TRAP: HV_FAST_TRAP
  237. * FUNCTION: HV_FAST_CPU_YIELD
  238. * RET0: status
  239. * ERRORS: No possible error.
  240. *
  241. * Suspend execution on the current CPU. Execution will resume when
  242. * an interrupt (device, %stick_compare, or cross-call) is targeted to
  243. * the CPU. On some CPUs, this API may be used by the hypervisor to
  244. * save power by disabling hardware strands.
  245. */
  246. #define HV_FAST_CPU_YIELD 0x12
  247. #ifndef __ASSEMBLY__
  248. extern unsigned long sun4v_cpu_yield(void);
  249. #endif
  250. /* cpu_qconf()
  251. * TRAP: HV_FAST_TRAP
  252. * FUNCTION: HV_FAST_CPU_QCONF
  253. * ARG0: queue
  254. * ARG1: base real address
  255. * ARG2: number of entries
  256. * RET0: status
  257. * ERRORS: ENORADDR Invalid base real address
  258. * EINVAL Invalid queue or number of entries is less
  259. * than 2 or too large.
  260. * EBADALIGN Base real address is not correctly aligned
  261. * for size.
  262. *
  263. * Configure the given queue to be placed at the given base real
  264. * address, with the given number of entries. The number of entries
  265. * must be a power of 2. The base real address must be aligned
  266. * exactly to match the queue size. Each queue entry is 64 bytes
  267. * long, so for example a 32 entry queue must be aligned on a 2048
  268. * byte real address boundary.
  269. *
  270. * The specified queue is unconfigured if the number of entries is given
  271. * as zero.
  272. *
  273. * For the current version of this API service, the argument queue is defined
  274. * as follows:
  275. *
  276. * queue description
  277. * ----- -------------------------
  278. * 0x3c cpu mondo queue
  279. * 0x3d device mondo queue
  280. * 0x3e resumable error queue
  281. * 0x3f non-resumable error queue
  282. *
  283. * Note: The maximum number of entries for each queue for a specific cpu may
  284. * be determined from the machine description.
  285. */
  286. #define HV_FAST_CPU_QCONF 0x14
  287. #define HV_CPU_QUEUE_CPU_MONDO 0x3c
  288. #define HV_CPU_QUEUE_DEVICE_MONDO 0x3d
  289. #define HV_CPU_QUEUE_RES_ERROR 0x3e
  290. #define HV_CPU_QUEUE_NONRES_ERROR 0x3f
  291. #ifndef __ASSEMBLY__
  292. extern unsigned long sun4v_cpu_qconf(unsigned long type,
  293. unsigned long queue_paddr,
  294. unsigned long num_queue_entries);
  295. #endif
  296. /* cpu_qinfo()
  297. * TRAP: HV_FAST_TRAP
  298. * FUNCTION: HV_FAST_CPU_QINFO
  299. * ARG0: queue
  300. * RET0: status
  301. * RET1: base real address
  302. * RET1: number of entries
  303. * ERRORS: EINVAL Invalid queue
  304. *
  305. * Return the configuration info for the given queue. The base real
  306. * address and number of entries of the defined queue are returned.
  307. * The queue argument values are the same as for cpu_qconf() above.
  308. *
  309. * If the specified queue is a valid queue number, but no queue has
  310. * been defined, the number of entries will be set to zero and the
  311. * base real address returned is undefined.
  312. */
  313. #define HV_FAST_CPU_QINFO 0x15
  314. /* cpu_mondo_send()
  315. * TRAP: HV_FAST_TRAP
  316. * FUNCTION: HV_FAST_CPU_MONDO_SEND
  317. * ARG0-1: CPU list
  318. * ARG2: data real address
  319. * RET0: status
  320. * ERRORS: EBADALIGN Mondo data is not 64-byte aligned or CPU list
  321. * is not 2-byte aligned.
  322. * ENORADDR Invalid data mondo address, or invalid cpu list
  323. * address.
  324. * ENOCPU Invalid cpu in CPU list
  325. * EWOULDBLOCK Some or all of the listed CPUs did not receive
  326. * the mondo
  327. * ECPUERROR One or more of the listed CPUs are in error
  328. * state, use HV_FAST_CPU_STATE to see which ones
  329. * EINVAL CPU list includes caller's CPU ID
  330. *
  331. * Send a mondo interrupt to the CPUs in the given CPU list with the
  332. * 64-bytes at the given data real address. The data must be 64-byte
  333. * aligned. The mondo data will be delivered to the cpu_mondo queues
  334. * of the recipient CPUs.
  335. *
  336. * In all cases, error or not, the CPUs in the CPU list to which the
  337. * mondo has been successfully delivered will be indicated by having
  338. * their entry in CPU list updated with the value 0xffff.
  339. */
  340. #define HV_FAST_CPU_MONDO_SEND 0x42
  341. #ifndef __ASSEMBLY__
  342. extern unsigned long sun4v_cpu_mondo_send(unsigned long cpu_count, unsigned long cpu_list_pa, unsigned long mondo_block_pa);
  343. #endif
  344. /* cpu_myid()
  345. * TRAP: HV_FAST_TRAP
  346. * FUNCTION: HV_FAST_CPU_MYID
  347. * RET0: status
  348. * RET1: CPU ID
  349. * ERRORS: No errors defined.
  350. *
  351. * Return the hypervisor ID handle for the current CPU. Use by a
  352. * virtual CPU to discover it's own identity.
  353. */
  354. #define HV_FAST_CPU_MYID 0x16
  355. /* cpu_state()
  356. * TRAP: HV_FAST_TRAP
  357. * FUNCTION: HV_FAST_CPU_STATE
  358. * ARG0: CPU ID
  359. * RET0: status
  360. * RET1: state
  361. * ERRORS: ENOCPU Invalid CPU ID
  362. *
  363. * Retrieve the current state of the CPU with the given CPU ID.
  364. */
  365. #define HV_FAST_CPU_STATE 0x17
  366. #define HV_CPU_STATE_STOPPED 0x01
  367. #define HV_CPU_STATE_RUNNING 0x02
  368. #define HV_CPU_STATE_ERROR 0x03
  369. #ifndef __ASSEMBLY__
  370. extern long sun4v_cpu_state(unsigned long cpuid);
  371. #endif
  372. /* cpu_set_rtba()
  373. * TRAP: HV_FAST_TRAP
  374. * FUNCTION: HV_FAST_CPU_SET_RTBA
  375. * ARG0: RTBA
  376. * RET0: status
  377. * RET1: previous RTBA
  378. * ERRORS: ENORADDR Invalid RTBA real address
  379. * EBADALIGN RTBA is incorrectly aligned for a trap table
  380. *
  381. * Set the real trap base address of the local cpu to the given RTBA.
  382. * The supplied RTBA must be aligned on a 256 byte boundary. Upon
  383. * success the previous value of the RTBA is returned in RET1.
  384. *
  385. * Note: This service does not affect %tba
  386. */
  387. #define HV_FAST_CPU_SET_RTBA 0x18
  388. /* cpu_set_rtba()
  389. * TRAP: HV_FAST_TRAP
  390. * FUNCTION: HV_FAST_CPU_GET_RTBA
  391. * RET0: status
  392. * RET1: previous RTBA
  393. * ERRORS: No possible error.
  394. *
  395. * Returns the current value of RTBA in RET1.
  396. */
  397. #define HV_FAST_CPU_GET_RTBA 0x19
  398. /* MMU services.
  399. *
  400. * Layout of a TSB description for mmu_tsb_ctx{,non}0() calls.
  401. */
  402. #ifndef __ASSEMBLY__
  403. struct hv_tsb_descr {
  404. unsigned short pgsz_idx;
  405. unsigned short assoc;
  406. unsigned int num_ttes; /* in TTEs */
  407. unsigned int ctx_idx;
  408. unsigned int pgsz_mask;
  409. unsigned long tsb_base;
  410. unsigned long resv;
  411. };
  412. #endif
  413. #define HV_TSB_DESCR_PGSZ_IDX_OFFSET 0x00
  414. #define HV_TSB_DESCR_ASSOC_OFFSET 0x02
  415. #define HV_TSB_DESCR_NUM_TTES_OFFSET 0x04
  416. #define HV_TSB_DESCR_CTX_IDX_OFFSET 0x08
  417. #define HV_TSB_DESCR_PGSZ_MASK_OFFSET 0x0c
  418. #define HV_TSB_DESCR_TSB_BASE_OFFSET 0x10
  419. #define HV_TSB_DESCR_RESV_OFFSET 0x18
  420. /* Page size bitmask. */
  421. #define HV_PGSZ_MASK_8K (1 << 0)
  422. #define HV_PGSZ_MASK_64K (1 << 1)
  423. #define HV_PGSZ_MASK_512K (1 << 2)
  424. #define HV_PGSZ_MASK_4MB (1 << 3)
  425. #define HV_PGSZ_MASK_32MB (1 << 4)
  426. #define HV_PGSZ_MASK_256MB (1 << 5)
  427. #define HV_PGSZ_MASK_2GB (1 << 6)
  428. #define HV_PGSZ_MASK_16GB (1 << 7)
  429. /* Page size index. The value given in the TSB descriptor must correspond
  430. * to the smallest page size specified in the pgsz_mask page size bitmask.
  431. */
  432. #define HV_PGSZ_IDX_8K 0
  433. #define HV_PGSZ_IDX_64K 1
  434. #define HV_PGSZ_IDX_512K 2
  435. #define HV_PGSZ_IDX_4MB 3
  436. #define HV_PGSZ_IDX_32MB 4
  437. #define HV_PGSZ_IDX_256MB 5
  438. #define HV_PGSZ_IDX_2GB 6
  439. #define HV_PGSZ_IDX_16GB 7
  440. /* MMU fault status area.
  441. *
  442. * MMU related faults have their status and fault address information
  443. * placed into a memory region made available by privileged code. Each
  444. * virtual processor must make a mmu_fault_area_conf() call to tell the
  445. * hypervisor where that processor's fault status should be stored.
  446. *
  447. * The fault status block is a multiple of 64-bytes and must be aligned
  448. * on a 64-byte boundary.
  449. */
  450. #ifndef __ASSEMBLY__
  451. struct hv_fault_status {
  452. unsigned long i_fault_type;
  453. unsigned long i_fault_addr;
  454. unsigned long i_fault_ctx;
  455. unsigned long i_reserved[5];
  456. unsigned long d_fault_type;
  457. unsigned long d_fault_addr;
  458. unsigned long d_fault_ctx;
  459. unsigned long d_reserved[5];
  460. };
  461. #endif
  462. #define HV_FAULT_I_TYPE_OFFSET 0x00
  463. #define HV_FAULT_I_ADDR_OFFSET 0x08
  464. #define HV_FAULT_I_CTX_OFFSET 0x10
  465. #define HV_FAULT_D_TYPE_OFFSET 0x40
  466. #define HV_FAULT_D_ADDR_OFFSET 0x48
  467. #define HV_FAULT_D_CTX_OFFSET 0x50
  468. #define HV_FAULT_TYPE_FAST_MISS 1
  469. #define HV_FAULT_TYPE_FAST_PROT 2
  470. #define HV_FAULT_TYPE_MMU_MISS 3
  471. #define HV_FAULT_TYPE_INV_RA 4
  472. #define HV_FAULT_TYPE_PRIV_VIOL 5
  473. #define HV_FAULT_TYPE_PROT_VIOL 6
  474. #define HV_FAULT_TYPE_NFO 7
  475. #define HV_FAULT_TYPE_NFO_SEFF 8
  476. #define HV_FAULT_TYPE_INV_VA 9
  477. #define HV_FAULT_TYPE_INV_ASI 10
  478. #define HV_FAULT_TYPE_NC_ATOMIC 11
  479. #define HV_FAULT_TYPE_PRIV_ACT 12
  480. #define HV_FAULT_TYPE_RESV1 13
  481. #define HV_FAULT_TYPE_UNALIGNED 14
  482. #define HV_FAULT_TYPE_INV_PGSZ 15
  483. /* Values 16 --> -2 are reserved. */
  484. #define HV_FAULT_TYPE_MULTIPLE -1
  485. /* Flags argument for mmu_{map,unmap}_addr(), mmu_demap_{page,context,all}(),
  486. * and mmu_{map,unmap}_perm_addr().
  487. */
  488. #define HV_MMU_DMMU 0x01
  489. #define HV_MMU_IMMU 0x02
  490. #define HV_MMU_ALL (HV_MMU_DMMU | HV_MMU_IMMU)
  491. /* mmu_map_addr()
  492. * TRAP: HV_MMU_MAP_ADDR_TRAP
  493. * ARG0: virtual address
  494. * ARG1: mmu context
  495. * ARG2: TTE
  496. * ARG3: flags (HV_MMU_{IMMU,DMMU})
  497. * ERRORS: EINVAL Invalid virtual address, mmu context, or flags
  498. * EBADPGSZ Invalid page size value
  499. * ENORADDR Invalid real address in TTE
  500. *
  501. * Create a non-permanent mapping using the given TTE, virtual
  502. * address, and mmu context. The flags argument determines which
  503. * (data, or instruction, or both) TLB the mapping gets loaded into.
  504. *
  505. * The behavior is undefined if the valid bit is clear in the TTE.
  506. *
  507. * Note: This API call is for privileged code to specify temporary translation
  508. * mappings without the need to create and manage a TSB.
  509. */
  510. /* mmu_unmap_addr()
  511. * TRAP: HV_MMU_UNMAP_ADDR_TRAP
  512. * ARG0: virtual address
  513. * ARG1: mmu context
  514. * ARG2: flags (HV_MMU_{IMMU,DMMU})
  515. * ERRORS: EINVAL Invalid virtual address, mmu context, or flags
  516. *
  517. * Demaps the given virtual address in the given mmu context on this
  518. * CPU. This function is intended to be used to demap pages mapped
  519. * with mmu_map_addr. This service is equivalent to invoking
  520. * mmu_demap_page() with only the current CPU in the CPU list. The
  521. * flags argument determines which (data, or instruction, or both) TLB
  522. * the mapping gets unmapped from.
  523. *
  524. * Attempting to perform an unmap operation for a previously defined
  525. * permanent mapping will have undefined results.
  526. */
  527. /* mmu_tsb_ctx0()
  528. * TRAP: HV_FAST_TRAP
  529. * FUNCTION: HV_FAST_MMU_TSB_CTX0
  530. * ARG0: number of TSB descriptions
  531. * ARG1: TSB descriptions pointer
  532. * RET0: status
  533. * ERRORS: ENORADDR Invalid TSB descriptions pointer or
  534. * TSB base within a descriptor
  535. * EBADALIGN TSB descriptions pointer is not aligned
  536. * to an 8-byte boundary, or TSB base
  537. * within a descriptor is not aligned for
  538. * the given TSB size
  539. * EBADPGSZ Invalid page size in a TSB descriptor
  540. * EBADTSB Invalid associativity or size in a TSB
  541. * descriptor
  542. * EINVAL Invalid number of TSB descriptions, or
  543. * invalid context index in a TSB
  544. * descriptor, or index page size not
  545. * equal to smallest page size in page
  546. * size bitmask field.
  547. *
  548. * Configures the TSBs for the current CPU for virtual addresses with
  549. * context zero. The TSB descriptions pointer is a pointer to an
  550. * array of the given number of TSB descriptions.
  551. *
  552. * Note: The maximum number of TSBs available to a virtual CPU is given by the
  553. * mmu-max-#tsbs property of the cpu's corresponding "cpu" node in the
  554. * machine description.
  555. */
  556. #define HV_FAST_MMU_TSB_CTX0 0x20
  557. /* mmu_tsb_ctxnon0()
  558. * TRAP: HV_FAST_TRAP
  559. * FUNCTION: HV_FAST_MMU_TSB_CTXNON0
  560. * ARG0: number of TSB descriptions
  561. * ARG1: TSB descriptions pointer
  562. * RET0: status
  563. * ERRORS: Same as for mmu_tsb_ctx0() above.
  564. *
  565. * Configures the TSBs for the current CPU for virtual addresses with
  566. * non-zero contexts. The TSB descriptions pointer is a pointer to an
  567. * array of the given number of TSB descriptions.
  568. *
  569. * Note: A maximum of 16 TSBs may be specified in the TSB description list.
  570. */
  571. #define HV_FAST_MMU_TSB_CTXNON0 0x21
  572. /* mmu_demap_page()
  573. * TRAP: HV_FAST_TRAP
  574. * FUNCTION: HV_FAST_MMU_DEMAP_PAGE
  575. * ARG0: reserved, must be zero
  576. * ARG1: reserved, must be zero
  577. * ARG2: virtual address
  578. * ARG3: mmu context
  579. * ARG4: flags (HV_MMU_{IMMU,DMMU})
  580. * RET0: status
  581. * ERRORS: EINVAL Invalid virutal address, context, or
  582. * flags value
  583. * ENOTSUPPORTED ARG0 or ARG1 is non-zero
  584. *
  585. * Demaps any page mapping of the given virtual address in the given
  586. * mmu context for the current virtual CPU. Any virtually tagged
  587. * caches are guaranteed to be kept consistent. The flags argument
  588. * determines which TLB (instruction, or data, or both) participate in
  589. * the operation.
  590. *
  591. * ARG0 and ARG1 are both reserved and must be set to zero.
  592. */
  593. #define HV_FAST_MMU_DEMAP_PAGE 0x22
  594. /* mmu_demap_ctx()
  595. * TRAP: HV_FAST_TRAP
  596. * FUNCTION: HV_FAST_MMU_DEMAP_CTX
  597. * ARG0: reserved, must be zero
  598. * ARG1: reserved, must be zero
  599. * ARG2: mmu context
  600. * ARG3: flags (HV_MMU_{IMMU,DMMU})
  601. * RET0: status
  602. * ERRORS: EINVAL Invalid context or flags value
  603. * ENOTSUPPORTED ARG0 or ARG1 is non-zero
  604. *
  605. * Demaps all non-permanent virtual page mappings previously specified
  606. * for the given context for the current virtual CPU. Any virtual
  607. * tagged caches are guaranteed to be kept consistent. The flags
  608. * argument determines which TLB (instruction, or data, or both)
  609. * participate in the operation.
  610. *
  611. * ARG0 and ARG1 are both reserved and must be set to zero.
  612. */
  613. #define HV_FAST_MMU_DEMAP_CTX 0x23
  614. /* mmu_demap_all()
  615. * TRAP: HV_FAST_TRAP
  616. * FUNCTION: HV_FAST_MMU_DEMAP_ALL
  617. * ARG0: reserved, must be zero
  618. * ARG1: reserved, must be zero
  619. * ARG2: flags (HV_MMU_{IMMU,DMMU})
  620. * RET0: status
  621. * ERRORS: EINVAL Invalid flags value
  622. * ENOTSUPPORTED ARG0 or ARG1 is non-zero
  623. *
  624. * Demaps all non-permanent virtual page mappings previously specified
  625. * for the current virtual CPU. Any virtual tagged caches are
  626. * guaranteed to be kept consistent. The flags argument determines
  627. * which TLB (instruction, or data, or both) participate in the
  628. * operation.
  629. *
  630. * ARG0 and ARG1 are both reserved and must be set to zero.
  631. */
  632. #define HV_FAST_MMU_DEMAP_ALL 0x24
  633. /* mmu_map_perm_addr()
  634. * TRAP: HV_FAST_TRAP
  635. * FUNCTION: HV_FAST_MMU_MAP_PERM_ADDR
  636. * ARG0: virtual address
  637. * ARG1: reserved, must be zero
  638. * ARG2: TTE
  639. * ARG3: flags (HV_MMU_{IMMU,DMMU})
  640. * RET0: status
  641. * ERRORS: EINVAL Invalid virutal address or flags value
  642. * EBADPGSZ Invalid page size value
  643. * ENORADDR Invalid real address in TTE
  644. * ETOOMANY Too many mappings (max of 8 reached)
  645. *
  646. * Create a permanent mapping using the given TTE and virtual address
  647. * for context 0 on the calling virtual CPU. A maximum of 8 such
  648. * permanent mappings may be specified by privileged code. Mappings
  649. * may be removed with mmu_unmap_perm_addr().
  650. *
  651. * The behavior is undefined if a TTE with the valid bit clear is given.
  652. *
  653. * Note: This call is used to specify address space mappings for which
  654. * privileged code does not expect to receive misses. For example,
  655. * this mechanism can be used to map kernel nucleus code and data.
  656. */
  657. #define HV_FAST_MMU_MAP_PERM_ADDR 0x25
  658. /* mmu_fault_area_conf()
  659. * TRAP: HV_FAST_TRAP
  660. * FUNCTION: HV_FAST_MMU_FAULT_AREA_CONF
  661. * ARG0: real address
  662. * RET0: status
  663. * RET1: previous mmu fault area real address
  664. * ERRORS: ENORADDR Invalid real address
  665. * EBADALIGN Invalid alignment for fault area
  666. *
  667. * Configure the MMU fault status area for the calling CPU. A 64-byte
  668. * aligned real address specifies where MMU fault status information
  669. * is placed. The return value is the previously specified area, or 0
  670. * for the first invocation. Specifying a fault area at real address
  671. * 0 is not allowed.
  672. */
  673. #define HV_FAST_MMU_FAULT_AREA_CONF 0x26
  674. /* mmu_enable()
  675. * TRAP: HV_FAST_TRAP
  676. * FUNCTION: HV_FAST_MMU_ENABLE
  677. * ARG0: enable flag
  678. * ARG1: return target address
  679. * RET0: status
  680. * ERRORS: ENORADDR Invalid real address when disabling
  681. * translation.
  682. * EBADALIGN The return target address is not
  683. * aligned to an instruction.
  684. * EINVAL The enable flag request the current
  685. * operating mode (e.g. disable if already
  686. * disabled)
  687. *
  688. * Enable or disable virtual address translation for the calling CPU
  689. * within the virtual machine domain. If the enable flag is zero,
  690. * translation is disabled, any non-zero value will enable
  691. * translation.
  692. *
  693. * When this function returns, the newly selected translation mode
  694. * will be active. If the mmu is being enabled, then the return
  695. * target address is a virtual address else it is a real address.
  696. *
  697. * Upon successful completion, control will be returned to the given
  698. * return target address (ie. the cpu will jump to that address). On
  699. * failure, the previous mmu mode remains and the trap simply returns
  700. * as normal with the appropriate error code in RET0.
  701. */
  702. #define HV_FAST_MMU_ENABLE 0x27
  703. /* mmu_unmap_perm_addr()
  704. * TRAP: HV_FAST_TRAP
  705. * FUNCTION: HV_FAST_MMU_UNMAP_PERM_ADDR
  706. * ARG0: virtual address
  707. * ARG1: reserved, must be zero
  708. * ARG2: flags (HV_MMU_{IMMU,DMMU})
  709. * RET0: status
  710. * ERRORS: EINVAL Invalid virutal address or flags value
  711. * ENOMAP Specified mapping was not found
  712. *
  713. * Demaps any permanent page mapping (established via
  714. * mmu_map_perm_addr()) at the given virtual address for context 0 on
  715. * the current virtual CPU. Any virtual tagged caches are guaranteed
  716. * to be kept consistent.
  717. */
  718. #define HV_FAST_MMU_UNMAP_PERM_ADDR 0x28
  719. /* mmu_tsb_ctx0_info()
  720. * TRAP: HV_FAST_TRAP
  721. * FUNCTION: HV_FAST_MMU_TSB_CTX0_INFO
  722. * ARG0: max TSBs
  723. * ARG1: buffer pointer
  724. * RET0: status
  725. * RET1: number of TSBs
  726. * ERRORS: EINVAL Supplied buffer is too small
  727. * EBADALIGN The buffer pointer is badly aligned
  728. * ENORADDR Invalid real address for buffer pointer
  729. *
  730. * Return the TSB configuration as previous defined by mmu_tsb_ctx0()
  731. * into the provided buffer. The size of the buffer is given in ARG1
  732. * in terms of the number of TSB description entries.
  733. *
  734. * Upon return, RET1 always contains the number of TSB descriptions
  735. * previously configured. If zero TSBs were configured, EOK is
  736. * returned with RET1 containing 0.
  737. */
  738. #define HV_FAST_MMU_TSB_CTX0_INFO 0x29
  739. /* mmu_tsb_ctxnon0_info()
  740. * TRAP: HV_FAST_TRAP
  741. * FUNCTION: HV_FAST_MMU_TSB_CTXNON0_INFO
  742. * ARG0: max TSBs
  743. * ARG1: buffer pointer
  744. * RET0: status
  745. * RET1: number of TSBs
  746. * ERRORS: EINVAL Supplied buffer is too small
  747. * EBADALIGN The buffer pointer is badly aligned
  748. * ENORADDR Invalid real address for buffer pointer
  749. *
  750. * Return the TSB configuration as previous defined by
  751. * mmu_tsb_ctxnon0() into the provided buffer. The size of the buffer
  752. * is given in ARG1 in terms of the number of TSB description entries.
  753. *
  754. * Upon return, RET1 always contains the number of TSB descriptions
  755. * previously configured. If zero TSBs were configured, EOK is
  756. * returned with RET1 containing 0.
  757. */
  758. #define HV_FAST_MMU_TSB_CTXNON0_INFO 0x2a
  759. /* mmu_fault_area_info()
  760. * TRAP: HV_FAST_TRAP
  761. * FUNCTION: HV_FAST_MMU_FAULT_AREA_INFO
  762. * RET0: status
  763. * RET1: fault area real address
  764. * ERRORS: No errors defined.
  765. *
  766. * Return the currently defined MMU fault status area for the current
  767. * CPU. The real address of the fault status area is returned in
  768. * RET1, or 0 is returned in RET1 if no fault status area is defined.
  769. *
  770. * Note: mmu_fault_area_conf() may be called with the return value (RET1)
  771. * from this service if there is a need to save and restore the fault
  772. * area for a cpu.
  773. */
  774. #define HV_FAST_MMU_FAULT_AREA_INFO 0x2b
  775. /* Cache and Memory services. */
  776. /* mem_scrub()
  777. * TRAP: HV_FAST_TRAP
  778. * FUNCTION: HV_FAST_MEM_SCRUB
  779. * ARG0: real address
  780. * ARG1: length
  781. * RET0: status
  782. * RET1: length scrubbed
  783. * ERRORS: ENORADDR Invalid real address
  784. * EBADALIGN Start address or length are not correctly
  785. * aligned
  786. * EINVAL Length is zero
  787. *
  788. * Zero the memory contents in the range real address to real address
  789. * plus length minus 1. Also, valid ECC will be generated for that
  790. * memory address range. Scrubbing is started at the given real
  791. * address, but may not scrub the entire given length. The actual
  792. * length scrubbed will be returned in RET1.
  793. *
  794. * The real address and length must be aligned on an 8K boundary, or
  795. * contain the start address and length from a sun4v error report.
  796. *
  797. * Note: There are two uses for this function. The first use is to block clear
  798. * and initialize memory and the second is to scrub an u ncorrectable
  799. * error reported via a resumable or non-resumable trap. The second
  800. * use requires the arguments to be equal to the real address and length
  801. * provided in a sun4v memory error report.
  802. */
  803. #define HV_FAST_MEM_SCRUB 0x31
  804. /* mem_sync()
  805. * TRAP: HV_FAST_TRAP
  806. * FUNCTION: HV_FAST_MEM_SYNC
  807. * ARG0: real address
  808. * ARG1: length
  809. * RET0: status
  810. * RET1: length synced
  811. * ERRORS: ENORADDR Invalid real address
  812. * EBADALIGN Start address or length are not correctly
  813. * aligned
  814. * EINVAL Length is zero
  815. *
  816. * Force the next access within the real address to real address plus
  817. * length minus 1 to be fetches from main system memory. Less than
  818. * the given length may be synced, the actual amount synced is
  819. * returned in RET1. The real address and length must be aligned on
  820. * an 8K boundary.
  821. */
  822. #define HV_FAST_MEM_SYNC 0x32
  823. /* Time of day services.
  824. *
  825. * The hypervisor maintains the time of day on a per-domain basis.
  826. * Changing the time of day in one domain does not affect the time of
  827. * day on any other domain.
  828. *
  829. * Time is described by a single unsigned 64-bit word which is the
  830. * number of seconds since the UNIX Epoch (00:00:00 UTC, January 1,
  831. * 1970).
  832. */
  833. /* tod_get()
  834. * TRAP: HV_FAST_TRAP
  835. * FUNCTION: HV_FAST_TOD_GET
  836. * RET0: status
  837. * RET1: TOD
  838. * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable
  839. * ENOTSUPPORTED If TOD not supported on this platform
  840. *
  841. * Return the current time of day. May block if TOD access is
  842. * temporarily not possible.
  843. */
  844. #define HV_FAST_TOD_GET 0x50
  845. /* tod_set()
  846. * TRAP: HV_FAST_TRAP
  847. * FUNCTION: HV_FAST_TOD_SET
  848. * ARG0: TOD
  849. * RET0: status
  850. * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable
  851. * ENOTSUPPORTED If TOD not supported on this platform
  852. *
  853. * The current time of day is set to the value specified in ARG0. May
  854. * block if TOD access is temporarily not possible.
  855. */
  856. #define HV_FAST_TOD_SET 0x51
  857. /* Console services */
  858. /* con_getchar()
  859. * TRAP: HV_FAST_TRAP
  860. * FUNCTION: HV_FAST_CONS_GETCHAR
  861. * RET0: status
  862. * RET1: character
  863. * ERRORS: EWOULDBLOCK No character available.
  864. *
  865. * Returns a character from the console device. If no character is
  866. * available then an EWOULDBLOCK error is returned. If a character is
  867. * available, then the returned status is EOK and the character value
  868. * is in RET1.
  869. *
  870. * A virtual BREAK is represented by the 64-bit value -1.
  871. *
  872. * A virtual HUP signal is represented by the 64-bit value -2.
  873. */
  874. #define HV_FAST_CONS_GETCHAR 0x60
  875. /* con_putchar()
  876. * TRAP: HV_FAST_TRAP
  877. * FUNCTION: HV_FAST_CONS_PUTCHAR
  878. * ARG0: character
  879. * RET0: status
  880. * ERRORS: EINVAL Illegal character
  881. * EWOULDBLOCK Output buffer currently full, would block
  882. *
  883. * Send a character to the console device. Only character values
  884. * between 0 and 255 may be used. Values outside this range are
  885. * invalid except for the 64-bit value -1 which is used to send a
  886. * virtual BREAK.
  887. */
  888. #define HV_FAST_CONS_PUTCHAR 0x61
  889. /* con_read()
  890. * TRAP: HV_FAST_TRAP
  891. * FUNCTION: HV_FAST_CONS_READ
  892. * ARG0: buffer real address
  893. * ARG1: buffer size in bytes
  894. * RET0: status
  895. * RET1: bytes read or BREAK or HUP
  896. * ERRORS: EWOULDBLOCK No character available.
  897. *
  898. * Reads characters into a buffer from the console device. If no
  899. * character is available then an EWOULDBLOCK error is returned.
  900. * If a character is available, then the returned status is EOK
  901. * and the number of bytes read into the given buffer is provided
  902. * in RET1.
  903. *
  904. * A virtual BREAK is represented by the 64-bit RET1 value -1.
  905. *
  906. * A virtual HUP signal is represented by the 64-bit RET1 value -2.
  907. *
  908. * If BREAK or HUP are indicated, no bytes were read into buffer.
  909. */
  910. #define HV_FAST_CONS_READ 0x62
  911. /* con_write()
  912. * TRAP: HV_FAST_TRAP
  913. * FUNCTION: HV_FAST_CONS_WRITE
  914. * ARG0: buffer real address
  915. * ARG1: buffer size in bytes
  916. * RET0: status
  917. * RET1: bytes written
  918. * ERRORS: EWOULDBLOCK Output buffer currently full, would block
  919. *
  920. * Send a characters in buffer to the console device. Breaks must be
  921. * sent using con_putchar().
  922. */
  923. #define HV_FAST_CONS_WRITE 0x63
  924. #ifndef __ASSEMBLY__
  925. extern long sun4v_con_getchar(long *status);
  926. extern long sun4v_con_putchar(long c);
  927. extern long sun4v_con_read(unsigned long buffer,
  928. unsigned long size,
  929. unsigned long *bytes_read);
  930. extern unsigned long sun4v_con_write(unsigned long buffer,
  931. unsigned long size,
  932. unsigned long *bytes_written);
  933. #endif
  934. /* Trap trace services.
  935. *
  936. * The hypervisor provides a trap tracing capability for privileged
  937. * code running on each virtual CPU. Privileged code provides a
  938. * round-robin trap trace queue within which the hypervisor writes
  939. * 64-byte entries detailing hyperprivileged traps taken n behalf of
  940. * privileged code. This is provided as a debugging capability for
  941. * privileged code.
  942. *
  943. * The trap trace control structure is 64-bytes long and placed at the
  944. * start (offset 0) of the trap trace buffer, and is described as
  945. * follows:
  946. */
  947. #ifndef __ASSEMBLY__
  948. struct hv_trap_trace_control {
  949. unsigned long head_offset;
  950. unsigned long tail_offset;
  951. unsigned long __reserved[0x30 / sizeof(unsigned long)];
  952. };
  953. #endif
  954. #define HV_TRAP_TRACE_CTRL_HEAD_OFFSET 0x00
  955. #define HV_TRAP_TRACE_CTRL_TAIL_OFFSET 0x08
  956. /* The head offset is the offset of the most recently completed entry
  957. * in the trap-trace buffer. The tail offset is the offset of the
  958. * next entry to be written. The control structure is owned and
  959. * modified by the hypervisor. A guest may not modify the control
  960. * structure contents. Attempts to do so will result in undefined
  961. * behavior for the guest.
  962. *
  963. * Each trap trace buffer entry is layed out as follows:
  964. */
  965. #ifndef __ASSEMBLY__
  966. struct hv_trap_trace_entry {
  967. unsigned char type; /* Hypervisor or guest entry? */
  968. unsigned char hpstate; /* Hyper-privileged state */
  969. unsigned char tl; /* Trap level */
  970. unsigned char gl; /* Global register level */
  971. unsigned short tt; /* Trap type */
  972. unsigned short tag; /* Extended trap identifier */
  973. unsigned long tstate; /* Trap state */
  974. unsigned long tick; /* Tick */
  975. unsigned long tpc; /* Trap PC */
  976. unsigned long f1; /* Entry specific */
  977. unsigned long f2; /* Entry specific */
  978. unsigned long f3; /* Entry specific */
  979. unsigned long f4; /* Entry specific */
  980. };
  981. #endif
  982. #define HV_TRAP_TRACE_ENTRY_TYPE 0x00
  983. #define HV_TRAP_TRACE_ENTRY_HPSTATE 0x01
  984. #define HV_TRAP_TRACE_ENTRY_TL 0x02
  985. #define HV_TRAP_TRACE_ENTRY_GL 0x03
  986. #define HV_TRAP_TRACE_ENTRY_TT 0x04
  987. #define HV_TRAP_TRACE_ENTRY_TAG 0x06
  988. #define HV_TRAP_TRACE_ENTRY_TSTATE 0x08
  989. #define HV_TRAP_TRACE_ENTRY_TICK 0x10
  990. #define HV_TRAP_TRACE_ENTRY_TPC 0x18
  991. #define HV_TRAP_TRACE_ENTRY_F1 0x20
  992. #define HV_TRAP_TRACE_ENTRY_F2 0x28
  993. #define HV_TRAP_TRACE_ENTRY_F3 0x30
  994. #define HV_TRAP_TRACE_ENTRY_F4 0x38
  995. /* The type field is encoded as follows. */
  996. #define HV_TRAP_TYPE_UNDEF 0x00 /* Entry content undefined */
  997. #define HV_TRAP_TYPE_HV 0x01 /* Hypervisor trap entry */
  998. #define HV_TRAP_TYPE_GUEST 0xff /* Added via ttrace_addentry() */
  999. /* ttrace_buf_conf()
  1000. * TRAP: HV_FAST_TRAP
  1001. * FUNCTION: HV_FAST_TTRACE_BUF_CONF
  1002. * ARG0: real address
  1003. * ARG1: number of entries
  1004. * RET0: status
  1005. * RET1: number of entries
  1006. * ERRORS: ENORADDR Invalid real address
  1007. * EINVAL Size is too small
  1008. * EBADALIGN Real address not aligned on 64-byte boundary
  1009. *
  1010. * Requests hypervisor trap tracing and declares a virtual CPU's trap
  1011. * trace buffer to the hypervisor. The real address supplies the real
  1012. * base address of the trap trace queue and must be 64-byte aligned.
  1013. * Specifying a value of 0 for the number of entries disables trap
  1014. * tracing for the calling virtual CPU. The buffer allocated must be
  1015. * sized for a power of two number of 64-byte trap trace entries plus
  1016. * an initial 64-byte control structure.
  1017. *
  1018. * This may be invoked any number of times so that a virtual CPU may
  1019. * relocate a trap trace buffer or create "snapshots" of information.
  1020. *
  1021. * If the real address is illegal or badly aligned, then trap tracing
  1022. * is disabled and an error is returned.
  1023. *
  1024. * Upon failure with EINVAL, this service call returns in RET1 the
  1025. * minimum number of buffer entries required. Upon other failures
  1026. * RET1 is undefined.
  1027. */
  1028. #define HV_FAST_TTRACE_BUF_CONF 0x90
  1029. /* ttrace_buf_info()
  1030. * TRAP: HV_FAST_TRAP
  1031. * FUNCTION: HV_FAST_TTRACE_BUF_INFO
  1032. * RET0: status
  1033. * RET1: real address
  1034. * RET2: size
  1035. * ERRORS: None defined.
  1036. *
  1037. * Returns the size and location of the previously declared trap-trace
  1038. * buffer. In the event that no buffer was previously defined, or the
  1039. * buffer is disabled, this call will return a size of zero bytes.
  1040. */
  1041. #define HV_FAST_TTRACE_BUF_INFO 0x91
  1042. /* ttrace_enable()
  1043. * TRAP: HV_FAST_TRAP
  1044. * FUNCTION: HV_FAST_TTRACE_ENABLE
  1045. * ARG0: enable
  1046. * RET0: status
  1047. * RET1: previous enable state
  1048. * ERRORS: EINVAL No trap trace buffer currently defined
  1049. *
  1050. * Enable or disable trap tracing, and return the previous enabled
  1051. * state in RET1. Future systems may define various flags for the
  1052. * enable argument (ARG0), for the moment a guest should pass
  1053. * "(uint64_t) -1" to enable, and "(uint64_t) 0" to disable all
  1054. * tracing - which will ensure future compatability.
  1055. */
  1056. #define HV_FAST_TTRACE_ENABLE 0x92
  1057. /* ttrace_freeze()
  1058. * TRAP: HV_FAST_TRAP
  1059. * FUNCTION: HV_FAST_TTRACE_FREEZE
  1060. * ARG0: freeze
  1061. * RET0: status
  1062. * RET1: previous freeze state
  1063. * ERRORS: EINVAL No trap trace buffer currently defined
  1064. *
  1065. * Freeze or unfreeze trap tracing, returning the previous freeze
  1066. * state in RET1. A guest should pass a non-zero value to freeze and
  1067. * a zero value to unfreeze all tracing. The returned previous state
  1068. * is 0 for not frozen and 1 for frozen.
  1069. */
  1070. #define HV_FAST_TTRACE_FREEZE 0x93
  1071. /* ttrace_addentry()
  1072. * TRAP: HV_TTRACE_ADDENTRY_TRAP
  1073. * ARG0: tag (16-bits)
  1074. * ARG1: data word 0
  1075. * ARG2: data word 1
  1076. * ARG3: data word 2
  1077. * ARG4: data word 3
  1078. * RET0: status
  1079. * ERRORS: EINVAL No trap trace buffer currently defined
  1080. *
  1081. * Add an entry to the trap trace buffer. Upon return only ARG0/RET0
  1082. * is modified - none of the other registers holding arguments are
  1083. * volatile across this hypervisor service.
  1084. */
  1085. /* Core dump services.
  1086. *
  1087. * Since the hypervisor viraulizes and thus obscures a lot of the
  1088. * physical machine layout and state, traditional OS crash dumps can
  1089. * be difficult to diagnose especially when the problem is a
  1090. * configuration error of some sort.
  1091. *
  1092. * The dump services provide an opaque buffer into which the
  1093. * hypervisor can place it's internal state in order to assist in
  1094. * debugging such situations. The contents are opaque and extremely
  1095. * platform and hypervisor implementation specific. The guest, during
  1096. * a core dump, requests that the hypervisor update any information in
  1097. * the dump buffer in preparation to being dumped as part of the
  1098. * domain's memory image.
  1099. */
  1100. /* dump_buf_update()
  1101. * TRAP: HV_FAST_TRAP
  1102. * FUNCTION: HV_FAST_DUMP_BUF_UPDATE
  1103. * ARG0: real address
  1104. * ARG1: size
  1105. * RET0: status
  1106. * RET1: required size of dump buffer
  1107. * ERRORS: ENORADDR Invalid real address
  1108. * EBADALIGN Real address is not aligned on a 64-byte
  1109. * boundary
  1110. * EINVAL Size is non-zero but less than minimum size
  1111. * required
  1112. * ENOTSUPPORTED Operation not supported on current logical
  1113. * domain
  1114. *
  1115. * Declare a domain dump buffer to the hypervisor. The real address
  1116. * provided for the domain dump buffer must be 64-byte aligned. The
  1117. * size specifies the size of the dump buffer and may be larger than
  1118. * the minimum size specified in the machine description. The
  1119. * hypervisor will fill the dump buffer with opaque data.
  1120. *
  1121. * Note: A guest may elect to include dump buffer contents as part of a crash
  1122. * dump to assist with debugging. This function may be called any number
  1123. * of times so that a guest may relocate a dump buffer, or create
  1124. * "snapshots" of any dump-buffer information. Each call to
  1125. * dump_buf_update() atomically declares the new dump buffer to the
  1126. * hypervisor.
  1127. *
  1128. * A specified size of 0 unconfigures the dump buffer. If the real
  1129. * address is illegal or badly aligned, then any currently active dump
  1130. * buffer is disabled and an error is returned.
  1131. *
  1132. * In the event that the call fails with EINVAL, RET1 contains the
  1133. * minimum size requires by the hypervisor for a valid dump buffer.
  1134. */
  1135. #define HV_FAST_DUMP_BUF_UPDATE 0x94
  1136. /* dump_buf_info()
  1137. * TRAP: HV_FAST_TRAP
  1138. * FUNCTION: HV_FAST_DUMP_BUF_INFO
  1139. * RET0: status
  1140. * RET1: real address of current dump buffer
  1141. * RET2: size of current dump buffer
  1142. * ERRORS: No errors defined.
  1143. *
  1144. * Return the currently configures dump buffer description. A
  1145. * returned size of 0 bytes indicates an undefined dump buffer. In
  1146. * this case the return address in RET1 is undefined.
  1147. */
  1148. #define HV_FAST_DUMP_BUF_INFO 0x95
  1149. /* Device interrupt services.
  1150. *
  1151. * Device interrupts are allocated to system bus bridges by the hypervisor,
  1152. * and described to OBP in the machine description. OBP then describes
  1153. * these interrupts to the OS via properties in the device tree.
  1154. *
  1155. * Terminology:
  1156. *
  1157. * cpuid Unique opaque value which represents a target cpu.
  1158. *
  1159. * devhandle Device handle. It uniquely identifies a device, and
  1160. * consistes of the lower 28-bits of the hi-cell of the
  1161. * first entry of the device's "reg" property in the
  1162. * OBP device tree.
  1163. *
  1164. * devino Device interrupt number. Specifies the relative
  1165. * interrupt number within the device. The unique
  1166. * combination of devhandle and devino are used to
  1167. * identify a specific device interrupt.
  1168. *
  1169. * Note: The devino value is the same as the values in the
  1170. * "interrupts" property or "interrupt-map" property
  1171. * in the OBP device tree for that device.
  1172. *
  1173. * sysino System interrupt number. A 64-bit unsigned interger
  1174. * representing a unique interrupt within a virtual
  1175. * machine.
  1176. *
  1177. * intr_state A flag representing the interrupt state for a given
  1178. * sysino. The state values are defined below.
  1179. *
  1180. * intr_enabled A flag representing the 'enabled' state for a given
  1181. * sysino. The enable values are defined below.
  1182. */
  1183. #define HV_INTR_STATE_IDLE 0 /* Nothing pending */
  1184. #define HV_INTR_STATE_RECEIVED 1 /* Interrupt received by hardware */
  1185. #define HV_INTR_STATE_DELIVERED 2 /* Interrupt delivered to queue */
  1186. #define HV_INTR_DISABLED 0 /* sysino not enabled */
  1187. #define HV_INTR_ENABLED 1 /* sysino enabled */
  1188. /* intr_devino_to_sysino()
  1189. * TRAP: HV_FAST_TRAP
  1190. * FUNCTION: HV_FAST_INTR_DEVINO2SYSINO
  1191. * ARG0: devhandle
  1192. * ARG1: devino
  1193. * RET0: status
  1194. * RET1: sysino
  1195. * ERRORS: EINVAL Invalid devhandle/devino
  1196. *
  1197. * Converts a device specific interrupt number of the given
  1198. * devhandle/devino into a system specific ino (sysino).
  1199. */
  1200. #define HV_FAST_INTR_DEVINO2SYSINO 0xa0
  1201. #ifndef __ASSEMBLY__
  1202. extern unsigned long sun4v_devino_to_sysino(unsigned long devhandle,
  1203. unsigned long devino);
  1204. #endif
  1205. /* intr_getenabled()
  1206. * TRAP: HV_FAST_TRAP
  1207. * FUNCTION: HV_FAST_INTR_GETENABLED
  1208. * ARG0: sysino
  1209. * RET0: status
  1210. * RET1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1211. * ERRORS: EINVAL Invalid sysino
  1212. *
  1213. * Returns interrupt enabled state in RET1 for the interrupt defined
  1214. * by the given sysino.
  1215. */
  1216. #define HV_FAST_INTR_GETENABLED 0xa1
  1217. #ifndef __ASSEMBLY__
  1218. extern unsigned long sun4v_intr_getenabled(unsigned long sysino);
  1219. #endif
  1220. /* intr_setenabled()
  1221. * TRAP: HV_FAST_TRAP
  1222. * FUNCTION: HV_FAST_INTR_SETENABLED
  1223. * ARG0: sysino
  1224. * ARG1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1225. * RET0: status
  1226. * ERRORS: EINVAL Invalid sysino or intr_enabled value
  1227. *
  1228. * Set the 'enabled' state of the interrupt sysino.
  1229. */
  1230. #define HV_FAST_INTR_SETENABLED 0xa2
  1231. #ifndef __ASSEMBLY__
  1232. extern unsigned long sun4v_intr_setenabled(unsigned long sysino, unsigned long intr_enabled);
  1233. #endif
  1234. /* intr_getstate()
  1235. * TRAP: HV_FAST_TRAP
  1236. * FUNCTION: HV_FAST_INTR_GETSTATE
  1237. * ARG0: sysino
  1238. * RET0: status
  1239. * RET1: intr_state (HV_INTR_STATE_*)
  1240. * ERRORS: EINVAL Invalid sysino
  1241. *
  1242. * Returns current state of the interrupt defined by the given sysino.
  1243. */
  1244. #define HV_FAST_INTR_GETSTATE 0xa3
  1245. #ifndef __ASSEMBLY__
  1246. extern unsigned long sun4v_intr_getstate(unsigned long sysino);
  1247. #endif
  1248. /* intr_setstate()
  1249. * TRAP: HV_FAST_TRAP
  1250. * FUNCTION: HV_FAST_INTR_SETSTATE
  1251. * ARG0: sysino
  1252. * ARG1: intr_state (HV_INTR_STATE_*)
  1253. * RET0: status
  1254. * ERRORS: EINVAL Invalid sysino or intr_state value
  1255. *
  1256. * Sets the current state of the interrupt described by the given sysino
  1257. * value.
  1258. *
  1259. * Note: Setting the state to HV_INTR_STATE_IDLE clears any pending
  1260. * interrupt for sysino.
  1261. */
  1262. #define HV_FAST_INTR_SETSTATE 0xa4
  1263. #ifndef __ASSEMBLY__
  1264. extern unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long intr_state);
  1265. #endif
  1266. /* intr_gettarget()
  1267. * TRAP: HV_FAST_TRAP
  1268. * FUNCTION: HV_FAST_INTR_GETTARGET
  1269. * ARG0: sysino
  1270. * RET0: status
  1271. * RET1: cpuid
  1272. * ERRORS: EINVAL Invalid sysino
  1273. *
  1274. * Returns CPU that is the current target of the interrupt defined by
  1275. * the given sysino. The CPU value returned is undefined if the target
  1276. * has not been set via intr_settarget().
  1277. */
  1278. #define HV_FAST_INTR_GETTARGET 0xa5
  1279. #ifndef __ASSEMBLY__
  1280. extern unsigned long sun4v_intr_gettarget(unsigned long sysino);
  1281. #endif
  1282. /* intr_settarget()
  1283. * TRAP: HV_FAST_TRAP
  1284. * FUNCTION: HV_FAST_INTR_SETTARGET
  1285. * ARG0: sysino
  1286. * ARG1: cpuid
  1287. * RET0: status
  1288. * ERRORS: EINVAL Invalid sysino
  1289. * ENOCPU Invalid cpuid
  1290. *
  1291. * Set the target CPU for the interrupt defined by the given sysino.
  1292. */
  1293. #define HV_FAST_INTR_SETTARGET 0xa6
  1294. #ifndef __ASSEMBLY__
  1295. extern unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cpuid);
  1296. #endif
  1297. /* PCI IO services.
  1298. *
  1299. * See the terminology descriptions in the device interrupt services
  1300. * section above as those apply here too. Here are terminology
  1301. * definitions specific to these PCI IO services:
  1302. *
  1303. * tsbnum TSB number. Indentifies which io-tsb is used.
  1304. * For this version of the specification, tsbnum
  1305. * must be zero.
  1306. *
  1307. * tsbindex TSB index. Identifies which entry in the TSB
  1308. * is used. The first entry is zero.
  1309. *
  1310. * tsbid A 64-bit aligned data structure which contains
  1311. * a tsbnum and a tsbindex. Bits 63:32 contain the
  1312. * tsbnum and bits 31:00 contain the tsbindex.
  1313. *
  1314. * Use the HV_PCI_TSBID() macro to construct such
  1315. * values.
  1316. *
  1317. * io_attributes IO attributes for IOMMU mappings. One of more
  1318. * of the attritbute bits are stores in a 64-bit
  1319. * value. The values are defined below.
  1320. *
  1321. * r_addr 64-bit real address
  1322. *
  1323. * pci_device PCI device address. A PCI device address identifies
  1324. * a specific device on a specific PCI bus segment.
  1325. * A PCI device address ia a 32-bit unsigned integer
  1326. * with the following format:
  1327. *
  1328. * 00000000.bbbbbbbb.dddddfff.00000000
  1329. *
  1330. * Use the HV_PCI_DEVICE_BUILD() macro to construct
  1331. * such values.
  1332. *
  1333. * pci_config_offset
  1334. * PCI configureation space offset. For conventional
  1335. * PCI a value between 0 and 255. For extended
  1336. * configuration space, a value between 0 and 4095.
  1337. *
  1338. * Note: For PCI configuration space accesses, the offset
  1339. * must be aligned to the access size.
  1340. *
  1341. * error_flag A return value which specifies if the action succeeded
  1342. * or failed. 0 means no error, non-0 means some error
  1343. * occurred while performing the service.
  1344. *
  1345. * io_sync_direction
  1346. * Direction definition for pci_dma_sync(), defined
  1347. * below in HV_PCI_SYNC_*.
  1348. *
  1349. * io_page_list A list of io_page_addresses, an io_page_address is
  1350. * a real address.
  1351. *
  1352. * io_page_list_p A pointer to an io_page_list.
  1353. *
  1354. * "size based byte swap" - Some functions do size based byte swapping
  1355. * which allows sw to access pointers and
  1356. * counters in native form when the processor
  1357. * operates in a different endianness than the
  1358. * IO bus. Size-based byte swapping converts a
  1359. * multi-byte field between big-endian and
  1360. * little-endian format.
  1361. */
  1362. #define HV_PCI_MAP_ATTR_READ 0x01
  1363. #define HV_PCI_MAP_ATTR_WRITE 0x02
  1364. #define HV_PCI_DEVICE_BUILD(b,d,f) \
  1365. ((((b) & 0xff) << 16) | \
  1366. (((d) & 0x1f) << 11) | \
  1367. (((f) & 0x07) << 8))
  1368. #define HV_PCI_TSBID(__tsb_num, __tsb_index) \
  1369. ((((u64)(__tsb_num)) << 32UL) | ((u64)(__tsb_index)))
  1370. #define HV_PCI_SYNC_FOR_DEVICE 0x01
  1371. #define HV_PCI_SYNC_FOR_CPU 0x02
  1372. /* pci_iommu_map()
  1373. * TRAP: HV_FAST_TRAP
  1374. * FUNCTION: HV_FAST_PCI_IOMMU_MAP
  1375. * ARG0: devhandle
  1376. * ARG1: tsbid
  1377. * ARG2: #ttes
  1378. * ARG3: io_attributes
  1379. * ARG4: io_page_list_p
  1380. * RET0: status
  1381. * RET1: #ttes mapped
  1382. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex/io_attributes
  1383. * EBADALIGN Improperly aligned real address
  1384. * ENORADDR Invalid real address
  1385. *
  1386. * Create IOMMU mappings in the sun4v device defined by the given
  1387. * devhandle. The mappings are created in the TSB defined by the
  1388. * tsbnum component of the given tsbid. The first mapping is created
  1389. * in the TSB i ndex defined by the tsbindex component of the given tsbid.
  1390. * The call creates up to #ttes mappings, the first one at tsbnum, tsbindex,
  1391. * the second at tsbnum, tsbindex + 1, etc.
  1392. *
  1393. * All mappings are created with the attributes defined by the io_attributes
  1394. * argument. The page mapping addresses are described in the io_page_list
  1395. * defined by the given io_page_list_p, which is a pointer to the io_page_list.
  1396. * The first entry in the io_page_list is the address for the first iotte, the
  1397. * 2nd for the 2nd iotte, and so on.
  1398. *
  1399. * Each io_page_address in the io_page_list must be appropriately aligned.
  1400. * #ttes must be greater than zero. For this version of the spec, the tsbnum
  1401. * component of the given tsbid must be zero.
  1402. *
  1403. * Returns the actual number of mappings creates, which may be less than
  1404. * or equal to the argument #ttes. If the function returns a value which
  1405. * is less than the #ttes, the caller may continus to call the function with
  1406. * an updated tsbid, #ttes, io_page_list_p arguments until all pages are
  1407. * mapped.
  1408. *
  1409. * Note: This function does not imply an iotte cache flush. The guest must
  1410. * demap an entry before re-mapping it.
  1411. */
  1412. #define HV_FAST_PCI_IOMMU_MAP 0xb0
  1413. /* pci_iommu_demap()
  1414. * TRAP: HV_FAST_TRAP
  1415. * FUNCTION: HV_FAST_PCI_IOMMU_DEMAP
  1416. * ARG0: devhandle
  1417. * ARG1: tsbid
  1418. * ARG2: #ttes
  1419. * RET0: status
  1420. * RET1: #ttes demapped
  1421. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex
  1422. *
  1423. * Demap and flush IOMMU mappings in the device defined by the given
  1424. * devhandle. Demaps up to #ttes entries in the TSB defined by the tsbnum
  1425. * component of the given tsbid, starting at the TSB index defined by the
  1426. * tsbindex component of the given tsbid.
  1427. *
  1428. * For this version of the spec, the tsbnum of the given tsbid must be zero.
  1429. * #ttes must be greater than zero.
  1430. *
  1431. * Returns the actual number of ttes demapped, which may be less than or equal
  1432. * to the argument #ttes. If #ttes demapped is less than #ttes, the caller
  1433. * may continue to call this function with updated tsbid and #ttes arguments
  1434. * until all pages are demapped.
  1435. *
  1436. * Note: Entries do not have to be mapped to be demapped. A demap of an
  1437. * unmapped page will flush the entry from the tte cache.
  1438. */
  1439. #define HV_FAST_PCI_IOMMU_DEMAP 0xb1
  1440. /* pci_iommu_getmap()
  1441. * TRAP: HV_FAST_TRAP
  1442. * FUNCTION: HV_FAST_PCI_IOMMU_GETMAP
  1443. * ARG0: devhandle
  1444. * ARG1: tsbid
  1445. * RET0: status
  1446. * RET1: io_attributes
  1447. * RET2: real address
  1448. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex
  1449. * ENOMAP Mapping is not valid, no translation exists
  1450. *
  1451. * Read and return the mapping in the device described by the given devhandle
  1452. * and tsbid. If successful, the io_attributes shall be returned in RET1
  1453. * and the page address of the mapping shall be returned in RET2.
  1454. *
  1455. * For this version of the spec, the tsbnum component of the given tsbid
  1456. * must be zero.
  1457. */
  1458. #define HV_FAST_PCI_IOMMU_GETMAP 0xb2
  1459. /* pci_iommu_getbypass()
  1460. * TRAP: HV_FAST_TRAP
  1461. * FUNCTION: HV_FAST_PCI_IOMMU_GETBYPASS
  1462. * ARG0: devhandle
  1463. * ARG1: real address
  1464. * ARG2: io_attributes
  1465. * RET0: status
  1466. * RET1: io_addr
  1467. * ERRORS: EINVAL Invalid devhandle/io_attributes
  1468. * ENORADDR Invalid real address
  1469. * ENOTSUPPORTED Function not supported in this implementation.
  1470. *
  1471. * Create a "special" mapping in the device described by the given devhandle,
  1472. * for the given real address and attributes. Return the IO address in RET1
  1473. * if successful.
  1474. */
  1475. #define HV_FAST_PCI_IOMMU_GETBYPASS 0xb3
  1476. /* pci_config_get()
  1477. * TRAP: HV_FAST_TRAP
  1478. * FUNCTION: HV_FAST_PCI_CONFIG_GET
  1479. * ARG0: devhandle
  1480. * ARG1: pci_device
  1481. * ARG2: pci_config_offset
  1482. * ARG3: size
  1483. * RET0: status
  1484. * RET1: error_flag
  1485. * RET2: data
  1486. * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size
  1487. * EBADALIGN pci_config_offset not size aligned
  1488. * ENOACCESS Access to this offset is not permitted
  1489. *
  1490. * Read PCI configuration space for the adapter described by the given
  1491. * devhandle. Read size (1, 2, or 4) bytes of data from the given
  1492. * pci_device, at pci_config_offset from the beginning of the device's
  1493. * configuration space. If there was no error, RET1 is set to zero and
  1494. * RET2 is set to the data read. Insignificant bits in RET2 are not
  1495. * guarenteed to have any specific value and therefore must be ignored.
  1496. *
  1497. * The data returned in RET2 is size based byte swapped.
  1498. *
  1499. * If an error occurs during the read, set RET1 to a non-zero value. The
  1500. * given pci_config_offset must be 'size' aligned.
  1501. */
  1502. #define HV_FAST_PCI_CONFIG_GET 0xb4
  1503. /* pci_config_put()
  1504. * TRAP: HV_FAST_TRAP
  1505. * FUNCTION: HV_FAST_PCI_CONFIG_PUT
  1506. * ARG0: devhandle
  1507. * ARG1: pci_device
  1508. * ARG2: pci_config_offset
  1509. * ARG3: size
  1510. * ARG4: data
  1511. * RET0: status
  1512. * RET1: error_flag
  1513. * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size
  1514. * EBADALIGN pci_config_offset not size aligned
  1515. * ENOACCESS Access to this offset is not permitted
  1516. *
  1517. * Write PCI configuration space for the adapter described by the given
  1518. * devhandle. Write size (1, 2, or 4) bytes of data in a single operation,
  1519. * at pci_config_offset from the beginning of the device's configuration
  1520. * space. The data argument contains the data to be written to configuration
  1521. * space. Prior to writing, the data is size based byte swapped.
  1522. *
  1523. * If an error occurs during the write access, do not generate an error
  1524. * report, do set RET1 to a non-zero value. Otherwise RET1 is zero.
  1525. * The given pci_config_offset must be 'size' aligned.
  1526. *
  1527. * This function is permitted to read from offset zero in the configuration
  1528. * space described by the given pci_device if necessary to ensure that the
  1529. * write access to config space completes.
  1530. */
  1531. #define HV_FAST_PCI_CONFIG_PUT 0xb5
  1532. /* pci_peek()
  1533. * TRAP: HV_FAST_TRAP
  1534. * FUNCTION: HV_FAST_PCI_PEEK
  1535. * ARG0: devhandle
  1536. * ARG1: real address
  1537. * ARG2: size
  1538. * RET0: status
  1539. * RET1: error_flag
  1540. * RET2: data
  1541. * ERRORS: EINVAL Invalid devhandle or size
  1542. * EBADALIGN Improperly aligned real address
  1543. * ENORADDR Bad real address
  1544. * ENOACCESS Guest access prohibited
  1545. *
  1546. * Attempt to read the IO address given by the given devhandle, real address,
  1547. * and size. Size must be 1, 2, 4, or 8. The read is performed as a single
  1548. * access operation using the given size. If an error occurs when reading
  1549. * from the given location, do not generate an error report, but return a
  1550. * non-zero value in RET1. If the read was successful, return zero in RET1
  1551. * and return the actual data read in RET2. The data returned is size based
  1552. * byte swapped.
  1553. *
  1554. * Non-significant bits in RET2 are not guarenteed to have any specific value
  1555. * and therefore must be ignored. If RET1 is returned as non-zero, the data
  1556. * value is not guarenteed to have any specific value and should be ignored.
  1557. *
  1558. * The caller must have permission to read from the given devhandle, real
  1559. * address, which must be an IO address. The argument real address must be a
  1560. * size aligned address.
  1561. *
  1562. * The hypervisor implementation of this function must block access to any
  1563. * IO address that the guest does not have explicit permission to access.
  1564. */
  1565. #define HV_FAST_PCI_PEEK 0xb6
  1566. /* pci_poke()
  1567. * TRAP: HV_FAST_TRAP
  1568. * FUNCTION: HV_FAST_PCI_POKE
  1569. * ARG0: devhandle
  1570. * ARG1: real address
  1571. * ARG2: size
  1572. * ARG3: data
  1573. * ARG4: pci_device
  1574. * RET0: status
  1575. * RET1: error_flag
  1576. * ERRORS: EINVAL Invalid devhandle, size, or pci_device
  1577. * EBADALIGN Improperly aligned real address
  1578. * ENORADDR Bad real address
  1579. * ENOACCESS Guest access prohibited
  1580. * ENOTSUPPORTED Function is not supported by implementation
  1581. *
  1582. * Attempt to write data to the IO address given by the given devhandle,
  1583. * real address, and size. Size must be 1, 2, 4, or 8. The write is
  1584. * performed as a single access operation using the given size. Prior to
  1585. * writing the data is size based swapped.
  1586. *
  1587. * If an error occurs when writing to the given location, do not generate an
  1588. * error report, but return a non-zero value in RET1. If the write was
  1589. * successful, return zero in RET1.
  1590. *
  1591. * pci_device describes the configuration address of the device being
  1592. * written to. The implementation may safely read from offset 0 with
  1593. * the configuration space of the device described by devhandle and
  1594. * pci_device in order to guarantee that the write portion of the operation
  1595. * completes
  1596. *
  1597. * Any error that occurs due to the read shall be reported using the normal
  1598. * error reporting mechanisms .. the read error is not suppressed.
  1599. *
  1600. * The caller must have permission to write to the given devhandle, real
  1601. * address, which must be an IO address. The argument real address must be a
  1602. * size aligned address. The caller must have permission to read from
  1603. * the given devhandle, pci_device cofiguration space offset 0.
  1604. *
  1605. * The hypervisor implementation of this function must block access to any
  1606. * IO address that the guest does not have explicit permission to access.
  1607. */
  1608. #define HV_FAST_PCI_POKE 0xb7
  1609. /* pci_dma_sync()
  1610. * TRAP: HV_FAST_TRAP
  1611. * FUNCTION: HV_FAST_PCI_DMA_SYNC
  1612. * ARG0: devhandle
  1613. * ARG1: real address
  1614. * ARG2: size
  1615. * ARG3: io_sync_direction
  1616. * RET0: status
  1617. * RET1: #synced
  1618. * ERRORS: EINVAL Invalid devhandle or io_sync_direction
  1619. * ENORADDR Bad real address
  1620. *
  1621. * Synchronize a memory region described by the given real address and size,
  1622. * for the device defined by the given devhandle using the direction(s)
  1623. * defined by the given io_sync_direction. The argument size is the size of
  1624. * the memory region in bytes.
  1625. *
  1626. * Return the actual number of bytes synchronized in the return value #synced,
  1627. * which may be less than or equal to the argument size. If the return
  1628. * value #synced is less than size, the caller must continue to call this
  1629. * function with updated real address and size arguments until the entire
  1630. * memory region is synchronized.
  1631. */
  1632. #define HV_FAST_PCI_DMA_SYNC 0xb8
  1633. /* PCI MSI services. */
  1634. #define HV_MSITYPE_MSI32 0x00
  1635. #define HV_MSITYPE_MSI64 0x01
  1636. #define HV_MSIQSTATE_IDLE 0x00
  1637. #define HV_MSIQSTATE_ERROR 0x01
  1638. #define HV_MSIQ_INVALID 0x00
  1639. #define HV_MSIQ_VALID 0x01
  1640. #define HV_MSISTATE_IDLE 0x00
  1641. #define HV_MSISTATE_DELIVERED 0x01
  1642. #define HV_MSIVALID_INVALID 0x00
  1643. #define HV_MSIVALID_VALID 0x01
  1644. #define HV_PCIE_MSGTYPE_PME_MSG 0x18
  1645. #define HV_PCIE_MSGTYPE_PME_ACK_MSG 0x1b
  1646. #define HV_PCIE_MSGTYPE_CORR_MSG 0x30
  1647. #define HV_PCIE_MSGTYPE_NONFATAL_MSG 0x31
  1648. #define HV_PCIE_MSGTYPE_FATAL_MSG 0x33
  1649. #define HV_MSG_INVALID 0x00
  1650. #define HV_MSG_VALID 0x01
  1651. /* pci_msiq_conf()
  1652. * TRAP: HV_FAST_TRAP
  1653. * FUNCTION: HV_FAST_PCI_MSIQ_CONF
  1654. * ARG0: devhandle
  1655. * ARG1: msiqid
  1656. * ARG2: real address
  1657. * ARG3: number of entries
  1658. * RET0: status
  1659. * ERRORS: EINVAL Invalid devhandle, msiqid or nentries
  1660. * EBADALIGN Improperly aligned real address
  1661. * ENORADDR Bad real address
  1662. *
  1663. * Configure the MSI queue given by the devhandle and msiqid arguments,
  1664. * and to be placed at the given real address and be of the given
  1665. * number of entries. The real address must be aligned exactly to match
  1666. * the queue size. Each queue entry is 64-bytes long, so f.e. a 32 entry
  1667. * queue must be aligned on a 2048 byte real address boundary. The MSI-EQ
  1668. * Head and Tail are initialized so that the MSI-EQ is 'empty'.
  1669. *
  1670. * Implementation Note: Certain implementations have fixed sized queues. In
  1671. * that case, number of entries must contain the correct
  1672. * value.
  1673. */
  1674. #define HV_FAST_PCI_MSIQ_CONF 0xc0
  1675. /* pci_msiq_info()
  1676. * TRAP: HV_FAST_TRAP
  1677. * FUNCTION: HV_FAST_PCI_MSIQ_INFO
  1678. * ARG0: devhandle
  1679. * ARG1: msiqid
  1680. * RET0: status
  1681. * RET1: real address
  1682. * RET2: number of entries
  1683. * ERRORS: EINVAL Invalid devhandle or msiqid
  1684. *
  1685. * Return the configuration information for the MSI queue described
  1686. * by the given devhandle and msiqid. The base address of the queue
  1687. * is returned in ARG1 and the number of entries is returned in ARG2.
  1688. * If the queue is unconfigured, the real address is undefined and the
  1689. * number of entries will be returned as zero.
  1690. */
  1691. #define HV_FAST_PCI_MSIQ_INFO 0xc1
  1692. /* pci_msiq_getvalid()
  1693. * TRAP: HV_FAST_TRAP
  1694. * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID
  1695. * ARG0: devhandle
  1696. * ARG1: msiqid
  1697. * RET0: status
  1698. * RET1: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID)
  1699. * ERRORS: EINVAL Invalid devhandle or msiqid
  1700. *
  1701. * Get the valid state of the MSI-EQ described by the given devhandle and
  1702. * msiqid.
  1703. */
  1704. #define HV_FAST_PCI_MSIQ_GETVALID 0xc2
  1705. /* pci_msiq_setvalid()
  1706. * TRAP: HV_FAST_TRAP
  1707. * FUNCTION: HV_FAST_PCI_MSIQ_SETVALID
  1708. * ARG0: devhandle
  1709. * ARG1: msiqid
  1710. * ARG2: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID)
  1711. * RET0: status
  1712. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqvalid
  1713. * value or MSI EQ is uninitialized
  1714. *
  1715. * Set the valid state of the MSI-EQ described by the given devhandle and
  1716. * msiqid to the given msiqvalid.
  1717. */
  1718. #define HV_FAST_PCI_MSIQ_SETVALID 0xc3
  1719. /* pci_msiq_getstate()
  1720. * TRAP: HV_FAST_TRAP
  1721. * FUNCTION: HV_FAST_PCI_MSIQ_GETSTATE
  1722. * ARG0: devhandle
  1723. * ARG1: msiqid
  1724. * RET0: status
  1725. * RET1: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
  1726. * ERRORS: EINVAL Invalid devhandle or msiqid
  1727. *
  1728. * Get the state of the MSI-EQ described by the given devhandle and
  1729. * msiqid.
  1730. */
  1731. #define HV_FAST_PCI_MSIQ_GETSTATE 0xc4
  1732. /* pci_msiq_getvalid()
  1733. * TRAP: HV_FAST_TRAP
  1734. * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID
  1735. * ARG0: devhandle
  1736. * ARG1: msiqid
  1737. * ARG2: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
  1738. * RET0: status
  1739. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqstate
  1740. * value or MSI EQ is uninitialized
  1741. *
  1742. * Set the state of the MSI-EQ described by the given devhandle and
  1743. * msiqid to the given msiqvalid.
  1744. */
  1745. #define HV_FAST_PCI_MSIQ_SETSTATE 0xc5
  1746. /* pci_msiq_gethead()
  1747. * TRAP: HV_FAST_TRAP
  1748. * FUNCTION: HV_FAST_PCI_MSIQ_GETHEAD
  1749. * ARG0: devhandle
  1750. * ARG1: msiqid
  1751. * RET0: status
  1752. * RET1: msiqhead
  1753. * ERRORS: EINVAL Invalid devhandle or msiqid
  1754. *
  1755. * Get the current MSI EQ queue head for the MSI-EQ described by the
  1756. * given devhandle and msiqid.
  1757. */
  1758. #define HV_FAST_PCI_MSIQ_GETHEAD 0xc6
  1759. /* pci_msiq_sethead()
  1760. * TRAP: HV_FAST_TRAP
  1761. * FUNCTION: HV_FAST_PCI_MSIQ_SETHEAD
  1762. * ARG0: devhandle
  1763. * ARG1: msiqid
  1764. * ARG2: msiqhead
  1765. * RET0: status
  1766. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqhead,
  1767. * or MSI EQ is uninitialized
  1768. *
  1769. * Set the current MSI EQ queue head for the MSI-EQ described by the
  1770. * given devhandle and msiqid.
  1771. */
  1772. #define HV_FAST_PCI_MSIQ_SETHEAD 0xc7
  1773. /* pci_msiq_gettail()
  1774. * TRAP: HV_FAST_TRAP
  1775. * FUNCTION: HV_FAST_PCI_MSIQ_GETTAIL
  1776. * ARG0: devhandle
  1777. * ARG1: msiqid
  1778. * RET0: status
  1779. * RET1: msiqtail
  1780. * ERRORS: EINVAL Invalid devhandle or msiqid
  1781. *
  1782. * Get the current MSI EQ queue tail for the MSI-EQ described by the
  1783. * given devhandle and msiqid.
  1784. */
  1785. #define HV_FAST_PCI_MSIQ_GETTAIL 0xc8
  1786. /* pci_msi_getvalid()
  1787. * TRAP: HV_FAST_TRAP
  1788. * FUNCTION: HV_FAST_PCI_MSI_GETVALID
  1789. * ARG0: devhandle
  1790. * ARG1: msinum
  1791. * RET0: status
  1792. * RET1: msivalidstate
  1793. * ERRORS: EINVAL Invalid devhandle or msinum
  1794. *
  1795. * Get the current valid/enabled state for the MSI defined by the
  1796. * given devhandle and msinum.
  1797. */
  1798. #define HV_FAST_PCI_MSI_GETVALID 0xc9
  1799. /* pci_msi_setvalid()
  1800. * TRAP: HV_FAST_TRAP
  1801. * FUNCTION: HV_FAST_PCI_MSI_SETVALID
  1802. * ARG0: devhandle
  1803. * ARG1: msinum
  1804. * ARG2: msivalidstate
  1805. * RET0: status
  1806. * ERRORS: EINVAL Invalid devhandle or msinum or msivalidstate
  1807. *
  1808. * Set the current valid/enabled state for the MSI defined by the
  1809. * given devhandle and msinum.
  1810. */
  1811. #define HV_FAST_PCI_MSI_SETVALID 0xca
  1812. /* pci_msi_getmsiq()
  1813. * TRAP: HV_FAST_TRAP
  1814. * FUNCTION: HV_FAST_PCI_MSI_GETMSIQ
  1815. * ARG0: devhandle
  1816. * ARG1: msinum
  1817. * RET0: status
  1818. * RET1: msiqid
  1819. * ERRORS: EINVAL Invalid devhandle or msinum or MSI is unbound
  1820. *
  1821. * Get the MSI EQ that the MSI defined by the given devhandle and
  1822. * msinum is bound to.
  1823. */
  1824. #define HV_FAST_PCI_MSI_GETMSIQ 0xcb
  1825. /* pci_msi_setmsiq()
  1826. * TRAP: HV_FAST_TRAP
  1827. * FUNCTION: HV_FAST_PCI_MSI_SETMSIQ
  1828. * ARG0: devhandle
  1829. * ARG1: msinum
  1830. * ARG2: msitype
  1831. * ARG3: msiqid
  1832. * RET0: status
  1833. * ERRORS: EINVAL Invalid devhandle or msinum or msiqid
  1834. *
  1835. * Set the MSI EQ that the MSI defined by the given devhandle and
  1836. * msinum is bound to.
  1837. */
  1838. #define HV_FAST_PCI_MSI_SETMSIQ 0xcc
  1839. /* pci_msi_getstate()
  1840. * TRAP: HV_FAST_TRAP
  1841. * FUNCTION: HV_FAST_PCI_MSI_GETSTATE
  1842. * ARG0: devhandle
  1843. * ARG1: msinum
  1844. * RET0: status
  1845. * RET1: msistate
  1846. * ERRORS: EINVAL Invalid devhandle or msinum
  1847. *
  1848. * Get the state of the MSI defined by the given devhandle and msinum.
  1849. * If not initialized, return HV_MSISTATE_IDLE.
  1850. */
  1851. #define HV_FAST_PCI_MSI_GETSTATE 0xcd
  1852. /* pci_msi_setstate()
  1853. * TRAP: HV_FAST_TRAP
  1854. * FUNCTION: HV_FAST_PCI_MSI_SETSTATE
  1855. * ARG0: devhandle
  1856. * ARG1: msinum
  1857. * ARG2: msistate
  1858. * RET0: status
  1859. * ERRORS: EINVAL Invalid devhandle or msinum or msistate
  1860. *
  1861. * Set the state of the MSI defined by the given devhandle and msinum.
  1862. */
  1863. #define HV_FAST_PCI_MSI_SETSTATE 0xce
  1864. /* pci_msg_getmsiq()
  1865. * TRAP: HV_FAST_TRAP
  1866. * FUNCTION: HV_FAST_PCI_MSG_GETMSIQ
  1867. * ARG0: devhandle
  1868. * ARG1: msgtype
  1869. * RET0: status
  1870. * RET1: msiqid
  1871. * ERRORS: EINVAL Invalid devhandle or msgtype
  1872. *
  1873. * Get the MSI EQ of the MSG defined by the given devhandle and msgtype.
  1874. */
  1875. #define HV_FAST_PCI_MSG_GETMSIQ 0xd0
  1876. /* pci_msg_setmsiq()
  1877. * TRAP: HV_FAST_TRAP
  1878. * FUNCTION: HV_FAST_PCI_MSG_SETMSIQ
  1879. * ARG0: devhandle
  1880. * ARG1: msgtype
  1881. * ARG2: msiqid
  1882. * RET0: status
  1883. * ERRORS: EINVAL Invalid devhandle, msgtype, or msiqid
  1884. *
  1885. * Set the MSI EQ of the MSG defined by the given devhandle and msgtype.
  1886. */
  1887. #define HV_FAST_PCI_MSG_SETMSIQ 0xd1
  1888. /* pci_msg_getvalid()
  1889. * TRAP: HV_FAST_TRAP
  1890. * FUNCTION: HV_FAST_PCI_MSG_GETVALID
  1891. * ARG0: devhandle
  1892. * ARG1: msgtype
  1893. * RET0: status
  1894. * RET1: msgvalidstate
  1895. * ERRORS: EINVAL Invalid devhandle or msgtype
  1896. *
  1897. * Get the valid/enabled state of the MSG defined by the given
  1898. * devhandle and msgtype.
  1899. */
  1900. #define HV_FAST_PCI_MSG_GETVALID 0xd2
  1901. /* pci_msg_setvalid()
  1902. * TRAP: HV_FAST_TRAP
  1903. * FUNCTION: HV_FAST_PCI_MSG_SETVALID
  1904. * ARG0: devhandle
  1905. * ARG1: msgtype
  1906. * ARG2: msgvalidstate
  1907. * RET0: status
  1908. * ERRORS: EINVAL Invalid devhandle or msgtype or msgvalidstate
  1909. *
  1910. * Set the valid/enabled state of the MSG defined by the given
  1911. * devhandle and msgtype.
  1912. */
  1913. #define HV_FAST_PCI_MSG_SETVALID 0xd3
  1914. /* Performance counter services. */
  1915. #define HV_PERF_JBUS_PERF_CTRL_REG 0x00
  1916. #define HV_PERF_JBUS_PERF_CNT_REG 0x01
  1917. #define HV_PERF_DRAM_PERF_CTRL_REG_0 0x02
  1918. #define HV_PERF_DRAM_PERF_CNT_REG_0 0x03
  1919. #define HV_PERF_DRAM_PERF_CTRL_REG_1 0x04
  1920. #define HV_PERF_DRAM_PERF_CNT_REG_1 0x05
  1921. #define HV_PERF_DRAM_PERF_CTRL_REG_2 0x06
  1922. #define HV_PERF_DRAM_PERF_CNT_REG_2 0x07
  1923. #define HV_PERF_DRAM_PERF_CTRL_REG_3 0x08
  1924. #define HV_PERF_DRAM_PERF_CNT_REG_3 0x09
  1925. /* get_perfreg()
  1926. * TRAP: HV_FAST_TRAP
  1927. * FUNCTION: HV_FAST_GET_PERFREG
  1928. * ARG0: performance reg number
  1929. * RET0: status
  1930. * RET1: performance reg value
  1931. * ERRORS: EINVAL Invalid performance register number
  1932. * ENOACCESS No access allowed to performance counters
  1933. *
  1934. * Read the value of the given DRAM/JBUS performance counter/control register.
  1935. */
  1936. #define HV_FAST_GET_PERFREG 0x100
  1937. /* set_perfreg()
  1938. * TRAP: HV_FAST_TRAP
  1939. * FUNCTION: HV_FAST_SET_PERFREG
  1940. * ARG0: performance reg number
  1941. * ARG1: performance reg value
  1942. * RET0: status
  1943. * ERRORS: EINVAL Invalid performance register number
  1944. * ENOACCESS No access allowed to performance counters
  1945. *
  1946. * Write the given performance reg value to the given DRAM/JBUS
  1947. * performance counter/control register.
  1948. */
  1949. #define HV_FAST_SET_PERFREG 0x101
  1950. /* MMU statistics services.
  1951. *
  1952. * The hypervisor maintains MMU statistics and privileged code provides
  1953. * a buffer where these statistics can be collected. It is continually
  1954. * updated once configured. The layout is as follows:
  1955. */
  1956. #ifndef __ASSEMBLY__
  1957. struct hv_mmu_statistics {
  1958. unsigned long immu_tsb_hits_ctx0_8k_tte;
  1959. unsigned long immu_tsb_ticks_ctx0_8k_tte;
  1960. unsigned long immu_tsb_hits_ctx0_64k_tte;
  1961. unsigned long immu_tsb_ticks_ctx0_64k_tte;
  1962. unsigned long __reserved1[2];
  1963. unsigned long immu_tsb_hits_ctx0_4mb_tte;
  1964. unsigned long immu_tsb_ticks_ctx0_4mb_tte;
  1965. unsigned long __reserved2[2];
  1966. unsigned long immu_tsb_hits_ctx0_256mb_tte;
  1967. unsigned long immu_tsb_ticks_ctx0_256mb_tte;
  1968. unsigned long __reserved3[4];
  1969. unsigned long immu_tsb_hits_ctxnon0_8k_tte;
  1970. unsigned long immu_tsb_ticks_ctxnon0_8k_tte;
  1971. unsigned long immu_tsb_hits_ctxnon0_64k_tte;
  1972. unsigned long immu_tsb_ticks_ctxnon0_64k_tte;
  1973. unsigned long __reserved4[2];
  1974. unsigned long immu_tsb_hits_ctxnon0_4mb_tte;
  1975. unsigned long immu_tsb_ticks_ctxnon0_4mb_tte;
  1976. unsigned long __reserved5[2];
  1977. unsigned long immu_tsb_hits_ctxnon0_256mb_tte;
  1978. unsigned long immu_tsb_ticks_ctxnon0_256mb_tte;
  1979. unsigned long __reserved6[4];
  1980. unsigned long dmmu_tsb_hits_ctx0_8k_tte;
  1981. unsigned long dmmu_tsb_ticks_ctx0_8k_tte;
  1982. unsigned long dmmu_tsb_hits_ctx0_64k_tte;
  1983. unsigned long dmmu_tsb_ticks_ctx0_64k_tte;
  1984. unsigned long __reserved7[2];
  1985. unsigned long dmmu_tsb_hits_ctx0_4mb_tte;
  1986. unsigned long dmmu_tsb_ticks_ctx0_4mb_tte;
  1987. unsigned long __reserved8[2];
  1988. unsigned long dmmu_tsb_hits_ctx0_256mb_tte;
  1989. unsigned long dmmu_tsb_ticks_ctx0_256mb_tte;
  1990. unsigned long __reserved9[4];
  1991. unsigned long dmmu_tsb_hits_ctxnon0_8k_tte;
  1992. unsigned long dmmu_tsb_ticks_ctxnon0_8k_tte;
  1993. unsigned long dmmu_tsb_hits_ctxnon0_64k_tte;
  1994. unsigned long dmmu_tsb_ticks_ctxnon0_64k_tte;
  1995. unsigned long __reserved10[2];
  1996. unsigned long dmmu_tsb_hits_ctxnon0_4mb_tte;
  1997. unsigned long dmmu_tsb_ticks_ctxnon0_4mb_tte;
  1998. unsigned long __reserved11[2];
  1999. unsigned long dmmu_tsb_hits_ctxnon0_256mb_tte;
  2000. unsigned long dmmu_tsb_ticks_ctxnon0_256mb_tte;
  2001. unsigned long __reserved12[4];
  2002. };
  2003. #endif
  2004. /* mmustat_conf()
  2005. * TRAP: HV_FAST_TRAP
  2006. * FUNCTION: HV_FAST_MMUSTAT_CONF
  2007. * ARG0: real address
  2008. * RET0: status
  2009. * RET1: real address
  2010. * ERRORS: ENORADDR Invalid real address
  2011. * EBADALIGN Real address not aligned on 64-byte boundary
  2012. * EBADTRAP API not supported on this processor
  2013. *
  2014. * Enable MMU statistic gathering using the buffer at the given real
  2015. * address on the current virtual CPU. The new buffer real address
  2016. * is given in ARG1, and the previously specified buffer real address
  2017. * is returned in RET1, or is returned as zero for the first invocation.
  2018. *
  2019. * If the passed in real address argument is zero, this will disable
  2020. * MMU statistic collection on the current virtual CPU. If an error is
  2021. * returned then no statistics are collected.
  2022. *
  2023. * The buffer contents should be initialized to all zeros before being
  2024. * given to the hypervisor or else the statistics will be meaningless.
  2025. */
  2026. #define HV_FAST_MMUSTAT_CONF 0x102
  2027. /* mmustat_info()
  2028. * TRAP: HV_FAST_TRAP
  2029. * FUNCTION: HV_FAST_MMUSTAT_INFO
  2030. * RET0: status
  2031. * RET1: real address
  2032. * ERRORS: EBADTRAP API not supported on this processor
  2033. *
  2034. * Return the current state and real address of the currently configured
  2035. * MMU statistics buffer on the current virtual CPU.
  2036. */
  2037. #define HV_FAST_MMUSTAT_INFO 0x103
  2038. /* Function numbers for HV_CORE_TRAP. */
  2039. #define HV_CORE_SET_VER 0x00
  2040. #define HV_CORE_PUTCHAR 0x01
  2041. #define HV_CORE_EXIT 0x02
  2042. #define HV_CORE_GET_VER 0x03
  2043. /* Hypervisor API groups for use with HV_CORE_SET_VER and
  2044. * HV_CORE_GET_VER.
  2045. */
  2046. #define HV_GRP_SUN4V 0x0000
  2047. #define HV_GRP_CORE 0x0001
  2048. #define HV_GRP_INTR 0x0002
  2049. #define HV_GRP_SOFT_STATE 0x0003
  2050. #define HV_GRP_PCI 0x0100
  2051. #define HV_GRP_LDOM 0x0101
  2052. #define HV_GRP_SVC_CHAN 0x0102
  2053. #define HV_GRP_NCS 0x0103
  2054. #define HV_GRP_NIAG_PERF 0x0200
  2055. #define HV_GRP_FIRE_PERF 0x0201
  2056. #define HV_GRP_DIAG 0x0300
  2057. #ifndef __ASSEMBLY__
  2058. extern unsigned long sun4v_get_version(unsigned long group,
  2059. unsigned long *major,
  2060. unsigned long *minor);
  2061. extern unsigned long sun4v_set_version(unsigned long group,
  2062. unsigned long major,
  2063. unsigned long minor,
  2064. unsigned long *actual_minor);
  2065. extern int sun4v_hvapi_register(unsigned long group, unsigned long major,
  2066. unsigned long *minor);
  2067. extern void sun4v_hvapi_unregister(unsigned long group);
  2068. extern int sun4v_hvapi_get(unsigned long group,
  2069. unsigned long *major,
  2070. unsigned long *minor);
  2071. #endif
  2072. #endif /* !(_SPARC64_HYPERVISOR_H) */