hypervisor.h 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941
  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. #define HV_ECHANNEL 16 /* Invalid LDC channel */
  74. #define HV_EBUSY 17 /* Resource busy */
  75. /* mach_exit()
  76. * TRAP: HV_FAST_TRAP
  77. * FUNCTION: HV_FAST_MACH_EXIT
  78. * ARG0: exit code
  79. * ERRORS: This service does not return.
  80. *
  81. * Stop all CPUs in the virtual domain and place them into the stopped
  82. * state. The 64-bit exit code may be passed to a service entity as
  83. * the domain's exit status. On systems without a service entity, the
  84. * domain will undergo a reset, and the boot firmware will be
  85. * reloaded.
  86. *
  87. * This function will never return to the guest that invokes it.
  88. *
  89. * Note: By convention an exit code of zero denotes a successful exit by
  90. * the guest code. A non-zero exit code denotes a guest specific
  91. * error indication.
  92. *
  93. */
  94. #define HV_FAST_MACH_EXIT 0x00
  95. #ifndef __ASSEMBLY__
  96. extern void sun4v_mach_exit(unsigned long exit_code);
  97. #endif
  98. /* Domain services. */
  99. /* mach_desc()
  100. * TRAP: HV_FAST_TRAP
  101. * FUNCTION: HV_FAST_MACH_DESC
  102. * ARG0: buffer
  103. * ARG1: length
  104. * RET0: status
  105. * RET1: length
  106. * ERRORS: HV_EBADALIGN Buffer is badly aligned
  107. * HV_ENORADDR Buffer is to an illegal real address.
  108. * HV_EINVAL Buffer length is too small for complete
  109. * machine description.
  110. *
  111. * Copy the most current machine description into the buffer indicated
  112. * by the real address in ARG0. The buffer provided must be 16 byte
  113. * aligned. Upon success or HV_EINVAL, this service returns the
  114. * actual size of the machine description in the RET1 return value.
  115. *
  116. * Note: A method of determining the appropriate buffer size for the
  117. * machine description is to first call this service with a buffer
  118. * length of 0 bytes.
  119. */
  120. #define HV_FAST_MACH_DESC 0x01
  121. #ifndef __ASSEMBLY__
  122. extern unsigned long sun4v_mach_desc(unsigned long buffer_pa,
  123. unsigned long buf_len,
  124. unsigned long *real_buf_len);
  125. #endif
  126. /* mach_sir()
  127. * TRAP: HV_FAST_TRAP
  128. * FUNCTION: HV_FAST_MACH_SIR
  129. * ERRORS: This service does not return.
  130. *
  131. * Perform a software initiated reset of the virtual machine domain.
  132. * All CPUs are captured as soon as possible, all hardware devices are
  133. * returned to the entry default state, and the domain is restarted at
  134. * the SIR (trap type 0x04) real trap table (RTBA) entry point on one
  135. * of the CPUs. The single CPU restarted is selected as determined by
  136. * platform specific policy. Memory is preserved across this
  137. * operation.
  138. */
  139. #define HV_FAST_MACH_SIR 0x02
  140. #ifndef __ASSEMBLY__
  141. extern void sun4v_mach_sir(void);
  142. #endif
  143. /* mach_set_watchdog()
  144. * TRAP: HV_FAST_TRAP
  145. * FUNCTION: HV_FAST_MACH_SET_WATCHDOG
  146. * ARG0: timeout in milliseconds
  147. * RET0: status
  148. * RET1: time remaining in milliseconds
  149. *
  150. * A guest uses this API to set a watchdog timer. Once the gues has set
  151. * the timer, it must call the timer service again either to disable or
  152. * postpone the expiration. If the timer expires before being reset or
  153. * disabled, then the hypervisor take a platform specific action leading
  154. * to guest termination within a bounded time period. The platform action
  155. * may include recovery actions such as reporting the expiration to a
  156. * Service Processor, and/or automatically restarting the gues.
  157. *
  158. * The 'timeout' parameter is specified in milliseconds, however the
  159. * implementated granularity is given by the 'watchdog-resolution'
  160. * property in the 'platform' node of the guest's machine description.
  161. * The largest allowed timeout value is specified by the
  162. * 'watchdog-max-timeout' property of the 'platform' node.
  163. *
  164. * If the 'timeout' argument is not zero, the watchdog timer is set to
  165. * expire after a minimum of 'timeout' milliseconds.
  166. *
  167. * If the 'timeout' argument is zero, the watchdog timer is disabled.
  168. *
  169. * If the 'timeout' value exceeds the value of the 'max-watchdog-timeout'
  170. * property, the hypervisor leaves the watchdog timer state unchanged,
  171. * and returns a status of EINVAL.
  172. *
  173. * The 'time remaining' return value is valid regardless of whether the
  174. * return status is EOK or EINVAL. A non-zero return value indicates the
  175. * number of milliseconds that were remaining until the timer was to expire.
  176. * If less than one millisecond remains, the return value is '1'. If the
  177. * watchdog timer was disabled at the time of the call, the return value is
  178. * zero.
  179. *
  180. * If the hypervisor cannot support the exact timeout value requested, but
  181. * can support a larger timeout value, the hypervisor may round the actual
  182. * timeout to a value larger than the requested timeout, consequently the
  183. * 'time remaining' return value may be larger than the previously requested
  184. * timeout value.
  185. *
  186. * Any guest OS debugger should be aware that the watchdog service may be in
  187. * use. Consequently, it is recommended that the watchdog service is
  188. * disabled upon debugger entry (e.g. reaching a breakpoint), and then
  189. * re-enabled upon returning to normal execution. The API has been designed
  190. * with this in mind, and the 'time remaining' result of the disable call may
  191. * be used directly as the timeout argument of the re-enable call.
  192. */
  193. #define HV_FAST_MACH_SET_WATCHDOG 0x05
  194. #ifndef __ASSEMBLY__
  195. extern unsigned long sun4v_mach_set_watchdog(unsigned long timeout,
  196. unsigned long *orig_timeout);
  197. #endif
  198. /* CPU services.
  199. *
  200. * CPUs represent devices that can execute software threads. A single
  201. * chip that contains multiple cores or strands is represented as
  202. * multiple CPUs with unique CPU identifiers. CPUs are exported to
  203. * OBP via the machine description (and to the OS via the OBP device
  204. * tree). CPUs are always in one of three states: stopped, running,
  205. * or error.
  206. *
  207. * A CPU ID is a pre-assigned 16-bit value that uniquely identifies a
  208. * CPU within a logical domain. Operations that are to be performed
  209. * on multiple CPUs specify them via a CPU list. A CPU list is an
  210. * array in real memory, of which each 16-bit word is a CPU ID. CPU
  211. * lists are passed through the API as two arguments. The first is
  212. * the number of entries (16-bit words) in the CPU list, and the
  213. * second is the (real address) pointer to the CPU ID list.
  214. */
  215. /* cpu_start()
  216. * TRAP: HV_FAST_TRAP
  217. * FUNCTION: HV_FAST_CPU_START
  218. * ARG0: CPU ID
  219. * ARG1: PC
  220. * ARG2: RTBA
  221. * ARG3: target ARG0
  222. * RET0: status
  223. * ERRORS: ENOCPU Invalid CPU ID
  224. * EINVAL Target CPU ID is not in the stopped state
  225. * ENORADDR Invalid PC or RTBA real address
  226. * EBADALIGN Unaligned PC or unaligned RTBA
  227. * EWOULDBLOCK Starting resources are not available
  228. *
  229. * Start CPU with given CPU ID with PC in %pc and with a real trap
  230. * base address value of RTBA. The indicated CPU must be in the
  231. * stopped state. The supplied RTBA must be aligned on a 256 byte
  232. * boundary. On successful completion, the specified CPU will be in
  233. * the running state and will be supplied with "target ARG0" in %o0
  234. * and RTBA in %tba.
  235. */
  236. #define HV_FAST_CPU_START 0x10
  237. #ifndef __ASSEMBLY__
  238. extern unsigned long sun4v_cpu_start(unsigned long cpuid,
  239. unsigned long pc,
  240. unsigned long rtba,
  241. unsigned long arg0);
  242. #endif
  243. /* cpu_stop()
  244. * TRAP: HV_FAST_TRAP
  245. * FUNCTION: HV_FAST_CPU_STOP
  246. * ARG0: CPU ID
  247. * RET0: status
  248. * ERRORS: ENOCPU Invalid CPU ID
  249. * EINVAL Target CPU ID is the current cpu
  250. * EINVAL Target CPU ID is not in the running state
  251. * EWOULDBLOCK Stopping resources are not available
  252. * ENOTSUPPORTED Not supported on this platform
  253. *
  254. * The specified CPU is stopped. The indicated CPU must be in the
  255. * running state. On completion, it will be in the stopped state. It
  256. * is not legal to stop the current CPU.
  257. *
  258. * Note: As this service cannot be used to stop the current cpu, this service
  259. * may not be used to stop the last running CPU in a domain. To stop
  260. * and exit a running domain, a guest must use the mach_exit() service.
  261. */
  262. #define HV_FAST_CPU_STOP 0x11
  263. #ifndef __ASSEMBLY__
  264. extern unsigned long sun4v_cpu_stop(unsigned long cpuid);
  265. #endif
  266. /* cpu_yield()
  267. * TRAP: HV_FAST_TRAP
  268. * FUNCTION: HV_FAST_CPU_YIELD
  269. * RET0: status
  270. * ERRORS: No possible error.
  271. *
  272. * Suspend execution on the current CPU. Execution will resume when
  273. * an interrupt (device, %stick_compare, or cross-call) is targeted to
  274. * the CPU. On some CPUs, this API may be used by the hypervisor to
  275. * save power by disabling hardware strands.
  276. */
  277. #define HV_FAST_CPU_YIELD 0x12
  278. #ifndef __ASSEMBLY__
  279. extern unsigned long sun4v_cpu_yield(void);
  280. #endif
  281. /* cpu_qconf()
  282. * TRAP: HV_FAST_TRAP
  283. * FUNCTION: HV_FAST_CPU_QCONF
  284. * ARG0: queue
  285. * ARG1: base real address
  286. * ARG2: number of entries
  287. * RET0: status
  288. * ERRORS: ENORADDR Invalid base real address
  289. * EINVAL Invalid queue or number of entries is less
  290. * than 2 or too large.
  291. * EBADALIGN Base real address is not correctly aligned
  292. * for size.
  293. *
  294. * Configure the given queue to be placed at the given base real
  295. * address, with the given number of entries. The number of entries
  296. * must be a power of 2. The base real address must be aligned
  297. * exactly to match the queue size. Each queue entry is 64 bytes
  298. * long, so for example a 32 entry queue must be aligned on a 2048
  299. * byte real address boundary.
  300. *
  301. * The specified queue is unconfigured if the number of entries is given
  302. * as zero.
  303. *
  304. * For the current version of this API service, the argument queue is defined
  305. * as follows:
  306. *
  307. * queue description
  308. * ----- -------------------------
  309. * 0x3c cpu mondo queue
  310. * 0x3d device mondo queue
  311. * 0x3e resumable error queue
  312. * 0x3f non-resumable error queue
  313. *
  314. * Note: The maximum number of entries for each queue for a specific cpu may
  315. * be determined from the machine description.
  316. */
  317. #define HV_FAST_CPU_QCONF 0x14
  318. #define HV_CPU_QUEUE_CPU_MONDO 0x3c
  319. #define HV_CPU_QUEUE_DEVICE_MONDO 0x3d
  320. #define HV_CPU_QUEUE_RES_ERROR 0x3e
  321. #define HV_CPU_QUEUE_NONRES_ERROR 0x3f
  322. #ifndef __ASSEMBLY__
  323. extern unsigned long sun4v_cpu_qconf(unsigned long type,
  324. unsigned long queue_paddr,
  325. unsigned long num_queue_entries);
  326. #endif
  327. /* cpu_qinfo()
  328. * TRAP: HV_FAST_TRAP
  329. * FUNCTION: HV_FAST_CPU_QINFO
  330. * ARG0: queue
  331. * RET0: status
  332. * RET1: base real address
  333. * RET1: number of entries
  334. * ERRORS: EINVAL Invalid queue
  335. *
  336. * Return the configuration info for the given queue. The base real
  337. * address and number of entries of the defined queue are returned.
  338. * The queue argument values are the same as for cpu_qconf() above.
  339. *
  340. * If the specified queue is a valid queue number, but no queue has
  341. * been defined, the number of entries will be set to zero and the
  342. * base real address returned is undefined.
  343. */
  344. #define HV_FAST_CPU_QINFO 0x15
  345. /* cpu_mondo_send()
  346. * TRAP: HV_FAST_TRAP
  347. * FUNCTION: HV_FAST_CPU_MONDO_SEND
  348. * ARG0-1: CPU list
  349. * ARG2: data real address
  350. * RET0: status
  351. * ERRORS: EBADALIGN Mondo data is not 64-byte aligned or CPU list
  352. * is not 2-byte aligned.
  353. * ENORADDR Invalid data mondo address, or invalid cpu list
  354. * address.
  355. * ENOCPU Invalid cpu in CPU list
  356. * EWOULDBLOCK Some or all of the listed CPUs did not receive
  357. * the mondo
  358. * ECPUERROR One or more of the listed CPUs are in error
  359. * state, use HV_FAST_CPU_STATE to see which ones
  360. * EINVAL CPU list includes caller's CPU ID
  361. *
  362. * Send a mondo interrupt to the CPUs in the given CPU list with the
  363. * 64-bytes at the given data real address. The data must be 64-byte
  364. * aligned. The mondo data will be delivered to the cpu_mondo queues
  365. * of the recipient CPUs.
  366. *
  367. * In all cases, error or not, the CPUs in the CPU list to which the
  368. * mondo has been successfully delivered will be indicated by having
  369. * their entry in CPU list updated with the value 0xffff.
  370. */
  371. #define HV_FAST_CPU_MONDO_SEND 0x42
  372. #ifndef __ASSEMBLY__
  373. extern unsigned long sun4v_cpu_mondo_send(unsigned long cpu_count, unsigned long cpu_list_pa, unsigned long mondo_block_pa);
  374. #endif
  375. /* cpu_myid()
  376. * TRAP: HV_FAST_TRAP
  377. * FUNCTION: HV_FAST_CPU_MYID
  378. * RET0: status
  379. * RET1: CPU ID
  380. * ERRORS: No errors defined.
  381. *
  382. * Return the hypervisor ID handle for the current CPU. Use by a
  383. * virtual CPU to discover it's own identity.
  384. */
  385. #define HV_FAST_CPU_MYID 0x16
  386. /* cpu_state()
  387. * TRAP: HV_FAST_TRAP
  388. * FUNCTION: HV_FAST_CPU_STATE
  389. * ARG0: CPU ID
  390. * RET0: status
  391. * RET1: state
  392. * ERRORS: ENOCPU Invalid CPU ID
  393. *
  394. * Retrieve the current state of the CPU with the given CPU ID.
  395. */
  396. #define HV_FAST_CPU_STATE 0x17
  397. #define HV_CPU_STATE_STOPPED 0x01
  398. #define HV_CPU_STATE_RUNNING 0x02
  399. #define HV_CPU_STATE_ERROR 0x03
  400. #ifndef __ASSEMBLY__
  401. extern long sun4v_cpu_state(unsigned long cpuid);
  402. #endif
  403. /* cpu_set_rtba()
  404. * TRAP: HV_FAST_TRAP
  405. * FUNCTION: HV_FAST_CPU_SET_RTBA
  406. * ARG0: RTBA
  407. * RET0: status
  408. * RET1: previous RTBA
  409. * ERRORS: ENORADDR Invalid RTBA real address
  410. * EBADALIGN RTBA is incorrectly aligned for a trap table
  411. *
  412. * Set the real trap base address of the local cpu to the given RTBA.
  413. * The supplied RTBA must be aligned on a 256 byte boundary. Upon
  414. * success the previous value of the RTBA is returned in RET1.
  415. *
  416. * Note: This service does not affect %tba
  417. */
  418. #define HV_FAST_CPU_SET_RTBA 0x18
  419. /* cpu_set_rtba()
  420. * TRAP: HV_FAST_TRAP
  421. * FUNCTION: HV_FAST_CPU_GET_RTBA
  422. * RET0: status
  423. * RET1: previous RTBA
  424. * ERRORS: No possible error.
  425. *
  426. * Returns the current value of RTBA in RET1.
  427. */
  428. #define HV_FAST_CPU_GET_RTBA 0x19
  429. /* MMU services.
  430. *
  431. * Layout of a TSB description for mmu_tsb_ctx{,non}0() calls.
  432. */
  433. #ifndef __ASSEMBLY__
  434. struct hv_tsb_descr {
  435. unsigned short pgsz_idx;
  436. unsigned short assoc;
  437. unsigned int num_ttes; /* in TTEs */
  438. unsigned int ctx_idx;
  439. unsigned int pgsz_mask;
  440. unsigned long tsb_base;
  441. unsigned long resv;
  442. };
  443. #endif
  444. #define HV_TSB_DESCR_PGSZ_IDX_OFFSET 0x00
  445. #define HV_TSB_DESCR_ASSOC_OFFSET 0x02
  446. #define HV_TSB_DESCR_NUM_TTES_OFFSET 0x04
  447. #define HV_TSB_DESCR_CTX_IDX_OFFSET 0x08
  448. #define HV_TSB_DESCR_PGSZ_MASK_OFFSET 0x0c
  449. #define HV_TSB_DESCR_TSB_BASE_OFFSET 0x10
  450. #define HV_TSB_DESCR_RESV_OFFSET 0x18
  451. /* Page size bitmask. */
  452. #define HV_PGSZ_MASK_8K (1 << 0)
  453. #define HV_PGSZ_MASK_64K (1 << 1)
  454. #define HV_PGSZ_MASK_512K (1 << 2)
  455. #define HV_PGSZ_MASK_4MB (1 << 3)
  456. #define HV_PGSZ_MASK_32MB (1 << 4)
  457. #define HV_PGSZ_MASK_256MB (1 << 5)
  458. #define HV_PGSZ_MASK_2GB (1 << 6)
  459. #define HV_PGSZ_MASK_16GB (1 << 7)
  460. /* Page size index. The value given in the TSB descriptor must correspond
  461. * to the smallest page size specified in the pgsz_mask page size bitmask.
  462. */
  463. #define HV_PGSZ_IDX_8K 0
  464. #define HV_PGSZ_IDX_64K 1
  465. #define HV_PGSZ_IDX_512K 2
  466. #define HV_PGSZ_IDX_4MB 3
  467. #define HV_PGSZ_IDX_32MB 4
  468. #define HV_PGSZ_IDX_256MB 5
  469. #define HV_PGSZ_IDX_2GB 6
  470. #define HV_PGSZ_IDX_16GB 7
  471. /* MMU fault status area.
  472. *
  473. * MMU related faults have their status and fault address information
  474. * placed into a memory region made available by privileged code. Each
  475. * virtual processor must make a mmu_fault_area_conf() call to tell the
  476. * hypervisor where that processor's fault status should be stored.
  477. *
  478. * The fault status block is a multiple of 64-bytes and must be aligned
  479. * on a 64-byte boundary.
  480. */
  481. #ifndef __ASSEMBLY__
  482. struct hv_fault_status {
  483. unsigned long i_fault_type;
  484. unsigned long i_fault_addr;
  485. unsigned long i_fault_ctx;
  486. unsigned long i_reserved[5];
  487. unsigned long d_fault_type;
  488. unsigned long d_fault_addr;
  489. unsigned long d_fault_ctx;
  490. unsigned long d_reserved[5];
  491. };
  492. #endif
  493. #define HV_FAULT_I_TYPE_OFFSET 0x00
  494. #define HV_FAULT_I_ADDR_OFFSET 0x08
  495. #define HV_FAULT_I_CTX_OFFSET 0x10
  496. #define HV_FAULT_D_TYPE_OFFSET 0x40
  497. #define HV_FAULT_D_ADDR_OFFSET 0x48
  498. #define HV_FAULT_D_CTX_OFFSET 0x50
  499. #define HV_FAULT_TYPE_FAST_MISS 1
  500. #define HV_FAULT_TYPE_FAST_PROT 2
  501. #define HV_FAULT_TYPE_MMU_MISS 3
  502. #define HV_FAULT_TYPE_INV_RA 4
  503. #define HV_FAULT_TYPE_PRIV_VIOL 5
  504. #define HV_FAULT_TYPE_PROT_VIOL 6
  505. #define HV_FAULT_TYPE_NFO 7
  506. #define HV_FAULT_TYPE_NFO_SEFF 8
  507. #define HV_FAULT_TYPE_INV_VA 9
  508. #define HV_FAULT_TYPE_INV_ASI 10
  509. #define HV_FAULT_TYPE_NC_ATOMIC 11
  510. #define HV_FAULT_TYPE_PRIV_ACT 12
  511. #define HV_FAULT_TYPE_RESV1 13
  512. #define HV_FAULT_TYPE_UNALIGNED 14
  513. #define HV_FAULT_TYPE_INV_PGSZ 15
  514. /* Values 16 --> -2 are reserved. */
  515. #define HV_FAULT_TYPE_MULTIPLE -1
  516. /* Flags argument for mmu_{map,unmap}_addr(), mmu_demap_{page,context,all}(),
  517. * and mmu_{map,unmap}_perm_addr().
  518. */
  519. #define HV_MMU_DMMU 0x01
  520. #define HV_MMU_IMMU 0x02
  521. #define HV_MMU_ALL (HV_MMU_DMMU | HV_MMU_IMMU)
  522. /* mmu_map_addr()
  523. * TRAP: HV_MMU_MAP_ADDR_TRAP
  524. * ARG0: virtual address
  525. * ARG1: mmu context
  526. * ARG2: TTE
  527. * ARG3: flags (HV_MMU_{IMMU,DMMU})
  528. * ERRORS: EINVAL Invalid virtual address, mmu context, or flags
  529. * EBADPGSZ Invalid page size value
  530. * ENORADDR Invalid real address in TTE
  531. *
  532. * Create a non-permanent mapping using the given TTE, virtual
  533. * address, and mmu context. The flags argument determines which
  534. * (data, or instruction, or both) TLB the mapping gets loaded into.
  535. *
  536. * The behavior is undefined if the valid bit is clear in the TTE.
  537. *
  538. * Note: This API call is for privileged code to specify temporary translation
  539. * mappings without the need to create and manage a TSB.
  540. */
  541. /* mmu_unmap_addr()
  542. * TRAP: HV_MMU_UNMAP_ADDR_TRAP
  543. * ARG0: virtual address
  544. * ARG1: mmu context
  545. * ARG2: flags (HV_MMU_{IMMU,DMMU})
  546. * ERRORS: EINVAL Invalid virtual address, mmu context, or flags
  547. *
  548. * Demaps the given virtual address in the given mmu context on this
  549. * CPU. This function is intended to be used to demap pages mapped
  550. * with mmu_map_addr. This service is equivalent to invoking
  551. * mmu_demap_page() with only the current CPU in the CPU list. The
  552. * flags argument determines which (data, or instruction, or both) TLB
  553. * the mapping gets unmapped from.
  554. *
  555. * Attempting to perform an unmap operation for a previously defined
  556. * permanent mapping will have undefined results.
  557. */
  558. /* mmu_tsb_ctx0()
  559. * TRAP: HV_FAST_TRAP
  560. * FUNCTION: HV_FAST_MMU_TSB_CTX0
  561. * ARG0: number of TSB descriptions
  562. * ARG1: TSB descriptions pointer
  563. * RET0: status
  564. * ERRORS: ENORADDR Invalid TSB descriptions pointer or
  565. * TSB base within a descriptor
  566. * EBADALIGN TSB descriptions pointer is not aligned
  567. * to an 8-byte boundary, or TSB base
  568. * within a descriptor is not aligned for
  569. * the given TSB size
  570. * EBADPGSZ Invalid page size in a TSB descriptor
  571. * EBADTSB Invalid associativity or size in a TSB
  572. * descriptor
  573. * EINVAL Invalid number of TSB descriptions, or
  574. * invalid context index in a TSB
  575. * descriptor, or index page size not
  576. * equal to smallest page size in page
  577. * size bitmask field.
  578. *
  579. * Configures the TSBs for the current CPU for virtual addresses with
  580. * context zero. The TSB descriptions pointer is a pointer to an
  581. * array of the given number of TSB descriptions.
  582. *
  583. * Note: The maximum number of TSBs available to a virtual CPU is given by the
  584. * mmu-max-#tsbs property of the cpu's corresponding "cpu" node in the
  585. * machine description.
  586. */
  587. #define HV_FAST_MMU_TSB_CTX0 0x20
  588. #ifndef __ASSEMBLY__
  589. extern unsigned long sun4v_mmu_tsb_ctx0(unsigned long num_descriptions,
  590. unsigned long tsb_desc_ra);
  591. #endif
  592. /* mmu_tsb_ctxnon0()
  593. * TRAP: HV_FAST_TRAP
  594. * FUNCTION: HV_FAST_MMU_TSB_CTXNON0
  595. * ARG0: number of TSB descriptions
  596. * ARG1: TSB descriptions pointer
  597. * RET0: status
  598. * ERRORS: Same as for mmu_tsb_ctx0() above.
  599. *
  600. * Configures the TSBs for the current CPU for virtual addresses with
  601. * non-zero contexts. The TSB descriptions pointer is a pointer to an
  602. * array of the given number of TSB descriptions.
  603. *
  604. * Note: A maximum of 16 TSBs may be specified in the TSB description list.
  605. */
  606. #define HV_FAST_MMU_TSB_CTXNON0 0x21
  607. /* mmu_demap_page()
  608. * TRAP: HV_FAST_TRAP
  609. * FUNCTION: HV_FAST_MMU_DEMAP_PAGE
  610. * ARG0: reserved, must be zero
  611. * ARG1: reserved, must be zero
  612. * ARG2: virtual address
  613. * ARG3: mmu context
  614. * ARG4: flags (HV_MMU_{IMMU,DMMU})
  615. * RET0: status
  616. * ERRORS: EINVAL Invalid virutal address, context, or
  617. * flags value
  618. * ENOTSUPPORTED ARG0 or ARG1 is non-zero
  619. *
  620. * Demaps any page mapping of the given virtual address in the given
  621. * mmu context for the current virtual CPU. Any virtually tagged
  622. * caches are guaranteed to be kept consistent. The flags argument
  623. * determines which TLB (instruction, or data, or both) participate in
  624. * the operation.
  625. *
  626. * ARG0 and ARG1 are both reserved and must be set to zero.
  627. */
  628. #define HV_FAST_MMU_DEMAP_PAGE 0x22
  629. /* mmu_demap_ctx()
  630. * TRAP: HV_FAST_TRAP
  631. * FUNCTION: HV_FAST_MMU_DEMAP_CTX
  632. * ARG0: reserved, must be zero
  633. * ARG1: reserved, must be zero
  634. * ARG2: mmu context
  635. * ARG3: flags (HV_MMU_{IMMU,DMMU})
  636. * RET0: status
  637. * ERRORS: EINVAL Invalid context or flags value
  638. * ENOTSUPPORTED ARG0 or ARG1 is non-zero
  639. *
  640. * Demaps all non-permanent virtual page mappings previously specified
  641. * for the given context for the current virtual CPU. Any virtual
  642. * tagged caches are guaranteed to be kept consistent. The flags
  643. * argument determines which TLB (instruction, or data, or both)
  644. * participate in the operation.
  645. *
  646. * ARG0 and ARG1 are both reserved and must be set to zero.
  647. */
  648. #define HV_FAST_MMU_DEMAP_CTX 0x23
  649. /* mmu_demap_all()
  650. * TRAP: HV_FAST_TRAP
  651. * FUNCTION: HV_FAST_MMU_DEMAP_ALL
  652. * ARG0: reserved, must be zero
  653. * ARG1: reserved, must be zero
  654. * ARG2: flags (HV_MMU_{IMMU,DMMU})
  655. * RET0: status
  656. * ERRORS: EINVAL Invalid flags value
  657. * ENOTSUPPORTED ARG0 or ARG1 is non-zero
  658. *
  659. * Demaps all non-permanent virtual page mappings previously specified
  660. * for the current virtual CPU. Any virtual tagged caches are
  661. * guaranteed to be kept consistent. The flags argument determines
  662. * which TLB (instruction, or data, or both) participate in the
  663. * operation.
  664. *
  665. * ARG0 and ARG1 are both reserved and must be set to zero.
  666. */
  667. #define HV_FAST_MMU_DEMAP_ALL 0x24
  668. /* mmu_map_perm_addr()
  669. * TRAP: HV_FAST_TRAP
  670. * FUNCTION: HV_FAST_MMU_MAP_PERM_ADDR
  671. * ARG0: virtual address
  672. * ARG1: reserved, must be zero
  673. * ARG2: TTE
  674. * ARG3: flags (HV_MMU_{IMMU,DMMU})
  675. * RET0: status
  676. * ERRORS: EINVAL Invalid virutal address or flags value
  677. * EBADPGSZ Invalid page size value
  678. * ENORADDR Invalid real address in TTE
  679. * ETOOMANY Too many mappings (max of 8 reached)
  680. *
  681. * Create a permanent mapping using the given TTE and virtual address
  682. * for context 0 on the calling virtual CPU. A maximum of 8 such
  683. * permanent mappings may be specified by privileged code. Mappings
  684. * may be removed with mmu_unmap_perm_addr().
  685. *
  686. * The behavior is undefined if a TTE with the valid bit clear is given.
  687. *
  688. * Note: This call is used to specify address space mappings for which
  689. * privileged code does not expect to receive misses. For example,
  690. * this mechanism can be used to map kernel nucleus code and data.
  691. */
  692. #define HV_FAST_MMU_MAP_PERM_ADDR 0x25
  693. #ifndef __ASSEMBLY__
  694. extern unsigned long sun4v_mmu_map_perm_addr(unsigned long vaddr,
  695. unsigned long set_to_zero,
  696. unsigned long tte,
  697. unsigned long flags);
  698. #endif
  699. /* mmu_fault_area_conf()
  700. * TRAP: HV_FAST_TRAP
  701. * FUNCTION: HV_FAST_MMU_FAULT_AREA_CONF
  702. * ARG0: real address
  703. * RET0: status
  704. * RET1: previous mmu fault area real address
  705. * ERRORS: ENORADDR Invalid real address
  706. * EBADALIGN Invalid alignment for fault area
  707. *
  708. * Configure the MMU fault status area for the calling CPU. A 64-byte
  709. * aligned real address specifies where MMU fault status information
  710. * is placed. The return value is the previously specified area, or 0
  711. * for the first invocation. Specifying a fault area at real address
  712. * 0 is not allowed.
  713. */
  714. #define HV_FAST_MMU_FAULT_AREA_CONF 0x26
  715. /* mmu_enable()
  716. * TRAP: HV_FAST_TRAP
  717. * FUNCTION: HV_FAST_MMU_ENABLE
  718. * ARG0: enable flag
  719. * ARG1: return target address
  720. * RET0: status
  721. * ERRORS: ENORADDR Invalid real address when disabling
  722. * translation.
  723. * EBADALIGN The return target address is not
  724. * aligned to an instruction.
  725. * EINVAL The enable flag request the current
  726. * operating mode (e.g. disable if already
  727. * disabled)
  728. *
  729. * Enable or disable virtual address translation for the calling CPU
  730. * within the virtual machine domain. If the enable flag is zero,
  731. * translation is disabled, any non-zero value will enable
  732. * translation.
  733. *
  734. * When this function returns, the newly selected translation mode
  735. * will be active. If the mmu is being enabled, then the return
  736. * target address is a virtual address else it is a real address.
  737. *
  738. * Upon successful completion, control will be returned to the given
  739. * return target address (ie. the cpu will jump to that address). On
  740. * failure, the previous mmu mode remains and the trap simply returns
  741. * as normal with the appropriate error code in RET0.
  742. */
  743. #define HV_FAST_MMU_ENABLE 0x27
  744. /* mmu_unmap_perm_addr()
  745. * TRAP: HV_FAST_TRAP
  746. * FUNCTION: HV_FAST_MMU_UNMAP_PERM_ADDR
  747. * ARG0: virtual address
  748. * ARG1: reserved, must be zero
  749. * ARG2: flags (HV_MMU_{IMMU,DMMU})
  750. * RET0: status
  751. * ERRORS: EINVAL Invalid virutal address or flags value
  752. * ENOMAP Specified mapping was not found
  753. *
  754. * Demaps any permanent page mapping (established via
  755. * mmu_map_perm_addr()) at the given virtual address for context 0 on
  756. * the current virtual CPU. Any virtual tagged caches are guaranteed
  757. * to be kept consistent.
  758. */
  759. #define HV_FAST_MMU_UNMAP_PERM_ADDR 0x28
  760. /* mmu_tsb_ctx0_info()
  761. * TRAP: HV_FAST_TRAP
  762. * FUNCTION: HV_FAST_MMU_TSB_CTX0_INFO
  763. * ARG0: max TSBs
  764. * ARG1: buffer pointer
  765. * RET0: status
  766. * RET1: number of TSBs
  767. * ERRORS: EINVAL Supplied buffer is too small
  768. * EBADALIGN The buffer pointer is badly aligned
  769. * ENORADDR Invalid real address for buffer pointer
  770. *
  771. * Return the TSB configuration as previous defined by mmu_tsb_ctx0()
  772. * into the provided buffer. The size of the buffer is given in ARG1
  773. * in terms of the number of TSB description entries.
  774. *
  775. * Upon return, RET1 always contains the number of TSB descriptions
  776. * previously configured. If zero TSBs were configured, EOK is
  777. * returned with RET1 containing 0.
  778. */
  779. #define HV_FAST_MMU_TSB_CTX0_INFO 0x29
  780. /* mmu_tsb_ctxnon0_info()
  781. * TRAP: HV_FAST_TRAP
  782. * FUNCTION: HV_FAST_MMU_TSB_CTXNON0_INFO
  783. * ARG0: max TSBs
  784. * ARG1: buffer pointer
  785. * RET0: status
  786. * RET1: number of TSBs
  787. * ERRORS: EINVAL Supplied buffer is too small
  788. * EBADALIGN The buffer pointer is badly aligned
  789. * ENORADDR Invalid real address for buffer pointer
  790. *
  791. * Return the TSB configuration as previous defined by
  792. * mmu_tsb_ctxnon0() into the provided buffer. The size of the buffer
  793. * is given in ARG1 in terms of the number of TSB description entries.
  794. *
  795. * Upon return, RET1 always contains the number of TSB descriptions
  796. * previously configured. If zero TSBs were configured, EOK is
  797. * returned with RET1 containing 0.
  798. */
  799. #define HV_FAST_MMU_TSB_CTXNON0_INFO 0x2a
  800. /* mmu_fault_area_info()
  801. * TRAP: HV_FAST_TRAP
  802. * FUNCTION: HV_FAST_MMU_FAULT_AREA_INFO
  803. * RET0: status
  804. * RET1: fault area real address
  805. * ERRORS: No errors defined.
  806. *
  807. * Return the currently defined MMU fault status area for the current
  808. * CPU. The real address of the fault status area is returned in
  809. * RET1, or 0 is returned in RET1 if no fault status area is defined.
  810. *
  811. * Note: mmu_fault_area_conf() may be called with the return value (RET1)
  812. * from this service if there is a need to save and restore the fault
  813. * area for a cpu.
  814. */
  815. #define HV_FAST_MMU_FAULT_AREA_INFO 0x2b
  816. /* Cache and Memory services. */
  817. /* mem_scrub()
  818. * TRAP: HV_FAST_TRAP
  819. * FUNCTION: HV_FAST_MEM_SCRUB
  820. * ARG0: real address
  821. * ARG1: length
  822. * RET0: status
  823. * RET1: length scrubbed
  824. * ERRORS: ENORADDR Invalid real address
  825. * EBADALIGN Start address or length are not correctly
  826. * aligned
  827. * EINVAL Length is zero
  828. *
  829. * Zero the memory contents in the range real address to real address
  830. * plus length minus 1. Also, valid ECC will be generated for that
  831. * memory address range. Scrubbing is started at the given real
  832. * address, but may not scrub the entire given length. The actual
  833. * length scrubbed will be returned in RET1.
  834. *
  835. * The real address and length must be aligned on an 8K boundary, or
  836. * contain the start address and length from a sun4v error report.
  837. *
  838. * Note: There are two uses for this function. The first use is to block clear
  839. * and initialize memory and the second is to scrub an u ncorrectable
  840. * error reported via a resumable or non-resumable trap. The second
  841. * use requires the arguments to be equal to the real address and length
  842. * provided in a sun4v memory error report.
  843. */
  844. #define HV_FAST_MEM_SCRUB 0x31
  845. /* mem_sync()
  846. * TRAP: HV_FAST_TRAP
  847. * FUNCTION: HV_FAST_MEM_SYNC
  848. * ARG0: real address
  849. * ARG1: length
  850. * RET0: status
  851. * RET1: length synced
  852. * ERRORS: ENORADDR Invalid real address
  853. * EBADALIGN Start address or length are not correctly
  854. * aligned
  855. * EINVAL Length is zero
  856. *
  857. * Force the next access within the real address to real address plus
  858. * length minus 1 to be fetches from main system memory. Less than
  859. * the given length may be synced, the actual amount synced is
  860. * returned in RET1. The real address and length must be aligned on
  861. * an 8K boundary.
  862. */
  863. #define HV_FAST_MEM_SYNC 0x32
  864. /* Time of day services.
  865. *
  866. * The hypervisor maintains the time of day on a per-domain basis.
  867. * Changing the time of day in one domain does not affect the time of
  868. * day on any other domain.
  869. *
  870. * Time is described by a single unsigned 64-bit word which is the
  871. * number of seconds since the UNIX Epoch (00:00:00 UTC, January 1,
  872. * 1970).
  873. */
  874. /* tod_get()
  875. * TRAP: HV_FAST_TRAP
  876. * FUNCTION: HV_FAST_TOD_GET
  877. * RET0: status
  878. * RET1: TOD
  879. * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable
  880. * ENOTSUPPORTED If TOD not supported on this platform
  881. *
  882. * Return the current time of day. May block if TOD access is
  883. * temporarily not possible.
  884. */
  885. #define HV_FAST_TOD_GET 0x50
  886. #ifndef __ASSEMBLY__
  887. extern unsigned long sun4v_tod_get(unsigned long *time);
  888. #endif
  889. /* tod_set()
  890. * TRAP: HV_FAST_TRAP
  891. * FUNCTION: HV_FAST_TOD_SET
  892. * ARG0: TOD
  893. * RET0: status
  894. * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable
  895. * ENOTSUPPORTED If TOD not supported on this platform
  896. *
  897. * The current time of day is set to the value specified in ARG0. May
  898. * block if TOD access is temporarily not possible.
  899. */
  900. #define HV_FAST_TOD_SET 0x51
  901. #ifndef __ASSEMBLY__
  902. extern unsigned long sun4v_tod_set(unsigned long time);
  903. #endif
  904. /* Console services */
  905. /* con_getchar()
  906. * TRAP: HV_FAST_TRAP
  907. * FUNCTION: HV_FAST_CONS_GETCHAR
  908. * RET0: status
  909. * RET1: character
  910. * ERRORS: EWOULDBLOCK No character available.
  911. *
  912. * Returns a character from the console device. If no character is
  913. * available then an EWOULDBLOCK error is returned. If a character is
  914. * available, then the returned status is EOK and the character value
  915. * is in RET1.
  916. *
  917. * A virtual BREAK is represented by the 64-bit value -1.
  918. *
  919. * A virtual HUP signal is represented by the 64-bit value -2.
  920. */
  921. #define HV_FAST_CONS_GETCHAR 0x60
  922. /* con_putchar()
  923. * TRAP: HV_FAST_TRAP
  924. * FUNCTION: HV_FAST_CONS_PUTCHAR
  925. * ARG0: character
  926. * RET0: status
  927. * ERRORS: EINVAL Illegal character
  928. * EWOULDBLOCK Output buffer currently full, would block
  929. *
  930. * Send a character to the console device. Only character values
  931. * between 0 and 255 may be used. Values outside this range are
  932. * invalid except for the 64-bit value -1 which is used to send a
  933. * virtual BREAK.
  934. */
  935. #define HV_FAST_CONS_PUTCHAR 0x61
  936. /* con_read()
  937. * TRAP: HV_FAST_TRAP
  938. * FUNCTION: HV_FAST_CONS_READ
  939. * ARG0: buffer real address
  940. * ARG1: buffer size in bytes
  941. * RET0: status
  942. * RET1: bytes read or BREAK or HUP
  943. * ERRORS: EWOULDBLOCK No character available.
  944. *
  945. * Reads characters into a buffer from the console device. If no
  946. * character is available then an EWOULDBLOCK error is returned.
  947. * If a character is available, then the returned status is EOK
  948. * and the number of bytes read into the given buffer is provided
  949. * in RET1.
  950. *
  951. * A virtual BREAK is represented by the 64-bit RET1 value -1.
  952. *
  953. * A virtual HUP signal is represented by the 64-bit RET1 value -2.
  954. *
  955. * If BREAK or HUP are indicated, no bytes were read into buffer.
  956. */
  957. #define HV_FAST_CONS_READ 0x62
  958. /* con_write()
  959. * TRAP: HV_FAST_TRAP
  960. * FUNCTION: HV_FAST_CONS_WRITE
  961. * ARG0: buffer real address
  962. * ARG1: buffer size in bytes
  963. * RET0: status
  964. * RET1: bytes written
  965. * ERRORS: EWOULDBLOCK Output buffer currently full, would block
  966. *
  967. * Send a characters in buffer to the console device. Breaks must be
  968. * sent using con_putchar().
  969. */
  970. #define HV_FAST_CONS_WRITE 0x63
  971. #ifndef __ASSEMBLY__
  972. extern long sun4v_con_getchar(long *status);
  973. extern long sun4v_con_putchar(long c);
  974. extern long sun4v_con_read(unsigned long buffer,
  975. unsigned long size,
  976. unsigned long *bytes_read);
  977. extern unsigned long sun4v_con_write(unsigned long buffer,
  978. unsigned long size,
  979. unsigned long *bytes_written);
  980. #endif
  981. /* mach_set_soft_state()
  982. * TRAP: HV_FAST_TRAP
  983. * FUNCTION: HV_FAST_MACH_SET_SOFT_STATE
  984. * ARG0: software state
  985. * ARG1: software state description pointer
  986. * RET0: status
  987. * ERRORS: EINVAL software state not valid or software state
  988. * description is not NULL terminated
  989. * ENORADDR software state description pointer is not a
  990. * valid real address
  991. * EBADALIGNED software state description is not correctly
  992. * aligned
  993. *
  994. * This allows the guest to report it's soft state to the hypervisor. There
  995. * are two primary components to this state. The first part states whether
  996. * the guest software is running or not. The second containts optional
  997. * details specific to the software.
  998. *
  999. * The software state argument is defined below in HV_SOFT_STATE_*, and
  1000. * indicates whether the guest is operating normally or in a transitional
  1001. * state.
  1002. *
  1003. * The software state description argument is a real address of a data buffer
  1004. * of size 32-bytes aligned on a 32-byte boundary. It is treated as a NULL
  1005. * terminated 7-bit ASCII string of up to 31 characters not including the
  1006. * NULL termination.
  1007. */
  1008. #define HV_FAST_MACH_SET_SOFT_STATE 0x70
  1009. #define HV_SOFT_STATE_NORMAL 0x01
  1010. #define HV_SOFT_STATE_TRANSITION 0x02
  1011. #ifndef __ASSEMBLY__
  1012. extern unsigned long sun4v_mach_set_soft_state(unsigned long soft_state,
  1013. unsigned long msg_string_ra);
  1014. #endif
  1015. /* mach_get_soft_state()
  1016. * TRAP: HV_FAST_TRAP
  1017. * FUNCTION: HV_FAST_MACH_GET_SOFT_STATE
  1018. * ARG0: software state description pointer
  1019. * RET0: status
  1020. * RET1: software state
  1021. * ERRORS: ENORADDR software state description pointer is not a
  1022. * valid real address
  1023. * EBADALIGNED software state description is not correctly
  1024. * aligned
  1025. *
  1026. * Retrieve the current value of the guest's software state. The rules
  1027. * for the software state pointer are the same as for mach_set_soft_state()
  1028. * above.
  1029. */
  1030. #define HV_FAST_MACH_GET_SOFT_STATE 0x71
  1031. /* svc_send()
  1032. * TRAP: HV_FAST_TRAP
  1033. * FUNCTION: HV_FAST_SVC_SEND
  1034. * ARG0: service ID
  1035. * ARG1: buffer real address
  1036. * ARG2: buffer size
  1037. * RET0: STATUS
  1038. * RET1: sent_bytes
  1039. *
  1040. * Be careful, all output registers are clobbered by this operation,
  1041. * so for example it is not possible to save away a value in %o4
  1042. * across the trap.
  1043. */
  1044. #define HV_FAST_SVC_SEND 0x80
  1045. /* svc_recv()
  1046. * TRAP: HV_FAST_TRAP
  1047. * FUNCTION: HV_FAST_SVC_RECV
  1048. * ARG0: service ID
  1049. * ARG1: buffer real address
  1050. * ARG2: buffer size
  1051. * RET0: STATUS
  1052. * RET1: recv_bytes
  1053. *
  1054. * Be careful, all output registers are clobbered by this operation,
  1055. * so for example it is not possible to save away a value in %o4
  1056. * across the trap.
  1057. */
  1058. #define HV_FAST_SVC_RECV 0x81
  1059. /* svc_getstatus()
  1060. * TRAP: HV_FAST_TRAP
  1061. * FUNCTION: HV_FAST_SVC_GETSTATUS
  1062. * ARG0: service ID
  1063. * RET0: STATUS
  1064. * RET1: status bits
  1065. */
  1066. #define HV_FAST_SVC_GETSTATUS 0x82
  1067. /* svc_setstatus()
  1068. * TRAP: HV_FAST_TRAP
  1069. * FUNCTION: HV_FAST_SVC_SETSTATUS
  1070. * ARG0: service ID
  1071. * ARG1: bits to set
  1072. * RET0: STATUS
  1073. */
  1074. #define HV_FAST_SVC_SETSTATUS 0x83
  1075. /* svc_clrstatus()
  1076. * TRAP: HV_FAST_TRAP
  1077. * FUNCTION: HV_FAST_SVC_CLRSTATUS
  1078. * ARG0: service ID
  1079. * ARG1: bits to clear
  1080. * RET0: STATUS
  1081. */
  1082. #define HV_FAST_SVC_CLRSTATUS 0x84
  1083. #ifndef __ASSEMBLY__
  1084. extern unsigned long sun4v_svc_send(unsigned long svc_id,
  1085. unsigned long buffer,
  1086. unsigned long buffer_size,
  1087. unsigned long *sent_bytes);
  1088. extern unsigned long sun4v_svc_recv(unsigned long svc_id,
  1089. unsigned long buffer,
  1090. unsigned long buffer_size,
  1091. unsigned long *recv_bytes);
  1092. extern unsigned long sun4v_svc_getstatus(unsigned long svc_id,
  1093. unsigned long *status_bits);
  1094. extern unsigned long sun4v_svc_setstatus(unsigned long svc_id,
  1095. unsigned long status_bits);
  1096. extern unsigned long sun4v_svc_clrstatus(unsigned long svc_id,
  1097. unsigned long status_bits);
  1098. #endif
  1099. /* Trap trace services.
  1100. *
  1101. * The hypervisor provides a trap tracing capability for privileged
  1102. * code running on each virtual CPU. Privileged code provides a
  1103. * round-robin trap trace queue within which the hypervisor writes
  1104. * 64-byte entries detailing hyperprivileged traps taken n behalf of
  1105. * privileged code. This is provided as a debugging capability for
  1106. * privileged code.
  1107. *
  1108. * The trap trace control structure is 64-bytes long and placed at the
  1109. * start (offset 0) of the trap trace buffer, and is described as
  1110. * follows:
  1111. */
  1112. #ifndef __ASSEMBLY__
  1113. struct hv_trap_trace_control {
  1114. unsigned long head_offset;
  1115. unsigned long tail_offset;
  1116. unsigned long __reserved[0x30 / sizeof(unsigned long)];
  1117. };
  1118. #endif
  1119. #define HV_TRAP_TRACE_CTRL_HEAD_OFFSET 0x00
  1120. #define HV_TRAP_TRACE_CTRL_TAIL_OFFSET 0x08
  1121. /* The head offset is the offset of the most recently completed entry
  1122. * in the trap-trace buffer. The tail offset is the offset of the
  1123. * next entry to be written. The control structure is owned and
  1124. * modified by the hypervisor. A guest may not modify the control
  1125. * structure contents. Attempts to do so will result in undefined
  1126. * behavior for the guest.
  1127. *
  1128. * Each trap trace buffer entry is layed out as follows:
  1129. */
  1130. #ifndef __ASSEMBLY__
  1131. struct hv_trap_trace_entry {
  1132. unsigned char type; /* Hypervisor or guest entry? */
  1133. unsigned char hpstate; /* Hyper-privileged state */
  1134. unsigned char tl; /* Trap level */
  1135. unsigned char gl; /* Global register level */
  1136. unsigned short tt; /* Trap type */
  1137. unsigned short tag; /* Extended trap identifier */
  1138. unsigned long tstate; /* Trap state */
  1139. unsigned long tick; /* Tick */
  1140. unsigned long tpc; /* Trap PC */
  1141. unsigned long f1; /* Entry specific */
  1142. unsigned long f2; /* Entry specific */
  1143. unsigned long f3; /* Entry specific */
  1144. unsigned long f4; /* Entry specific */
  1145. };
  1146. #endif
  1147. #define HV_TRAP_TRACE_ENTRY_TYPE 0x00
  1148. #define HV_TRAP_TRACE_ENTRY_HPSTATE 0x01
  1149. #define HV_TRAP_TRACE_ENTRY_TL 0x02
  1150. #define HV_TRAP_TRACE_ENTRY_GL 0x03
  1151. #define HV_TRAP_TRACE_ENTRY_TT 0x04
  1152. #define HV_TRAP_TRACE_ENTRY_TAG 0x06
  1153. #define HV_TRAP_TRACE_ENTRY_TSTATE 0x08
  1154. #define HV_TRAP_TRACE_ENTRY_TICK 0x10
  1155. #define HV_TRAP_TRACE_ENTRY_TPC 0x18
  1156. #define HV_TRAP_TRACE_ENTRY_F1 0x20
  1157. #define HV_TRAP_TRACE_ENTRY_F2 0x28
  1158. #define HV_TRAP_TRACE_ENTRY_F3 0x30
  1159. #define HV_TRAP_TRACE_ENTRY_F4 0x38
  1160. /* The type field is encoded as follows. */
  1161. #define HV_TRAP_TYPE_UNDEF 0x00 /* Entry content undefined */
  1162. #define HV_TRAP_TYPE_HV 0x01 /* Hypervisor trap entry */
  1163. #define HV_TRAP_TYPE_GUEST 0xff /* Added via ttrace_addentry() */
  1164. /* ttrace_buf_conf()
  1165. * TRAP: HV_FAST_TRAP
  1166. * FUNCTION: HV_FAST_TTRACE_BUF_CONF
  1167. * ARG0: real address
  1168. * ARG1: number of entries
  1169. * RET0: status
  1170. * RET1: number of entries
  1171. * ERRORS: ENORADDR Invalid real address
  1172. * EINVAL Size is too small
  1173. * EBADALIGN Real address not aligned on 64-byte boundary
  1174. *
  1175. * Requests hypervisor trap tracing and declares a virtual CPU's trap
  1176. * trace buffer to the hypervisor. The real address supplies the real
  1177. * base address of the trap trace queue and must be 64-byte aligned.
  1178. * Specifying a value of 0 for the number of entries disables trap
  1179. * tracing for the calling virtual CPU. The buffer allocated must be
  1180. * sized for a power of two number of 64-byte trap trace entries plus
  1181. * an initial 64-byte control structure.
  1182. *
  1183. * This may be invoked any number of times so that a virtual CPU may
  1184. * relocate a trap trace buffer or create "snapshots" of information.
  1185. *
  1186. * If the real address is illegal or badly aligned, then trap tracing
  1187. * is disabled and an error is returned.
  1188. *
  1189. * Upon failure with EINVAL, this service call returns in RET1 the
  1190. * minimum number of buffer entries required. Upon other failures
  1191. * RET1 is undefined.
  1192. */
  1193. #define HV_FAST_TTRACE_BUF_CONF 0x90
  1194. /* ttrace_buf_info()
  1195. * TRAP: HV_FAST_TRAP
  1196. * FUNCTION: HV_FAST_TTRACE_BUF_INFO
  1197. * RET0: status
  1198. * RET1: real address
  1199. * RET2: size
  1200. * ERRORS: None defined.
  1201. *
  1202. * Returns the size and location of the previously declared trap-trace
  1203. * buffer. In the event that no buffer was previously defined, or the
  1204. * buffer is disabled, this call will return a size of zero bytes.
  1205. */
  1206. #define HV_FAST_TTRACE_BUF_INFO 0x91
  1207. /* ttrace_enable()
  1208. * TRAP: HV_FAST_TRAP
  1209. * FUNCTION: HV_FAST_TTRACE_ENABLE
  1210. * ARG0: enable
  1211. * RET0: status
  1212. * RET1: previous enable state
  1213. * ERRORS: EINVAL No trap trace buffer currently defined
  1214. *
  1215. * Enable or disable trap tracing, and return the previous enabled
  1216. * state in RET1. Future systems may define various flags for the
  1217. * enable argument (ARG0), for the moment a guest should pass
  1218. * "(uint64_t) -1" to enable, and "(uint64_t) 0" to disable all
  1219. * tracing - which will ensure future compatability.
  1220. */
  1221. #define HV_FAST_TTRACE_ENABLE 0x92
  1222. /* ttrace_freeze()
  1223. * TRAP: HV_FAST_TRAP
  1224. * FUNCTION: HV_FAST_TTRACE_FREEZE
  1225. * ARG0: freeze
  1226. * RET0: status
  1227. * RET1: previous freeze state
  1228. * ERRORS: EINVAL No trap trace buffer currently defined
  1229. *
  1230. * Freeze or unfreeze trap tracing, returning the previous freeze
  1231. * state in RET1. A guest should pass a non-zero value to freeze and
  1232. * a zero value to unfreeze all tracing. The returned previous state
  1233. * is 0 for not frozen and 1 for frozen.
  1234. */
  1235. #define HV_FAST_TTRACE_FREEZE 0x93
  1236. /* ttrace_addentry()
  1237. * TRAP: HV_TTRACE_ADDENTRY_TRAP
  1238. * ARG0: tag (16-bits)
  1239. * ARG1: data word 0
  1240. * ARG2: data word 1
  1241. * ARG3: data word 2
  1242. * ARG4: data word 3
  1243. * RET0: status
  1244. * ERRORS: EINVAL No trap trace buffer currently defined
  1245. *
  1246. * Add an entry to the trap trace buffer. Upon return only ARG0/RET0
  1247. * is modified - none of the other registers holding arguments are
  1248. * volatile across this hypervisor service.
  1249. */
  1250. /* Core dump services.
  1251. *
  1252. * Since the hypervisor viraulizes and thus obscures a lot of the
  1253. * physical machine layout and state, traditional OS crash dumps can
  1254. * be difficult to diagnose especially when the problem is a
  1255. * configuration error of some sort.
  1256. *
  1257. * The dump services provide an opaque buffer into which the
  1258. * hypervisor can place it's internal state in order to assist in
  1259. * debugging such situations. The contents are opaque and extremely
  1260. * platform and hypervisor implementation specific. The guest, during
  1261. * a core dump, requests that the hypervisor update any information in
  1262. * the dump buffer in preparation to being dumped as part of the
  1263. * domain's memory image.
  1264. */
  1265. /* dump_buf_update()
  1266. * TRAP: HV_FAST_TRAP
  1267. * FUNCTION: HV_FAST_DUMP_BUF_UPDATE
  1268. * ARG0: real address
  1269. * ARG1: size
  1270. * RET0: status
  1271. * RET1: required size of dump buffer
  1272. * ERRORS: ENORADDR Invalid real address
  1273. * EBADALIGN Real address is not aligned on a 64-byte
  1274. * boundary
  1275. * EINVAL Size is non-zero but less than minimum size
  1276. * required
  1277. * ENOTSUPPORTED Operation not supported on current logical
  1278. * domain
  1279. *
  1280. * Declare a domain dump buffer to the hypervisor. The real address
  1281. * provided for the domain dump buffer must be 64-byte aligned. The
  1282. * size specifies the size of the dump buffer and may be larger than
  1283. * the minimum size specified in the machine description. The
  1284. * hypervisor will fill the dump buffer with opaque data.
  1285. *
  1286. * Note: A guest may elect to include dump buffer contents as part of a crash
  1287. * dump to assist with debugging. This function may be called any number
  1288. * of times so that a guest may relocate a dump buffer, or create
  1289. * "snapshots" of any dump-buffer information. Each call to
  1290. * dump_buf_update() atomically declares the new dump buffer to the
  1291. * hypervisor.
  1292. *
  1293. * A specified size of 0 unconfigures the dump buffer. If the real
  1294. * address is illegal or badly aligned, then any currently active dump
  1295. * buffer is disabled and an error is returned.
  1296. *
  1297. * In the event that the call fails with EINVAL, RET1 contains the
  1298. * minimum size requires by the hypervisor for a valid dump buffer.
  1299. */
  1300. #define HV_FAST_DUMP_BUF_UPDATE 0x94
  1301. /* dump_buf_info()
  1302. * TRAP: HV_FAST_TRAP
  1303. * FUNCTION: HV_FAST_DUMP_BUF_INFO
  1304. * RET0: status
  1305. * RET1: real address of current dump buffer
  1306. * RET2: size of current dump buffer
  1307. * ERRORS: No errors defined.
  1308. *
  1309. * Return the currently configures dump buffer description. A
  1310. * returned size of 0 bytes indicates an undefined dump buffer. In
  1311. * this case the return address in RET1 is undefined.
  1312. */
  1313. #define HV_FAST_DUMP_BUF_INFO 0x95
  1314. /* Device interrupt services.
  1315. *
  1316. * Device interrupts are allocated to system bus bridges by the hypervisor,
  1317. * and described to OBP in the machine description. OBP then describes
  1318. * these interrupts to the OS via properties in the device tree.
  1319. *
  1320. * Terminology:
  1321. *
  1322. * cpuid Unique opaque value which represents a target cpu.
  1323. *
  1324. * devhandle Device handle. It uniquely identifies a device, and
  1325. * consistes of the lower 28-bits of the hi-cell of the
  1326. * first entry of the device's "reg" property in the
  1327. * OBP device tree.
  1328. *
  1329. * devino Device interrupt number. Specifies the relative
  1330. * interrupt number within the device. The unique
  1331. * combination of devhandle and devino are used to
  1332. * identify a specific device interrupt.
  1333. *
  1334. * Note: The devino value is the same as the values in the
  1335. * "interrupts" property or "interrupt-map" property
  1336. * in the OBP device tree for that device.
  1337. *
  1338. * sysino System interrupt number. A 64-bit unsigned interger
  1339. * representing a unique interrupt within a virtual
  1340. * machine.
  1341. *
  1342. * intr_state A flag representing the interrupt state for a given
  1343. * sysino. The state values are defined below.
  1344. *
  1345. * intr_enabled A flag representing the 'enabled' state for a given
  1346. * sysino. The enable values are defined below.
  1347. */
  1348. #define HV_INTR_STATE_IDLE 0 /* Nothing pending */
  1349. #define HV_INTR_STATE_RECEIVED 1 /* Interrupt received by hardware */
  1350. #define HV_INTR_STATE_DELIVERED 2 /* Interrupt delivered to queue */
  1351. #define HV_INTR_DISABLED 0 /* sysino not enabled */
  1352. #define HV_INTR_ENABLED 1 /* sysino enabled */
  1353. /* intr_devino_to_sysino()
  1354. * TRAP: HV_FAST_TRAP
  1355. * FUNCTION: HV_FAST_INTR_DEVINO2SYSINO
  1356. * ARG0: devhandle
  1357. * ARG1: devino
  1358. * RET0: status
  1359. * RET1: sysino
  1360. * ERRORS: EINVAL Invalid devhandle/devino
  1361. *
  1362. * Converts a device specific interrupt number of the given
  1363. * devhandle/devino into a system specific ino (sysino).
  1364. */
  1365. #define HV_FAST_INTR_DEVINO2SYSINO 0xa0
  1366. #ifndef __ASSEMBLY__
  1367. extern unsigned long sun4v_devino_to_sysino(unsigned long devhandle,
  1368. unsigned long devino);
  1369. #endif
  1370. /* intr_getenabled()
  1371. * TRAP: HV_FAST_TRAP
  1372. * FUNCTION: HV_FAST_INTR_GETENABLED
  1373. * ARG0: sysino
  1374. * RET0: status
  1375. * RET1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1376. * ERRORS: EINVAL Invalid sysino
  1377. *
  1378. * Returns interrupt enabled state in RET1 for the interrupt defined
  1379. * by the given sysino.
  1380. */
  1381. #define HV_FAST_INTR_GETENABLED 0xa1
  1382. #ifndef __ASSEMBLY__
  1383. extern unsigned long sun4v_intr_getenabled(unsigned long sysino);
  1384. #endif
  1385. /* intr_setenabled()
  1386. * TRAP: HV_FAST_TRAP
  1387. * FUNCTION: HV_FAST_INTR_SETENABLED
  1388. * ARG0: sysino
  1389. * ARG1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1390. * RET0: status
  1391. * ERRORS: EINVAL Invalid sysino or intr_enabled value
  1392. *
  1393. * Set the 'enabled' state of the interrupt sysino.
  1394. */
  1395. #define HV_FAST_INTR_SETENABLED 0xa2
  1396. #ifndef __ASSEMBLY__
  1397. extern unsigned long sun4v_intr_setenabled(unsigned long sysino, unsigned long intr_enabled);
  1398. #endif
  1399. /* intr_getstate()
  1400. * TRAP: HV_FAST_TRAP
  1401. * FUNCTION: HV_FAST_INTR_GETSTATE
  1402. * ARG0: sysino
  1403. * RET0: status
  1404. * RET1: intr_state (HV_INTR_STATE_*)
  1405. * ERRORS: EINVAL Invalid sysino
  1406. *
  1407. * Returns current state of the interrupt defined by the given sysino.
  1408. */
  1409. #define HV_FAST_INTR_GETSTATE 0xa3
  1410. #ifndef __ASSEMBLY__
  1411. extern unsigned long sun4v_intr_getstate(unsigned long sysino);
  1412. #endif
  1413. /* intr_setstate()
  1414. * TRAP: HV_FAST_TRAP
  1415. * FUNCTION: HV_FAST_INTR_SETSTATE
  1416. * ARG0: sysino
  1417. * ARG1: intr_state (HV_INTR_STATE_*)
  1418. * RET0: status
  1419. * ERRORS: EINVAL Invalid sysino or intr_state value
  1420. *
  1421. * Sets the current state of the interrupt described by the given sysino
  1422. * value.
  1423. *
  1424. * Note: Setting the state to HV_INTR_STATE_IDLE clears any pending
  1425. * interrupt for sysino.
  1426. */
  1427. #define HV_FAST_INTR_SETSTATE 0xa4
  1428. #ifndef __ASSEMBLY__
  1429. extern unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long intr_state);
  1430. #endif
  1431. /* intr_gettarget()
  1432. * TRAP: HV_FAST_TRAP
  1433. * FUNCTION: HV_FAST_INTR_GETTARGET
  1434. * ARG0: sysino
  1435. * RET0: status
  1436. * RET1: cpuid
  1437. * ERRORS: EINVAL Invalid sysino
  1438. *
  1439. * Returns CPU that is the current target of the interrupt defined by
  1440. * the given sysino. The CPU value returned is undefined if the target
  1441. * has not been set via intr_settarget().
  1442. */
  1443. #define HV_FAST_INTR_GETTARGET 0xa5
  1444. #ifndef __ASSEMBLY__
  1445. extern unsigned long sun4v_intr_gettarget(unsigned long sysino);
  1446. #endif
  1447. /* intr_settarget()
  1448. * TRAP: HV_FAST_TRAP
  1449. * FUNCTION: HV_FAST_INTR_SETTARGET
  1450. * ARG0: sysino
  1451. * ARG1: cpuid
  1452. * RET0: status
  1453. * ERRORS: EINVAL Invalid sysino
  1454. * ENOCPU Invalid cpuid
  1455. *
  1456. * Set the target CPU for the interrupt defined by the given sysino.
  1457. */
  1458. #define HV_FAST_INTR_SETTARGET 0xa6
  1459. #ifndef __ASSEMBLY__
  1460. extern unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cpuid);
  1461. #endif
  1462. /* vintr_get_cookie()
  1463. * TRAP: HV_FAST_TRAP
  1464. * FUNCTION: HV_FAST_VINTR_GET_COOKIE
  1465. * ARG0: device handle
  1466. * ARG1: device ino
  1467. * RET0: status
  1468. * RET1: cookie
  1469. */
  1470. #define HV_FAST_VINTR_GET_COOKIE 0xa7
  1471. /* vintr_set_cookie()
  1472. * TRAP: HV_FAST_TRAP
  1473. * FUNCTION: HV_FAST_VINTR_SET_COOKIE
  1474. * ARG0: device handle
  1475. * ARG1: device ino
  1476. * ARG2: cookie
  1477. * RET0: status
  1478. */
  1479. #define HV_FAST_VINTR_SET_COOKIE 0xa8
  1480. /* vintr_get_valid()
  1481. * TRAP: HV_FAST_TRAP
  1482. * FUNCTION: HV_FAST_VINTR_GET_VALID
  1483. * ARG0: device handle
  1484. * ARG1: device ino
  1485. * RET0: status
  1486. * RET1: valid state
  1487. */
  1488. #define HV_FAST_VINTR_GET_VALID 0xa9
  1489. /* vintr_set_valid()
  1490. * TRAP: HV_FAST_TRAP
  1491. * FUNCTION: HV_FAST_VINTR_SET_VALID
  1492. * ARG0: device handle
  1493. * ARG1: device ino
  1494. * ARG2: valid state
  1495. * RET0: status
  1496. */
  1497. #define HV_FAST_VINTR_SET_VALID 0xaa
  1498. /* vintr_get_state()
  1499. * TRAP: HV_FAST_TRAP
  1500. * FUNCTION: HV_FAST_VINTR_GET_STATE
  1501. * ARG0: device handle
  1502. * ARG1: device ino
  1503. * RET0: status
  1504. * RET1: state
  1505. */
  1506. #define HV_FAST_VINTR_GET_STATE 0xab
  1507. /* vintr_set_state()
  1508. * TRAP: HV_FAST_TRAP
  1509. * FUNCTION: HV_FAST_VINTR_SET_STATE
  1510. * ARG0: device handle
  1511. * ARG1: device ino
  1512. * ARG2: state
  1513. * RET0: status
  1514. */
  1515. #define HV_FAST_VINTR_SET_STATE 0xac
  1516. /* vintr_get_target()
  1517. * TRAP: HV_FAST_TRAP
  1518. * FUNCTION: HV_FAST_VINTR_GET_TARGET
  1519. * ARG0: device handle
  1520. * ARG1: device ino
  1521. * RET0: status
  1522. * RET1: cpuid
  1523. */
  1524. #define HV_FAST_VINTR_GET_TARGET 0xad
  1525. /* vintr_set_target()
  1526. * TRAP: HV_FAST_TRAP
  1527. * FUNCTION: HV_FAST_VINTR_SET_TARGET
  1528. * ARG0: device handle
  1529. * ARG1: device ino
  1530. * ARG2: cpuid
  1531. * RET0: status
  1532. */
  1533. #define HV_FAST_VINTR_SET_TARGET 0xae
  1534. #ifndef __ASSEMBLY__
  1535. extern unsigned long sun4v_vintr_get_cookie(unsigned long dev_handle,
  1536. unsigned long dev_ino,
  1537. unsigned long *cookie);
  1538. extern unsigned long sun4v_vintr_set_cookie(unsigned long dev_handle,
  1539. unsigned long dev_ino,
  1540. unsigned long cookie);
  1541. extern unsigned long sun4v_vintr_get_valid(unsigned long dev_handle,
  1542. unsigned long dev_ino,
  1543. unsigned long *valid);
  1544. extern unsigned long sun4v_vintr_set_valid(unsigned long dev_handle,
  1545. unsigned long dev_ino,
  1546. unsigned long valid);
  1547. extern unsigned long sun4v_vintr_get_state(unsigned long dev_handle,
  1548. unsigned long dev_ino,
  1549. unsigned long *state);
  1550. extern unsigned long sun4v_vintr_set_state(unsigned long dev_handle,
  1551. unsigned long dev_ino,
  1552. unsigned long state);
  1553. extern unsigned long sun4v_vintr_get_target(unsigned long dev_handle,
  1554. unsigned long dev_ino,
  1555. unsigned long *cpuid);
  1556. extern unsigned long sun4v_vintr_set_target(unsigned long dev_handle,
  1557. unsigned long dev_ino,
  1558. unsigned long cpuid);
  1559. #endif
  1560. /* PCI IO services.
  1561. *
  1562. * See the terminology descriptions in the device interrupt services
  1563. * section above as those apply here too. Here are terminology
  1564. * definitions specific to these PCI IO services:
  1565. *
  1566. * tsbnum TSB number. Indentifies which io-tsb is used.
  1567. * For this version of the specification, tsbnum
  1568. * must be zero.
  1569. *
  1570. * tsbindex TSB index. Identifies which entry in the TSB
  1571. * is used. The first entry is zero.
  1572. *
  1573. * tsbid A 64-bit aligned data structure which contains
  1574. * a tsbnum and a tsbindex. Bits 63:32 contain the
  1575. * tsbnum and bits 31:00 contain the tsbindex.
  1576. *
  1577. * Use the HV_PCI_TSBID() macro to construct such
  1578. * values.
  1579. *
  1580. * io_attributes IO attributes for IOMMU mappings. One of more
  1581. * of the attritbute bits are stores in a 64-bit
  1582. * value. The values are defined below.
  1583. *
  1584. * r_addr 64-bit real address
  1585. *
  1586. * pci_device PCI device address. A PCI device address identifies
  1587. * a specific device on a specific PCI bus segment.
  1588. * A PCI device address ia a 32-bit unsigned integer
  1589. * with the following format:
  1590. *
  1591. * 00000000.bbbbbbbb.dddddfff.00000000
  1592. *
  1593. * Use the HV_PCI_DEVICE_BUILD() macro to construct
  1594. * such values.
  1595. *
  1596. * pci_config_offset
  1597. * PCI configureation space offset. For conventional
  1598. * PCI a value between 0 and 255. For extended
  1599. * configuration space, a value between 0 and 4095.
  1600. *
  1601. * Note: For PCI configuration space accesses, the offset
  1602. * must be aligned to the access size.
  1603. *
  1604. * error_flag A return value which specifies if the action succeeded
  1605. * or failed. 0 means no error, non-0 means some error
  1606. * occurred while performing the service.
  1607. *
  1608. * io_sync_direction
  1609. * Direction definition for pci_dma_sync(), defined
  1610. * below in HV_PCI_SYNC_*.
  1611. *
  1612. * io_page_list A list of io_page_addresses, an io_page_address is
  1613. * a real address.
  1614. *
  1615. * io_page_list_p A pointer to an io_page_list.
  1616. *
  1617. * "size based byte swap" - Some functions do size based byte swapping
  1618. * which allows sw to access pointers and
  1619. * counters in native form when the processor
  1620. * operates in a different endianness than the
  1621. * IO bus. Size-based byte swapping converts a
  1622. * multi-byte field between big-endian and
  1623. * little-endian format.
  1624. */
  1625. #define HV_PCI_MAP_ATTR_READ 0x01
  1626. #define HV_PCI_MAP_ATTR_WRITE 0x02
  1627. #define HV_PCI_DEVICE_BUILD(b,d,f) \
  1628. ((((b) & 0xff) << 16) | \
  1629. (((d) & 0x1f) << 11) | \
  1630. (((f) & 0x07) << 8))
  1631. #define HV_PCI_TSBID(__tsb_num, __tsb_index) \
  1632. ((((u64)(__tsb_num)) << 32UL) | ((u64)(__tsb_index)))
  1633. #define HV_PCI_SYNC_FOR_DEVICE 0x01
  1634. #define HV_PCI_SYNC_FOR_CPU 0x02
  1635. /* pci_iommu_map()
  1636. * TRAP: HV_FAST_TRAP
  1637. * FUNCTION: HV_FAST_PCI_IOMMU_MAP
  1638. * ARG0: devhandle
  1639. * ARG1: tsbid
  1640. * ARG2: #ttes
  1641. * ARG3: io_attributes
  1642. * ARG4: io_page_list_p
  1643. * RET0: status
  1644. * RET1: #ttes mapped
  1645. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex/io_attributes
  1646. * EBADALIGN Improperly aligned real address
  1647. * ENORADDR Invalid real address
  1648. *
  1649. * Create IOMMU mappings in the sun4v device defined by the given
  1650. * devhandle. The mappings are created in the TSB defined by the
  1651. * tsbnum component of the given tsbid. The first mapping is created
  1652. * in the TSB i ndex defined by the tsbindex component of the given tsbid.
  1653. * The call creates up to #ttes mappings, the first one at tsbnum, tsbindex,
  1654. * the second at tsbnum, tsbindex + 1, etc.
  1655. *
  1656. * All mappings are created with the attributes defined by the io_attributes
  1657. * argument. The page mapping addresses are described in the io_page_list
  1658. * defined by the given io_page_list_p, which is a pointer to the io_page_list.
  1659. * The first entry in the io_page_list is the address for the first iotte, the
  1660. * 2nd for the 2nd iotte, and so on.
  1661. *
  1662. * Each io_page_address in the io_page_list must be appropriately aligned.
  1663. * #ttes must be greater than zero. For this version of the spec, the tsbnum
  1664. * component of the given tsbid must be zero.
  1665. *
  1666. * Returns the actual number of mappings creates, which may be less than
  1667. * or equal to the argument #ttes. If the function returns a value which
  1668. * is less than the #ttes, the caller may continus to call the function with
  1669. * an updated tsbid, #ttes, io_page_list_p arguments until all pages are
  1670. * mapped.
  1671. *
  1672. * Note: This function does not imply an iotte cache flush. The guest must
  1673. * demap an entry before re-mapping it.
  1674. */
  1675. #define HV_FAST_PCI_IOMMU_MAP 0xb0
  1676. /* pci_iommu_demap()
  1677. * TRAP: HV_FAST_TRAP
  1678. * FUNCTION: HV_FAST_PCI_IOMMU_DEMAP
  1679. * ARG0: devhandle
  1680. * ARG1: tsbid
  1681. * ARG2: #ttes
  1682. * RET0: status
  1683. * RET1: #ttes demapped
  1684. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex
  1685. *
  1686. * Demap and flush IOMMU mappings in the device defined by the given
  1687. * devhandle. Demaps up to #ttes entries in the TSB defined by the tsbnum
  1688. * component of the given tsbid, starting at the TSB index defined by the
  1689. * tsbindex component of the given tsbid.
  1690. *
  1691. * For this version of the spec, the tsbnum of the given tsbid must be zero.
  1692. * #ttes must be greater than zero.
  1693. *
  1694. * Returns the actual number of ttes demapped, which may be less than or equal
  1695. * to the argument #ttes. If #ttes demapped is less than #ttes, the caller
  1696. * may continue to call this function with updated tsbid and #ttes arguments
  1697. * until all pages are demapped.
  1698. *
  1699. * Note: Entries do not have to be mapped to be demapped. A demap of an
  1700. * unmapped page will flush the entry from the tte cache.
  1701. */
  1702. #define HV_FAST_PCI_IOMMU_DEMAP 0xb1
  1703. /* pci_iommu_getmap()
  1704. * TRAP: HV_FAST_TRAP
  1705. * FUNCTION: HV_FAST_PCI_IOMMU_GETMAP
  1706. * ARG0: devhandle
  1707. * ARG1: tsbid
  1708. * RET0: status
  1709. * RET1: io_attributes
  1710. * RET2: real address
  1711. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex
  1712. * ENOMAP Mapping is not valid, no translation exists
  1713. *
  1714. * Read and return the mapping in the device described by the given devhandle
  1715. * and tsbid. If successful, the io_attributes shall be returned in RET1
  1716. * and the page address of the mapping shall be returned in RET2.
  1717. *
  1718. * For this version of the spec, the tsbnum component of the given tsbid
  1719. * must be zero.
  1720. */
  1721. #define HV_FAST_PCI_IOMMU_GETMAP 0xb2
  1722. /* pci_iommu_getbypass()
  1723. * TRAP: HV_FAST_TRAP
  1724. * FUNCTION: HV_FAST_PCI_IOMMU_GETBYPASS
  1725. * ARG0: devhandle
  1726. * ARG1: real address
  1727. * ARG2: io_attributes
  1728. * RET0: status
  1729. * RET1: io_addr
  1730. * ERRORS: EINVAL Invalid devhandle/io_attributes
  1731. * ENORADDR Invalid real address
  1732. * ENOTSUPPORTED Function not supported in this implementation.
  1733. *
  1734. * Create a "special" mapping in the device described by the given devhandle,
  1735. * for the given real address and attributes. Return the IO address in RET1
  1736. * if successful.
  1737. */
  1738. #define HV_FAST_PCI_IOMMU_GETBYPASS 0xb3
  1739. /* pci_config_get()
  1740. * TRAP: HV_FAST_TRAP
  1741. * FUNCTION: HV_FAST_PCI_CONFIG_GET
  1742. * ARG0: devhandle
  1743. * ARG1: pci_device
  1744. * ARG2: pci_config_offset
  1745. * ARG3: size
  1746. * RET0: status
  1747. * RET1: error_flag
  1748. * RET2: data
  1749. * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size
  1750. * EBADALIGN pci_config_offset not size aligned
  1751. * ENOACCESS Access to this offset is not permitted
  1752. *
  1753. * Read PCI configuration space for the adapter described by the given
  1754. * devhandle. Read size (1, 2, or 4) bytes of data from the given
  1755. * pci_device, at pci_config_offset from the beginning of the device's
  1756. * configuration space. If there was no error, RET1 is set to zero and
  1757. * RET2 is set to the data read. Insignificant bits in RET2 are not
  1758. * guarenteed to have any specific value and therefore must be ignored.
  1759. *
  1760. * The data returned in RET2 is size based byte swapped.
  1761. *
  1762. * If an error occurs during the read, set RET1 to a non-zero value. The
  1763. * given pci_config_offset must be 'size' aligned.
  1764. */
  1765. #define HV_FAST_PCI_CONFIG_GET 0xb4
  1766. /* pci_config_put()
  1767. * TRAP: HV_FAST_TRAP
  1768. * FUNCTION: HV_FAST_PCI_CONFIG_PUT
  1769. * ARG0: devhandle
  1770. * ARG1: pci_device
  1771. * ARG2: pci_config_offset
  1772. * ARG3: size
  1773. * ARG4: data
  1774. * RET0: status
  1775. * RET1: error_flag
  1776. * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size
  1777. * EBADALIGN pci_config_offset not size aligned
  1778. * ENOACCESS Access to this offset is not permitted
  1779. *
  1780. * Write PCI configuration space for the adapter described by the given
  1781. * devhandle. Write size (1, 2, or 4) bytes of data in a single operation,
  1782. * at pci_config_offset from the beginning of the device's configuration
  1783. * space. The data argument contains the data to be written to configuration
  1784. * space. Prior to writing, the data is size based byte swapped.
  1785. *
  1786. * If an error occurs during the write access, do not generate an error
  1787. * report, do set RET1 to a non-zero value. Otherwise RET1 is zero.
  1788. * The given pci_config_offset must be 'size' aligned.
  1789. *
  1790. * This function is permitted to read from offset zero in the configuration
  1791. * space described by the given pci_device if necessary to ensure that the
  1792. * write access to config space completes.
  1793. */
  1794. #define HV_FAST_PCI_CONFIG_PUT 0xb5
  1795. /* pci_peek()
  1796. * TRAP: HV_FAST_TRAP
  1797. * FUNCTION: HV_FAST_PCI_PEEK
  1798. * ARG0: devhandle
  1799. * ARG1: real address
  1800. * ARG2: size
  1801. * RET0: status
  1802. * RET1: error_flag
  1803. * RET2: data
  1804. * ERRORS: EINVAL Invalid devhandle or size
  1805. * EBADALIGN Improperly aligned real address
  1806. * ENORADDR Bad real address
  1807. * ENOACCESS Guest access prohibited
  1808. *
  1809. * Attempt to read the IO address given by the given devhandle, real address,
  1810. * and size. Size must be 1, 2, 4, or 8. The read is performed as a single
  1811. * access operation using the given size. If an error occurs when reading
  1812. * from the given location, do not generate an error report, but return a
  1813. * non-zero value in RET1. If the read was successful, return zero in RET1
  1814. * and return the actual data read in RET2. The data returned is size based
  1815. * byte swapped.
  1816. *
  1817. * Non-significant bits in RET2 are not guarenteed to have any specific value
  1818. * and therefore must be ignored. If RET1 is returned as non-zero, the data
  1819. * value is not guarenteed to have any specific value and should be ignored.
  1820. *
  1821. * The caller must have permission to read from the given devhandle, real
  1822. * address, which must be an IO address. The argument real address must be a
  1823. * size aligned address.
  1824. *
  1825. * The hypervisor implementation of this function must block access to any
  1826. * IO address that the guest does not have explicit permission to access.
  1827. */
  1828. #define HV_FAST_PCI_PEEK 0xb6
  1829. /* pci_poke()
  1830. * TRAP: HV_FAST_TRAP
  1831. * FUNCTION: HV_FAST_PCI_POKE
  1832. * ARG0: devhandle
  1833. * ARG1: real address
  1834. * ARG2: size
  1835. * ARG3: data
  1836. * ARG4: pci_device
  1837. * RET0: status
  1838. * RET1: error_flag
  1839. * ERRORS: EINVAL Invalid devhandle, size, or pci_device
  1840. * EBADALIGN Improperly aligned real address
  1841. * ENORADDR Bad real address
  1842. * ENOACCESS Guest access prohibited
  1843. * ENOTSUPPORTED Function is not supported by implementation
  1844. *
  1845. * Attempt to write data to the IO address given by the given devhandle,
  1846. * real address, and size. Size must be 1, 2, 4, or 8. The write is
  1847. * performed as a single access operation using the given size. Prior to
  1848. * writing the data is size based swapped.
  1849. *
  1850. * If an error occurs when writing to the given location, do not generate an
  1851. * error report, but return a non-zero value in RET1. If the write was
  1852. * successful, return zero in RET1.
  1853. *
  1854. * pci_device describes the configuration address of the device being
  1855. * written to. The implementation may safely read from offset 0 with
  1856. * the configuration space of the device described by devhandle and
  1857. * pci_device in order to guarantee that the write portion of the operation
  1858. * completes
  1859. *
  1860. * Any error that occurs due to the read shall be reported using the normal
  1861. * error reporting mechanisms .. the read error is not suppressed.
  1862. *
  1863. * The caller must have permission to write to the given devhandle, real
  1864. * address, which must be an IO address. The argument real address must be a
  1865. * size aligned address. The caller must have permission to read from
  1866. * the given devhandle, pci_device cofiguration space offset 0.
  1867. *
  1868. * The hypervisor implementation of this function must block access to any
  1869. * IO address that the guest does not have explicit permission to access.
  1870. */
  1871. #define HV_FAST_PCI_POKE 0xb7
  1872. /* pci_dma_sync()
  1873. * TRAP: HV_FAST_TRAP
  1874. * FUNCTION: HV_FAST_PCI_DMA_SYNC
  1875. * ARG0: devhandle
  1876. * ARG1: real address
  1877. * ARG2: size
  1878. * ARG3: io_sync_direction
  1879. * RET0: status
  1880. * RET1: #synced
  1881. * ERRORS: EINVAL Invalid devhandle or io_sync_direction
  1882. * ENORADDR Bad real address
  1883. *
  1884. * Synchronize a memory region described by the given real address and size,
  1885. * for the device defined by the given devhandle using the direction(s)
  1886. * defined by the given io_sync_direction. The argument size is the size of
  1887. * the memory region in bytes.
  1888. *
  1889. * Return the actual number of bytes synchronized in the return value #synced,
  1890. * which may be less than or equal to the argument size. If the return
  1891. * value #synced is less than size, the caller must continue to call this
  1892. * function with updated real address and size arguments until the entire
  1893. * memory region is synchronized.
  1894. */
  1895. #define HV_FAST_PCI_DMA_SYNC 0xb8
  1896. /* PCI MSI services. */
  1897. #define HV_MSITYPE_MSI32 0x00
  1898. #define HV_MSITYPE_MSI64 0x01
  1899. #define HV_MSIQSTATE_IDLE 0x00
  1900. #define HV_MSIQSTATE_ERROR 0x01
  1901. #define HV_MSIQ_INVALID 0x00
  1902. #define HV_MSIQ_VALID 0x01
  1903. #define HV_MSISTATE_IDLE 0x00
  1904. #define HV_MSISTATE_DELIVERED 0x01
  1905. #define HV_MSIVALID_INVALID 0x00
  1906. #define HV_MSIVALID_VALID 0x01
  1907. #define HV_PCIE_MSGTYPE_PME_MSG 0x18
  1908. #define HV_PCIE_MSGTYPE_PME_ACK_MSG 0x1b
  1909. #define HV_PCIE_MSGTYPE_CORR_MSG 0x30
  1910. #define HV_PCIE_MSGTYPE_NONFATAL_MSG 0x31
  1911. #define HV_PCIE_MSGTYPE_FATAL_MSG 0x33
  1912. #define HV_MSG_INVALID 0x00
  1913. #define HV_MSG_VALID 0x01
  1914. /* pci_msiq_conf()
  1915. * TRAP: HV_FAST_TRAP
  1916. * FUNCTION: HV_FAST_PCI_MSIQ_CONF
  1917. * ARG0: devhandle
  1918. * ARG1: msiqid
  1919. * ARG2: real address
  1920. * ARG3: number of entries
  1921. * RET0: status
  1922. * ERRORS: EINVAL Invalid devhandle, msiqid or nentries
  1923. * EBADALIGN Improperly aligned real address
  1924. * ENORADDR Bad real address
  1925. *
  1926. * Configure the MSI queue given by the devhandle and msiqid arguments,
  1927. * and to be placed at the given real address and be of the given
  1928. * number of entries. The real address must be aligned exactly to match
  1929. * the queue size. Each queue entry is 64-bytes long, so f.e. a 32 entry
  1930. * queue must be aligned on a 2048 byte real address boundary. The MSI-EQ
  1931. * Head and Tail are initialized so that the MSI-EQ is 'empty'.
  1932. *
  1933. * Implementation Note: Certain implementations have fixed sized queues. In
  1934. * that case, number of entries must contain the correct
  1935. * value.
  1936. */
  1937. #define HV_FAST_PCI_MSIQ_CONF 0xc0
  1938. /* pci_msiq_info()
  1939. * TRAP: HV_FAST_TRAP
  1940. * FUNCTION: HV_FAST_PCI_MSIQ_INFO
  1941. * ARG0: devhandle
  1942. * ARG1: msiqid
  1943. * RET0: status
  1944. * RET1: real address
  1945. * RET2: number of entries
  1946. * ERRORS: EINVAL Invalid devhandle or msiqid
  1947. *
  1948. * Return the configuration information for the MSI queue described
  1949. * by the given devhandle and msiqid. The base address of the queue
  1950. * is returned in ARG1 and the number of entries is returned in ARG2.
  1951. * If the queue is unconfigured, the real address is undefined and the
  1952. * number of entries will be returned as zero.
  1953. */
  1954. #define HV_FAST_PCI_MSIQ_INFO 0xc1
  1955. /* pci_msiq_getvalid()
  1956. * TRAP: HV_FAST_TRAP
  1957. * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID
  1958. * ARG0: devhandle
  1959. * ARG1: msiqid
  1960. * RET0: status
  1961. * RET1: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID)
  1962. * ERRORS: EINVAL Invalid devhandle or msiqid
  1963. *
  1964. * Get the valid state of the MSI-EQ described by the given devhandle and
  1965. * msiqid.
  1966. */
  1967. #define HV_FAST_PCI_MSIQ_GETVALID 0xc2
  1968. /* pci_msiq_setvalid()
  1969. * TRAP: HV_FAST_TRAP
  1970. * FUNCTION: HV_FAST_PCI_MSIQ_SETVALID
  1971. * ARG0: devhandle
  1972. * ARG1: msiqid
  1973. * ARG2: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID)
  1974. * RET0: status
  1975. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqvalid
  1976. * value or MSI EQ is uninitialized
  1977. *
  1978. * Set the valid state of the MSI-EQ described by the given devhandle and
  1979. * msiqid to the given msiqvalid.
  1980. */
  1981. #define HV_FAST_PCI_MSIQ_SETVALID 0xc3
  1982. /* pci_msiq_getstate()
  1983. * TRAP: HV_FAST_TRAP
  1984. * FUNCTION: HV_FAST_PCI_MSIQ_GETSTATE
  1985. * ARG0: devhandle
  1986. * ARG1: msiqid
  1987. * RET0: status
  1988. * RET1: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
  1989. * ERRORS: EINVAL Invalid devhandle or msiqid
  1990. *
  1991. * Get the state of the MSI-EQ described by the given devhandle and
  1992. * msiqid.
  1993. */
  1994. #define HV_FAST_PCI_MSIQ_GETSTATE 0xc4
  1995. /* pci_msiq_getvalid()
  1996. * TRAP: HV_FAST_TRAP
  1997. * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID
  1998. * ARG0: devhandle
  1999. * ARG1: msiqid
  2000. * ARG2: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
  2001. * RET0: status
  2002. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqstate
  2003. * value or MSI EQ is uninitialized
  2004. *
  2005. * Set the state of the MSI-EQ described by the given devhandle and
  2006. * msiqid to the given msiqvalid.
  2007. */
  2008. #define HV_FAST_PCI_MSIQ_SETSTATE 0xc5
  2009. /* pci_msiq_gethead()
  2010. * TRAP: HV_FAST_TRAP
  2011. * FUNCTION: HV_FAST_PCI_MSIQ_GETHEAD
  2012. * ARG0: devhandle
  2013. * ARG1: msiqid
  2014. * RET0: status
  2015. * RET1: msiqhead
  2016. * ERRORS: EINVAL Invalid devhandle or msiqid
  2017. *
  2018. * Get the current MSI EQ queue head for the MSI-EQ described by the
  2019. * given devhandle and msiqid.
  2020. */
  2021. #define HV_FAST_PCI_MSIQ_GETHEAD 0xc6
  2022. /* pci_msiq_sethead()
  2023. * TRAP: HV_FAST_TRAP
  2024. * FUNCTION: HV_FAST_PCI_MSIQ_SETHEAD
  2025. * ARG0: devhandle
  2026. * ARG1: msiqid
  2027. * ARG2: msiqhead
  2028. * RET0: status
  2029. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqhead,
  2030. * or MSI EQ is uninitialized
  2031. *
  2032. * Set the current MSI EQ queue head for the MSI-EQ described by the
  2033. * given devhandle and msiqid.
  2034. */
  2035. #define HV_FAST_PCI_MSIQ_SETHEAD 0xc7
  2036. /* pci_msiq_gettail()
  2037. * TRAP: HV_FAST_TRAP
  2038. * FUNCTION: HV_FAST_PCI_MSIQ_GETTAIL
  2039. * ARG0: devhandle
  2040. * ARG1: msiqid
  2041. * RET0: status
  2042. * RET1: msiqtail
  2043. * ERRORS: EINVAL Invalid devhandle or msiqid
  2044. *
  2045. * Get the current MSI EQ queue tail for the MSI-EQ described by the
  2046. * given devhandle and msiqid.
  2047. */
  2048. #define HV_FAST_PCI_MSIQ_GETTAIL 0xc8
  2049. /* pci_msi_getvalid()
  2050. * TRAP: HV_FAST_TRAP
  2051. * FUNCTION: HV_FAST_PCI_MSI_GETVALID
  2052. * ARG0: devhandle
  2053. * ARG1: msinum
  2054. * RET0: status
  2055. * RET1: msivalidstate
  2056. * ERRORS: EINVAL Invalid devhandle or msinum
  2057. *
  2058. * Get the current valid/enabled state for the MSI defined by the
  2059. * given devhandle and msinum.
  2060. */
  2061. #define HV_FAST_PCI_MSI_GETVALID 0xc9
  2062. /* pci_msi_setvalid()
  2063. * TRAP: HV_FAST_TRAP
  2064. * FUNCTION: HV_FAST_PCI_MSI_SETVALID
  2065. * ARG0: devhandle
  2066. * ARG1: msinum
  2067. * ARG2: msivalidstate
  2068. * RET0: status
  2069. * ERRORS: EINVAL Invalid devhandle or msinum or msivalidstate
  2070. *
  2071. * Set the current valid/enabled state for the MSI defined by the
  2072. * given devhandle and msinum.
  2073. */
  2074. #define HV_FAST_PCI_MSI_SETVALID 0xca
  2075. /* pci_msi_getmsiq()
  2076. * TRAP: HV_FAST_TRAP
  2077. * FUNCTION: HV_FAST_PCI_MSI_GETMSIQ
  2078. * ARG0: devhandle
  2079. * ARG1: msinum
  2080. * RET0: status
  2081. * RET1: msiqid
  2082. * ERRORS: EINVAL Invalid devhandle or msinum or MSI is unbound
  2083. *
  2084. * Get the MSI EQ that the MSI defined by the given devhandle and
  2085. * msinum is bound to.
  2086. */
  2087. #define HV_FAST_PCI_MSI_GETMSIQ 0xcb
  2088. /* pci_msi_setmsiq()
  2089. * TRAP: HV_FAST_TRAP
  2090. * FUNCTION: HV_FAST_PCI_MSI_SETMSIQ
  2091. * ARG0: devhandle
  2092. * ARG1: msinum
  2093. * ARG2: msitype
  2094. * ARG3: msiqid
  2095. * RET0: status
  2096. * ERRORS: EINVAL Invalid devhandle or msinum or msiqid
  2097. *
  2098. * Set the MSI EQ that the MSI defined by the given devhandle and
  2099. * msinum is bound to.
  2100. */
  2101. #define HV_FAST_PCI_MSI_SETMSIQ 0xcc
  2102. /* pci_msi_getstate()
  2103. * TRAP: HV_FAST_TRAP
  2104. * FUNCTION: HV_FAST_PCI_MSI_GETSTATE
  2105. * ARG0: devhandle
  2106. * ARG1: msinum
  2107. * RET0: status
  2108. * RET1: msistate
  2109. * ERRORS: EINVAL Invalid devhandle or msinum
  2110. *
  2111. * Get the state of the MSI defined by the given devhandle and msinum.
  2112. * If not initialized, return HV_MSISTATE_IDLE.
  2113. */
  2114. #define HV_FAST_PCI_MSI_GETSTATE 0xcd
  2115. /* pci_msi_setstate()
  2116. * TRAP: HV_FAST_TRAP
  2117. * FUNCTION: HV_FAST_PCI_MSI_SETSTATE
  2118. * ARG0: devhandle
  2119. * ARG1: msinum
  2120. * ARG2: msistate
  2121. * RET0: status
  2122. * ERRORS: EINVAL Invalid devhandle or msinum or msistate
  2123. *
  2124. * Set the state of the MSI defined by the given devhandle and msinum.
  2125. */
  2126. #define HV_FAST_PCI_MSI_SETSTATE 0xce
  2127. /* pci_msg_getmsiq()
  2128. * TRAP: HV_FAST_TRAP
  2129. * FUNCTION: HV_FAST_PCI_MSG_GETMSIQ
  2130. * ARG0: devhandle
  2131. * ARG1: msgtype
  2132. * RET0: status
  2133. * RET1: msiqid
  2134. * ERRORS: EINVAL Invalid devhandle or msgtype
  2135. *
  2136. * Get the MSI EQ of the MSG defined by the given devhandle and msgtype.
  2137. */
  2138. #define HV_FAST_PCI_MSG_GETMSIQ 0xd0
  2139. /* pci_msg_setmsiq()
  2140. * TRAP: HV_FAST_TRAP
  2141. * FUNCTION: HV_FAST_PCI_MSG_SETMSIQ
  2142. * ARG0: devhandle
  2143. * ARG1: msgtype
  2144. * ARG2: msiqid
  2145. * RET0: status
  2146. * ERRORS: EINVAL Invalid devhandle, msgtype, or msiqid
  2147. *
  2148. * Set the MSI EQ of the MSG defined by the given devhandle and msgtype.
  2149. */
  2150. #define HV_FAST_PCI_MSG_SETMSIQ 0xd1
  2151. /* pci_msg_getvalid()
  2152. * TRAP: HV_FAST_TRAP
  2153. * FUNCTION: HV_FAST_PCI_MSG_GETVALID
  2154. * ARG0: devhandle
  2155. * ARG1: msgtype
  2156. * RET0: status
  2157. * RET1: msgvalidstate
  2158. * ERRORS: EINVAL Invalid devhandle or msgtype
  2159. *
  2160. * Get the valid/enabled state of the MSG defined by the given
  2161. * devhandle and msgtype.
  2162. */
  2163. #define HV_FAST_PCI_MSG_GETVALID 0xd2
  2164. /* pci_msg_setvalid()
  2165. * TRAP: HV_FAST_TRAP
  2166. * FUNCTION: HV_FAST_PCI_MSG_SETVALID
  2167. * ARG0: devhandle
  2168. * ARG1: msgtype
  2169. * ARG2: msgvalidstate
  2170. * RET0: status
  2171. * ERRORS: EINVAL Invalid devhandle or msgtype or msgvalidstate
  2172. *
  2173. * Set the valid/enabled state of the MSG defined by the given
  2174. * devhandle and msgtype.
  2175. */
  2176. #define HV_FAST_PCI_MSG_SETVALID 0xd3
  2177. /* Logical Domain Channel services. */
  2178. #define LDC_CHANNEL_DOWN 0
  2179. #define LDC_CHANNEL_UP 1
  2180. #define LDC_CHANNEL_RESETTING 2
  2181. /* ldc_tx_qconf()
  2182. * TRAP: HV_FAST_TRAP
  2183. * FUNCTION: HV_FAST_LDC_TX_QCONF
  2184. * ARG0: channel ID
  2185. * ARG1: real address base of queue
  2186. * ARG2: num entries in queue
  2187. * RET0: status
  2188. *
  2189. * Configure transmit queue for the LDC endpoint specified by the
  2190. * given channel ID, to be placed at the given real address, and
  2191. * be of the given num entries. Num entries must be a power of two.
  2192. * The real address base of the queue must be aligned on the queue
  2193. * size. Each queue entry is 64-bytes, so for example, a 32 entry
  2194. * queue must be aligned on a 2048 byte real address boundary.
  2195. *
  2196. * Upon configuration of a valid transmit queue the head and tail
  2197. * pointers are set to a hypervisor specific identical value indicating
  2198. * that the queue initially is empty.
  2199. *
  2200. * The endpoint's transmit queue is un-configured if num entries is zero.
  2201. *
  2202. * The maximum number of entries for each queue for a specific cpu may be
  2203. * determined from the machine description. A transmit queue may be
  2204. * specified even in the event that the LDC is down (peer endpoint has no
  2205. * receive queue specified). Transmission will begin as soon as the peer
  2206. * endpoint defines a receive queue.
  2207. *
  2208. * It is recommended that a guest wait for a transmit queue to empty prior
  2209. * to reconfiguring it, or un-configuring it. Re or un-configuring of a
  2210. * non-empty transmit queue behaves exactly as defined above, however it
  2211. * is undefined as to how many of the pending entries in the original queue
  2212. * will be delivered prior to the re-configuration taking effect.
  2213. * Furthermore, as the queue configuration causes a reset of the head and
  2214. * tail pointers there is no way for a guest to determine how many entries
  2215. * have been sent after the configuration operation.
  2216. */
  2217. #define HV_FAST_LDC_TX_QCONF 0xe0
  2218. /* ldc_tx_qinfo()
  2219. * TRAP: HV_FAST_TRAP
  2220. * FUNCTION: HV_FAST_LDC_TX_QINFO
  2221. * ARG0: channel ID
  2222. * RET0: status
  2223. * RET1: real address base of queue
  2224. * RET2: num entries in queue
  2225. *
  2226. * Return the configuration info for the transmit queue of LDC endpoint
  2227. * defined by the given channel ID. The real address is the currently
  2228. * defined real address base of the defined queue, and num entries is the
  2229. * size of the queue in terms of number of entries.
  2230. *
  2231. * If the specified channel ID is a valid endpoint number, but no transmit
  2232. * queue has been defined this service will return success, but with num
  2233. * entries set to zero and the real address will have an undefined value.
  2234. */
  2235. #define HV_FAST_LDC_TX_QINFO 0xe1
  2236. /* ldc_tx_get_state()
  2237. * TRAP: HV_FAST_TRAP
  2238. * FUNCTION: HV_FAST_LDC_TX_GET_STATE
  2239. * ARG0: channel ID
  2240. * RET0: status
  2241. * RET1: head offset
  2242. * RET2: tail offset
  2243. * RET3: channel state
  2244. *
  2245. * Return the transmit state, and the head and tail queue pointers, for
  2246. * the transmit queue of the LDC endpoint defined by the given channel ID.
  2247. * The head and tail values are the byte offset of the head and tail
  2248. * positions of the transmit queue for the specified endpoint.
  2249. */
  2250. #define HV_FAST_LDC_TX_GET_STATE 0xe2
  2251. /* ldc_tx_set_qtail()
  2252. * TRAP: HV_FAST_TRAP
  2253. * FUNCTION: HV_FAST_LDC_TX_SET_QTAIL
  2254. * ARG0: channel ID
  2255. * ARG1: tail offset
  2256. * RET0: status
  2257. *
  2258. * Update the tail pointer for the transmit queue associated with the LDC
  2259. * endpoint defined by the given channel ID. The tail offset specified
  2260. * must be aligned on a 64 byte boundary, and calculated so as to increase
  2261. * the number of pending entries on the transmit queue. Any attempt to
  2262. * decrease the number of pending transmit queue entires is considered
  2263. * an invalid tail offset and will result in an EINVAL error.
  2264. *
  2265. * Since the tail of the transmit queue may not be moved backwards, the
  2266. * transmit queue may be flushed by configuring a new transmit queue,
  2267. * whereupon the hypervisor will configure the initial transmit head and
  2268. * tail pointers to be equal.
  2269. */
  2270. #define HV_FAST_LDC_TX_SET_QTAIL 0xe3
  2271. /* ldc_rx_qconf()
  2272. * TRAP: HV_FAST_TRAP
  2273. * FUNCTION: HV_FAST_LDC_RX_QCONF
  2274. * ARG0: channel ID
  2275. * ARG1: real address base of queue
  2276. * ARG2: num entries in queue
  2277. * RET0: status
  2278. *
  2279. * Configure receive queue for the LDC endpoint specified by the
  2280. * given channel ID, to be placed at the given real address, and
  2281. * be of the given num entries. Num entries must be a power of two.
  2282. * The real address base of the queue must be aligned on the queue
  2283. * size. Each queue entry is 64-bytes, so for example, a 32 entry
  2284. * queue must be aligned on a 2048 byte real address boundary.
  2285. *
  2286. * The endpoint's transmit queue is un-configured if num entries is zero.
  2287. *
  2288. * If a valid receive queue is specified for a local endpoint the LDC is
  2289. * in the up state for the purpose of transmission to this endpoint.
  2290. *
  2291. * The maximum number of entries for each queue for a specific cpu may be
  2292. * determined from the machine description.
  2293. *
  2294. * As receive queue configuration causes a reset of the queue's head and
  2295. * tail pointers there is no way for a gues to determine how many entries
  2296. * have been received between a preceeding ldc_get_rx_state() API call
  2297. * and the completion of the configuration operation. It should be noted
  2298. * that datagram delivery is not guarenteed via domain channels anyway,
  2299. * and therefore any higher protocol should be resilient to datagram
  2300. * loss if necessary. However, to overcome this specific race potential
  2301. * it is recommended, for example, that a higher level protocol be employed
  2302. * to ensure either retransmission, or ensure that no datagrams are pending
  2303. * on the peer endpoint's transmit queue prior to the configuration process.
  2304. */
  2305. #define HV_FAST_LDC_RX_QCONF 0xe4
  2306. /* ldc_rx_qinfo()
  2307. * TRAP: HV_FAST_TRAP
  2308. * FUNCTION: HV_FAST_LDC_RX_QINFO
  2309. * ARG0: channel ID
  2310. * RET0: status
  2311. * RET1: real address base of queue
  2312. * RET2: num entries in queue
  2313. *
  2314. * Return the configuration info for the receive queue of LDC endpoint
  2315. * defined by the given channel ID. The real address is the currently
  2316. * defined real address base of the defined queue, and num entries is the
  2317. * size of the queue in terms of number of entries.
  2318. *
  2319. * If the specified channel ID is a valid endpoint number, but no receive
  2320. * queue has been defined this service will return success, but with num
  2321. * entries set to zero and the real address will have an undefined value.
  2322. */
  2323. #define HV_FAST_LDC_RX_QINFO 0xe5
  2324. /* ldc_rx_get_state()
  2325. * TRAP: HV_FAST_TRAP
  2326. * FUNCTION: HV_FAST_LDC_RX_GET_STATE
  2327. * ARG0: channel ID
  2328. * RET0: status
  2329. * RET1: head offset
  2330. * RET2: tail offset
  2331. * RET3: channel state
  2332. *
  2333. * Return the receive state, and the head and tail queue pointers, for
  2334. * the receive queue of the LDC endpoint defined by the given channel ID.
  2335. * The head and tail values are the byte offset of the head and tail
  2336. * positions of the receive queue for the specified endpoint.
  2337. */
  2338. #define HV_FAST_LDC_RX_GET_STATE 0xe6
  2339. /* ldc_rx_set_qhead()
  2340. * TRAP: HV_FAST_TRAP
  2341. * FUNCTION: HV_FAST_LDC_RX_SET_QHEAD
  2342. * ARG0: channel ID
  2343. * ARG1: head offset
  2344. * RET0: status
  2345. *
  2346. * Update the head pointer for the receive queue associated with the LDC
  2347. * endpoint defined by the given channel ID. The head offset specified
  2348. * must be aligned on a 64 byte boundary, and calculated so as to decrease
  2349. * the number of pending entries on the receive queue. Any attempt to
  2350. * increase the number of pending receive queue entires is considered
  2351. * an invalid head offset and will result in an EINVAL error.
  2352. *
  2353. * The receive queue may be flushed by setting the head offset equal
  2354. * to the current tail offset.
  2355. */
  2356. #define HV_FAST_LDC_RX_SET_QHEAD 0xe7
  2357. /* LDC Map Table Entry. Each slot is defined by a translation table
  2358. * entry, as specified by the LDC_MTE_* bits below, and a 64-bit
  2359. * hypervisor invalidation cookie.
  2360. */
  2361. #define LDC_MTE_PADDR 0x0fffffffffffe000 /* pa[55:13] */
  2362. #define LDC_MTE_COPY_W 0x0000000000000400 /* copy write access */
  2363. #define LDC_MTE_COPY_R 0x0000000000000200 /* copy read access */
  2364. #define LDC_MTE_IOMMU_W 0x0000000000000100 /* IOMMU write access */
  2365. #define LDC_MTE_IOMMU_R 0x0000000000000080 /* IOMMU read access */
  2366. #define LDC_MTE_EXEC 0x0000000000000040 /* execute */
  2367. #define LDC_MTE_WRITE 0x0000000000000020 /* read */
  2368. #define LDC_MTE_READ 0x0000000000000010 /* write */
  2369. #define LDC_MTE_SZALL 0x000000000000000f /* page size bits */
  2370. #define LDC_MTE_SZ16GB 0x0000000000000007 /* 16GB page */
  2371. #define LDC_MTE_SZ2GB 0x0000000000000006 /* 2GB page */
  2372. #define LDC_MTE_SZ256MB 0x0000000000000005 /* 256MB page */
  2373. #define LDC_MTE_SZ32MB 0x0000000000000004 /* 32MB page */
  2374. #define LDC_MTE_SZ4MB 0x0000000000000003 /* 4MB page */
  2375. #define LDC_MTE_SZ512K 0x0000000000000002 /* 512K page */
  2376. #define LDC_MTE_SZ64K 0x0000000000000001 /* 64K page */
  2377. #define LDC_MTE_SZ8K 0x0000000000000000 /* 8K page */
  2378. #ifndef __ASSEMBLY__
  2379. struct ldc_mtable_entry {
  2380. unsigned long mte;
  2381. unsigned long cookie;
  2382. };
  2383. #endif
  2384. /* ldc_set_map_table()
  2385. * TRAP: HV_FAST_TRAP
  2386. * FUNCTION: HV_FAST_LDC_SET_MAP_TABLE
  2387. * ARG0: channel ID
  2388. * ARG1: table real address
  2389. * ARG2: num entries
  2390. * RET0: status
  2391. *
  2392. * Register the MTE table at the given table real address, with the
  2393. * specified num entries, for the LDC indicated by the given channel
  2394. * ID.
  2395. */
  2396. #define HV_FAST_LDC_SET_MAP_TABLE 0xea
  2397. /* ldc_get_map_table()
  2398. * TRAP: HV_FAST_TRAP
  2399. * FUNCTION: HV_FAST_LDC_GET_MAP_TABLE
  2400. * ARG0: channel ID
  2401. * RET0: status
  2402. * RET1: table real address
  2403. * RET2: num entries
  2404. *
  2405. * Return the configuration of the current mapping table registered
  2406. * for the given channel ID.
  2407. */
  2408. #define HV_FAST_LDC_GET_MAP_TABLE 0xeb
  2409. #define LDC_COPY_IN 0
  2410. #define LDC_COPY_OUT 1
  2411. /* ldc_copy()
  2412. * TRAP: HV_FAST_TRAP
  2413. * FUNCTION: HV_FAST_LDC_COPY
  2414. * ARG0: channel ID
  2415. * ARG1: LDC_COPY_* direction code
  2416. * ARG2: target real address
  2417. * ARG3: local real address
  2418. * ARG4: length in bytes
  2419. * RET0: status
  2420. * RET1: actual length in bytes
  2421. */
  2422. #define HV_FAST_LDC_COPY 0xec
  2423. #define LDC_MEM_READ 1
  2424. #define LDC_MEM_WRITE 2
  2425. #define LDC_MEM_EXEC 4
  2426. /* ldc_mapin()
  2427. * TRAP: HV_FAST_TRAP
  2428. * FUNCTION: HV_FAST_LDC_MAPIN
  2429. * ARG0: channel ID
  2430. * ARG1: cookie
  2431. * RET0: status
  2432. * RET1: real address
  2433. * RET2: LDC_MEM_* permissions
  2434. */
  2435. #define HV_FAST_LDC_MAPIN 0xed
  2436. /* ldc_unmap()
  2437. * TRAP: HV_FAST_TRAP
  2438. * FUNCTION: HV_FAST_LDC_UNMAP
  2439. * ARG0: real address
  2440. * RET0: status
  2441. */
  2442. #define HV_FAST_LDC_UNMAP 0xee
  2443. /* ldc_revoke()
  2444. * TRAP: HV_FAST_TRAP
  2445. * FUNCTION: HV_FAST_LDC_REVOKE
  2446. * ARG0: channel ID
  2447. * ARG1: cookie
  2448. * ARG2: ldc_mtable_entry cookie
  2449. * RET0: status
  2450. */
  2451. #define HV_FAST_LDC_REVOKE 0xef
  2452. #ifndef __ASSEMBLY__
  2453. extern unsigned long sun4v_ldc_tx_qconf(unsigned long channel,
  2454. unsigned long ra,
  2455. unsigned long num_entries);
  2456. extern unsigned long sun4v_ldc_tx_qinfo(unsigned long channel,
  2457. unsigned long *ra,
  2458. unsigned long *num_entries);
  2459. extern unsigned long sun4v_ldc_tx_get_state(unsigned long channel,
  2460. unsigned long *head_off,
  2461. unsigned long *tail_off,
  2462. unsigned long *chan_state);
  2463. extern unsigned long sun4v_ldc_tx_set_qtail(unsigned long channel,
  2464. unsigned long tail_off);
  2465. extern unsigned long sun4v_ldc_rx_qconf(unsigned long channel,
  2466. unsigned long ra,
  2467. unsigned long num_entries);
  2468. extern unsigned long sun4v_ldc_rx_qinfo(unsigned long channel,
  2469. unsigned long *ra,
  2470. unsigned long *num_entries);
  2471. extern unsigned long sun4v_ldc_rx_get_state(unsigned long channel,
  2472. unsigned long *head_off,
  2473. unsigned long *tail_off,
  2474. unsigned long *chan_state);
  2475. extern unsigned long sun4v_ldc_rx_set_qhead(unsigned long channel,
  2476. unsigned long head_off);
  2477. extern unsigned long sun4v_ldc_set_map_table(unsigned long channel,
  2478. unsigned long ra,
  2479. unsigned long num_entries);
  2480. extern unsigned long sun4v_ldc_get_map_table(unsigned long channel,
  2481. unsigned long *ra,
  2482. unsigned long *num_entries);
  2483. extern unsigned long sun4v_ldc_copy(unsigned long channel,
  2484. unsigned long dir_code,
  2485. unsigned long tgt_raddr,
  2486. unsigned long lcl_raddr,
  2487. unsigned long len,
  2488. unsigned long *actual_len);
  2489. extern unsigned long sun4v_ldc_mapin(unsigned long channel,
  2490. unsigned long cookie,
  2491. unsigned long *ra,
  2492. unsigned long *perm);
  2493. extern unsigned long sun4v_ldc_unmap(unsigned long ra);
  2494. extern unsigned long sun4v_ldc_revoke(unsigned long channel,
  2495. unsigned long cookie,
  2496. unsigned long mte_cookie);
  2497. #endif
  2498. /* Performance counter services. */
  2499. #define HV_PERF_JBUS_PERF_CTRL_REG 0x00
  2500. #define HV_PERF_JBUS_PERF_CNT_REG 0x01
  2501. #define HV_PERF_DRAM_PERF_CTRL_REG_0 0x02
  2502. #define HV_PERF_DRAM_PERF_CNT_REG_0 0x03
  2503. #define HV_PERF_DRAM_PERF_CTRL_REG_1 0x04
  2504. #define HV_PERF_DRAM_PERF_CNT_REG_1 0x05
  2505. #define HV_PERF_DRAM_PERF_CTRL_REG_2 0x06
  2506. #define HV_PERF_DRAM_PERF_CNT_REG_2 0x07
  2507. #define HV_PERF_DRAM_PERF_CTRL_REG_3 0x08
  2508. #define HV_PERF_DRAM_PERF_CNT_REG_3 0x09
  2509. /* get_perfreg()
  2510. * TRAP: HV_FAST_TRAP
  2511. * FUNCTION: HV_FAST_GET_PERFREG
  2512. * ARG0: performance reg number
  2513. * RET0: status
  2514. * RET1: performance reg value
  2515. * ERRORS: EINVAL Invalid performance register number
  2516. * ENOACCESS No access allowed to performance counters
  2517. *
  2518. * Read the value of the given DRAM/JBUS performance counter/control register.
  2519. */
  2520. #define HV_FAST_GET_PERFREG 0x100
  2521. /* set_perfreg()
  2522. * TRAP: HV_FAST_TRAP
  2523. * FUNCTION: HV_FAST_SET_PERFREG
  2524. * ARG0: performance reg number
  2525. * ARG1: performance reg value
  2526. * RET0: status
  2527. * ERRORS: EINVAL Invalid performance register number
  2528. * ENOACCESS No access allowed to performance counters
  2529. *
  2530. * Write the given performance reg value to the given DRAM/JBUS
  2531. * performance counter/control register.
  2532. */
  2533. #define HV_FAST_SET_PERFREG 0x101
  2534. /* MMU statistics services.
  2535. *
  2536. * The hypervisor maintains MMU statistics and privileged code provides
  2537. * a buffer where these statistics can be collected. It is continually
  2538. * updated once configured. The layout is as follows:
  2539. */
  2540. #ifndef __ASSEMBLY__
  2541. struct hv_mmu_statistics {
  2542. unsigned long immu_tsb_hits_ctx0_8k_tte;
  2543. unsigned long immu_tsb_ticks_ctx0_8k_tte;
  2544. unsigned long immu_tsb_hits_ctx0_64k_tte;
  2545. unsigned long immu_tsb_ticks_ctx0_64k_tte;
  2546. unsigned long __reserved1[2];
  2547. unsigned long immu_tsb_hits_ctx0_4mb_tte;
  2548. unsigned long immu_tsb_ticks_ctx0_4mb_tte;
  2549. unsigned long __reserved2[2];
  2550. unsigned long immu_tsb_hits_ctx0_256mb_tte;
  2551. unsigned long immu_tsb_ticks_ctx0_256mb_tte;
  2552. unsigned long __reserved3[4];
  2553. unsigned long immu_tsb_hits_ctxnon0_8k_tte;
  2554. unsigned long immu_tsb_ticks_ctxnon0_8k_tte;
  2555. unsigned long immu_tsb_hits_ctxnon0_64k_tte;
  2556. unsigned long immu_tsb_ticks_ctxnon0_64k_tte;
  2557. unsigned long __reserved4[2];
  2558. unsigned long immu_tsb_hits_ctxnon0_4mb_tte;
  2559. unsigned long immu_tsb_ticks_ctxnon0_4mb_tte;
  2560. unsigned long __reserved5[2];
  2561. unsigned long immu_tsb_hits_ctxnon0_256mb_tte;
  2562. unsigned long immu_tsb_ticks_ctxnon0_256mb_tte;
  2563. unsigned long __reserved6[4];
  2564. unsigned long dmmu_tsb_hits_ctx0_8k_tte;
  2565. unsigned long dmmu_tsb_ticks_ctx0_8k_tte;
  2566. unsigned long dmmu_tsb_hits_ctx0_64k_tte;
  2567. unsigned long dmmu_tsb_ticks_ctx0_64k_tte;
  2568. unsigned long __reserved7[2];
  2569. unsigned long dmmu_tsb_hits_ctx0_4mb_tte;
  2570. unsigned long dmmu_tsb_ticks_ctx0_4mb_tte;
  2571. unsigned long __reserved8[2];
  2572. unsigned long dmmu_tsb_hits_ctx0_256mb_tte;
  2573. unsigned long dmmu_tsb_ticks_ctx0_256mb_tte;
  2574. unsigned long __reserved9[4];
  2575. unsigned long dmmu_tsb_hits_ctxnon0_8k_tte;
  2576. unsigned long dmmu_tsb_ticks_ctxnon0_8k_tte;
  2577. unsigned long dmmu_tsb_hits_ctxnon0_64k_tte;
  2578. unsigned long dmmu_tsb_ticks_ctxnon0_64k_tte;
  2579. unsigned long __reserved10[2];
  2580. unsigned long dmmu_tsb_hits_ctxnon0_4mb_tte;
  2581. unsigned long dmmu_tsb_ticks_ctxnon0_4mb_tte;
  2582. unsigned long __reserved11[2];
  2583. unsigned long dmmu_tsb_hits_ctxnon0_256mb_tte;
  2584. unsigned long dmmu_tsb_ticks_ctxnon0_256mb_tte;
  2585. unsigned long __reserved12[4];
  2586. };
  2587. #endif
  2588. /* mmustat_conf()
  2589. * TRAP: HV_FAST_TRAP
  2590. * FUNCTION: HV_FAST_MMUSTAT_CONF
  2591. * ARG0: real address
  2592. * RET0: status
  2593. * RET1: real address
  2594. * ERRORS: ENORADDR Invalid real address
  2595. * EBADALIGN Real address not aligned on 64-byte boundary
  2596. * EBADTRAP API not supported on this processor
  2597. *
  2598. * Enable MMU statistic gathering using the buffer at the given real
  2599. * address on the current virtual CPU. The new buffer real address
  2600. * is given in ARG1, and the previously specified buffer real address
  2601. * is returned in RET1, or is returned as zero for the first invocation.
  2602. *
  2603. * If the passed in real address argument is zero, this will disable
  2604. * MMU statistic collection on the current virtual CPU. If an error is
  2605. * returned then no statistics are collected.
  2606. *
  2607. * The buffer contents should be initialized to all zeros before being
  2608. * given to the hypervisor or else the statistics will be meaningless.
  2609. */
  2610. #define HV_FAST_MMUSTAT_CONF 0x102
  2611. /* mmustat_info()
  2612. * TRAP: HV_FAST_TRAP
  2613. * FUNCTION: HV_FAST_MMUSTAT_INFO
  2614. * RET0: status
  2615. * RET1: real address
  2616. * ERRORS: EBADTRAP API not supported on this processor
  2617. *
  2618. * Return the current state and real address of the currently configured
  2619. * MMU statistics buffer on the current virtual CPU.
  2620. */
  2621. #define HV_FAST_MMUSTAT_INFO 0x103
  2622. #ifndef __ASSEMBLY__
  2623. extern unsigned long sun4v_mmustat_conf(unsigned long ra, unsigned long *orig_ra);
  2624. extern unsigned long sun4v_mmustat_info(unsigned long *ra);
  2625. #endif
  2626. /* NCS crypto services */
  2627. /* ncs_request() sub-function numbers */
  2628. #define HV_NCS_QCONF 0x01
  2629. #define HV_NCS_QTAIL_UPDATE 0x02
  2630. #ifndef __ASSEMBLY__
  2631. struct hv_ncs_queue_entry {
  2632. /* MAU Control Register */
  2633. unsigned long mau_control;
  2634. #define MAU_CONTROL_INV_PARITY 0x0000000000002000
  2635. #define MAU_CONTROL_STRAND 0x0000000000001800
  2636. #define MAU_CONTROL_BUSY 0x0000000000000400
  2637. #define MAU_CONTROL_INT 0x0000000000000200
  2638. #define MAU_CONTROL_OP 0x00000000000001c0
  2639. #define MAU_CONTROL_OP_SHIFT 6
  2640. #define MAU_OP_LOAD_MA_MEMORY 0x0
  2641. #define MAU_OP_STORE_MA_MEMORY 0x1
  2642. #define MAU_OP_MODULAR_MULT 0x2
  2643. #define MAU_OP_MODULAR_REDUCE 0x3
  2644. #define MAU_OP_MODULAR_EXP_LOOP 0x4
  2645. #define MAU_CONTROL_LEN 0x000000000000003f
  2646. #define MAU_CONTROL_LEN_SHIFT 0
  2647. /* Real address of bytes to load or store bytes
  2648. * into/out-of the MAU.
  2649. */
  2650. unsigned long mau_mpa;
  2651. /* Modular Arithmetic MA Offset Register. */
  2652. unsigned long mau_ma;
  2653. /* Modular Arithmetic N Prime Register. */
  2654. unsigned long mau_np;
  2655. };
  2656. struct hv_ncs_qconf_arg {
  2657. unsigned long mid; /* MAU ID, 1 per core on Niagara */
  2658. unsigned long base; /* Real address base of queue */
  2659. unsigned long end; /* Real address end of queue */
  2660. unsigned long num_ents; /* Number of entries in queue */
  2661. };
  2662. struct hv_ncs_qtail_update_arg {
  2663. unsigned long mid; /* MAU ID, 1 per core on Niagara */
  2664. unsigned long tail; /* New tail index to use */
  2665. unsigned long syncflag; /* only SYNCFLAG_SYNC is implemented */
  2666. #define HV_NCS_SYNCFLAG_SYNC 0x00
  2667. #define HV_NCS_SYNCFLAG_ASYNC 0x01
  2668. };
  2669. #endif
  2670. /* ncs_request()
  2671. * TRAP: HV_FAST_TRAP
  2672. * FUNCTION: HV_FAST_NCS_REQUEST
  2673. * ARG0: NCS sub-function
  2674. * ARG1: sub-function argument real address
  2675. * ARG2: size in bytes of sub-function argument
  2676. * RET0: status
  2677. *
  2678. * The MAU chip of the Niagara processor is not directly accessible
  2679. * to privileged code, instead it is programmed indirectly via this
  2680. * hypervisor API.
  2681. *
  2682. * The interfaces defines a queue of MAU operations to perform.
  2683. * Privileged code registers a queue with the hypervisor by invoking
  2684. * this HVAPI with the HV_NCS_QCONF sub-function, which defines the
  2685. * base, end, and number of entries of the queue. Each queue entry
  2686. * contains a MAU register struct block.
  2687. *
  2688. * The privileged code then proceeds to add entries to the queue and
  2689. * then invoke the HV_NCS_QTAIL_UPDATE sub-function. Since only
  2690. * synchronous operations are supported by the current hypervisor,
  2691. * HV_NCS_QTAIL_UPDATE will run all the pending queue entries to
  2692. * completion and return HV_EOK, or return an error code.
  2693. *
  2694. * The real address of the sub-function argument must be aligned on at
  2695. * least an 8-byte boundary.
  2696. *
  2697. * The tail argument of HV_NCS_QTAIL_UPDATE is an index, not a byte
  2698. * offset, into the queue and must be less than or equal the 'num_ents'
  2699. * argument given in the HV_NCS_QCONF call.
  2700. */
  2701. #define HV_FAST_NCS_REQUEST 0x110
  2702. #ifndef __ASSEMBLY__
  2703. extern unsigned long sun4v_ncs_request(unsigned long request,
  2704. unsigned long arg_ra,
  2705. unsigned long arg_size);
  2706. #endif
  2707. #define HV_FAST_FIRE_GET_PERFREG 0x120
  2708. #define HV_FAST_FIRE_SET_PERFREG 0x121
  2709. /* Function numbers for HV_CORE_TRAP. */
  2710. #define HV_CORE_SET_VER 0x00
  2711. #define HV_CORE_PUTCHAR 0x01
  2712. #define HV_CORE_EXIT 0x02
  2713. #define HV_CORE_GET_VER 0x03
  2714. /* Hypervisor API groups for use with HV_CORE_SET_VER and
  2715. * HV_CORE_GET_VER.
  2716. */
  2717. #define HV_GRP_SUN4V 0x0000
  2718. #define HV_GRP_CORE 0x0001
  2719. #define HV_GRP_INTR 0x0002
  2720. #define HV_GRP_SOFT_STATE 0x0003
  2721. #define HV_GRP_PCI 0x0100
  2722. #define HV_GRP_LDOM 0x0101
  2723. #define HV_GRP_SVC_CHAN 0x0102
  2724. #define HV_GRP_NCS 0x0103
  2725. #define HV_GRP_NIAG_PERF 0x0200
  2726. #define HV_GRP_FIRE_PERF 0x0201
  2727. #define HV_GRP_DIAG 0x0300
  2728. #ifndef __ASSEMBLY__
  2729. extern unsigned long sun4v_get_version(unsigned long group,
  2730. unsigned long *major,
  2731. unsigned long *minor);
  2732. extern unsigned long sun4v_set_version(unsigned long group,
  2733. unsigned long major,
  2734. unsigned long minor,
  2735. unsigned long *actual_minor);
  2736. extern int sun4v_hvapi_register(unsigned long group, unsigned long major,
  2737. unsigned long *minor);
  2738. extern void sun4v_hvapi_unregister(unsigned long group);
  2739. extern int sun4v_hvapi_get(unsigned long group,
  2740. unsigned long *major,
  2741. unsigned long *minor);
  2742. extern void sun4v_hvapi_init(void);
  2743. #endif
  2744. #endif /* !(_SPARC64_HYPERVISOR_H) */