hypervisor.h 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949
  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. #ifndef __ASSEMBLY__
  669. extern void sun4v_mmu_demap_all(void);
  670. #endif
  671. /* mmu_map_perm_addr()
  672. * TRAP: HV_FAST_TRAP
  673. * FUNCTION: HV_FAST_MMU_MAP_PERM_ADDR
  674. * ARG0: virtual address
  675. * ARG1: reserved, must be zero
  676. * ARG2: TTE
  677. * ARG3: flags (HV_MMU_{IMMU,DMMU})
  678. * RET0: status
  679. * ERRORS: EINVAL Invalid virutal address or flags value
  680. * EBADPGSZ Invalid page size value
  681. * ENORADDR Invalid real address in TTE
  682. * ETOOMANY Too many mappings (max of 8 reached)
  683. *
  684. * Create a permanent mapping using the given TTE and virtual address
  685. * for context 0 on the calling virtual CPU. A maximum of 8 such
  686. * permanent mappings may be specified by privileged code. Mappings
  687. * may be removed with mmu_unmap_perm_addr().
  688. *
  689. * The behavior is undefined if a TTE with the valid bit clear is given.
  690. *
  691. * Note: This call is used to specify address space mappings for which
  692. * privileged code does not expect to receive misses. For example,
  693. * this mechanism can be used to map kernel nucleus code and data.
  694. */
  695. #define HV_FAST_MMU_MAP_PERM_ADDR 0x25
  696. #ifndef __ASSEMBLY__
  697. extern unsigned long sun4v_mmu_map_perm_addr(unsigned long vaddr,
  698. unsigned long set_to_zero,
  699. unsigned long tte,
  700. unsigned long flags);
  701. #endif
  702. /* mmu_fault_area_conf()
  703. * TRAP: HV_FAST_TRAP
  704. * FUNCTION: HV_FAST_MMU_FAULT_AREA_CONF
  705. * ARG0: real address
  706. * RET0: status
  707. * RET1: previous mmu fault area real address
  708. * ERRORS: ENORADDR Invalid real address
  709. * EBADALIGN Invalid alignment for fault area
  710. *
  711. * Configure the MMU fault status area for the calling CPU. A 64-byte
  712. * aligned real address specifies where MMU fault status information
  713. * is placed. The return value is the previously specified area, or 0
  714. * for the first invocation. Specifying a fault area at real address
  715. * 0 is not allowed.
  716. */
  717. #define HV_FAST_MMU_FAULT_AREA_CONF 0x26
  718. /* mmu_enable()
  719. * TRAP: HV_FAST_TRAP
  720. * FUNCTION: HV_FAST_MMU_ENABLE
  721. * ARG0: enable flag
  722. * ARG1: return target address
  723. * RET0: status
  724. * ERRORS: ENORADDR Invalid real address when disabling
  725. * translation.
  726. * EBADALIGN The return target address is not
  727. * aligned to an instruction.
  728. * EINVAL The enable flag request the current
  729. * operating mode (e.g. disable if already
  730. * disabled)
  731. *
  732. * Enable or disable virtual address translation for the calling CPU
  733. * within the virtual machine domain. If the enable flag is zero,
  734. * translation is disabled, any non-zero value will enable
  735. * translation.
  736. *
  737. * When this function returns, the newly selected translation mode
  738. * will be active. If the mmu is being enabled, then the return
  739. * target address is a virtual address else it is a real address.
  740. *
  741. * Upon successful completion, control will be returned to the given
  742. * return target address (ie. the cpu will jump to that address). On
  743. * failure, the previous mmu mode remains and the trap simply returns
  744. * as normal with the appropriate error code in RET0.
  745. */
  746. #define HV_FAST_MMU_ENABLE 0x27
  747. /* mmu_unmap_perm_addr()
  748. * TRAP: HV_FAST_TRAP
  749. * FUNCTION: HV_FAST_MMU_UNMAP_PERM_ADDR
  750. * ARG0: virtual address
  751. * ARG1: reserved, must be zero
  752. * ARG2: flags (HV_MMU_{IMMU,DMMU})
  753. * RET0: status
  754. * ERRORS: EINVAL Invalid virutal address or flags value
  755. * ENOMAP Specified mapping was not found
  756. *
  757. * Demaps any permanent page mapping (established via
  758. * mmu_map_perm_addr()) at the given virtual address for context 0 on
  759. * the current virtual CPU. Any virtual tagged caches are guaranteed
  760. * to be kept consistent.
  761. */
  762. #define HV_FAST_MMU_UNMAP_PERM_ADDR 0x28
  763. /* mmu_tsb_ctx0_info()
  764. * TRAP: HV_FAST_TRAP
  765. * FUNCTION: HV_FAST_MMU_TSB_CTX0_INFO
  766. * ARG0: max TSBs
  767. * ARG1: buffer pointer
  768. * RET0: status
  769. * RET1: number of TSBs
  770. * ERRORS: EINVAL Supplied buffer is too small
  771. * EBADALIGN The buffer pointer is badly aligned
  772. * ENORADDR Invalid real address for buffer pointer
  773. *
  774. * Return the TSB configuration as previous defined by mmu_tsb_ctx0()
  775. * into the provided buffer. The size of the buffer is given in ARG1
  776. * in terms of the number of TSB description entries.
  777. *
  778. * Upon return, RET1 always contains the number of TSB descriptions
  779. * previously configured. If zero TSBs were configured, EOK is
  780. * returned with RET1 containing 0.
  781. */
  782. #define HV_FAST_MMU_TSB_CTX0_INFO 0x29
  783. /* mmu_tsb_ctxnon0_info()
  784. * TRAP: HV_FAST_TRAP
  785. * FUNCTION: HV_FAST_MMU_TSB_CTXNON0_INFO
  786. * ARG0: max TSBs
  787. * ARG1: buffer pointer
  788. * RET0: status
  789. * RET1: number of TSBs
  790. * ERRORS: EINVAL Supplied buffer is too small
  791. * EBADALIGN The buffer pointer is badly aligned
  792. * ENORADDR Invalid real address for buffer pointer
  793. *
  794. * Return the TSB configuration as previous defined by
  795. * mmu_tsb_ctxnon0() into the provided buffer. The size of the buffer
  796. * is given in ARG1 in terms of the number of TSB description entries.
  797. *
  798. * Upon return, RET1 always contains the number of TSB descriptions
  799. * previously configured. If zero TSBs were configured, EOK is
  800. * returned with RET1 containing 0.
  801. */
  802. #define HV_FAST_MMU_TSB_CTXNON0_INFO 0x2a
  803. /* mmu_fault_area_info()
  804. * TRAP: HV_FAST_TRAP
  805. * FUNCTION: HV_FAST_MMU_FAULT_AREA_INFO
  806. * RET0: status
  807. * RET1: fault area real address
  808. * ERRORS: No errors defined.
  809. *
  810. * Return the currently defined MMU fault status area for the current
  811. * CPU. The real address of the fault status area is returned in
  812. * RET1, or 0 is returned in RET1 if no fault status area is defined.
  813. *
  814. * Note: mmu_fault_area_conf() may be called with the return value (RET1)
  815. * from this service if there is a need to save and restore the fault
  816. * area for a cpu.
  817. */
  818. #define HV_FAST_MMU_FAULT_AREA_INFO 0x2b
  819. /* Cache and Memory services. */
  820. /* mem_scrub()
  821. * TRAP: HV_FAST_TRAP
  822. * FUNCTION: HV_FAST_MEM_SCRUB
  823. * ARG0: real address
  824. * ARG1: length
  825. * RET0: status
  826. * RET1: length scrubbed
  827. * ERRORS: ENORADDR Invalid real address
  828. * EBADALIGN Start address or length are not correctly
  829. * aligned
  830. * EINVAL Length is zero
  831. *
  832. * Zero the memory contents in the range real address to real address
  833. * plus length minus 1. Also, valid ECC will be generated for that
  834. * memory address range. Scrubbing is started at the given real
  835. * address, but may not scrub the entire given length. The actual
  836. * length scrubbed will be returned in RET1.
  837. *
  838. * The real address and length must be aligned on an 8K boundary, or
  839. * contain the start address and length from a sun4v error report.
  840. *
  841. * Note: There are two uses for this function. The first use is to block clear
  842. * and initialize memory and the second is to scrub an u ncorrectable
  843. * error reported via a resumable or non-resumable trap. The second
  844. * use requires the arguments to be equal to the real address and length
  845. * provided in a sun4v memory error report.
  846. */
  847. #define HV_FAST_MEM_SCRUB 0x31
  848. /* mem_sync()
  849. * TRAP: HV_FAST_TRAP
  850. * FUNCTION: HV_FAST_MEM_SYNC
  851. * ARG0: real address
  852. * ARG1: length
  853. * RET0: status
  854. * RET1: length synced
  855. * ERRORS: ENORADDR Invalid real address
  856. * EBADALIGN Start address or length are not correctly
  857. * aligned
  858. * EINVAL Length is zero
  859. *
  860. * Force the next access within the real address to real address plus
  861. * length minus 1 to be fetches from main system memory. Less than
  862. * the given length may be synced, the actual amount synced is
  863. * returned in RET1. The real address and length must be aligned on
  864. * an 8K boundary.
  865. */
  866. #define HV_FAST_MEM_SYNC 0x32
  867. /* Time of day services.
  868. *
  869. * The hypervisor maintains the time of day on a per-domain basis.
  870. * Changing the time of day in one domain does not affect the time of
  871. * day on any other domain.
  872. *
  873. * Time is described by a single unsigned 64-bit word which is the
  874. * number of seconds since the UNIX Epoch (00:00:00 UTC, January 1,
  875. * 1970).
  876. */
  877. /* tod_get()
  878. * TRAP: HV_FAST_TRAP
  879. * FUNCTION: HV_FAST_TOD_GET
  880. * RET0: status
  881. * RET1: TOD
  882. * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable
  883. * ENOTSUPPORTED If TOD not supported on this platform
  884. *
  885. * Return the current time of day. May block if TOD access is
  886. * temporarily not possible.
  887. */
  888. #define HV_FAST_TOD_GET 0x50
  889. #ifndef __ASSEMBLY__
  890. extern unsigned long sun4v_tod_get(unsigned long *time);
  891. #endif
  892. /* tod_set()
  893. * TRAP: HV_FAST_TRAP
  894. * FUNCTION: HV_FAST_TOD_SET
  895. * ARG0: TOD
  896. * RET0: status
  897. * ERRORS: EWOULDBLOCK TOD resource is temporarily unavailable
  898. * ENOTSUPPORTED If TOD not supported on this platform
  899. *
  900. * The current time of day is set to the value specified in ARG0. May
  901. * block if TOD access is temporarily not possible.
  902. */
  903. #define HV_FAST_TOD_SET 0x51
  904. #ifndef __ASSEMBLY__
  905. extern unsigned long sun4v_tod_set(unsigned long time);
  906. #endif
  907. /* Console services */
  908. /* con_getchar()
  909. * TRAP: HV_FAST_TRAP
  910. * FUNCTION: HV_FAST_CONS_GETCHAR
  911. * RET0: status
  912. * RET1: character
  913. * ERRORS: EWOULDBLOCK No character available.
  914. *
  915. * Returns a character from the console device. If no character is
  916. * available then an EWOULDBLOCK error is returned. If a character is
  917. * available, then the returned status is EOK and the character value
  918. * is in RET1.
  919. *
  920. * A virtual BREAK is represented by the 64-bit value -1.
  921. *
  922. * A virtual HUP signal is represented by the 64-bit value -2.
  923. */
  924. #define HV_FAST_CONS_GETCHAR 0x60
  925. /* con_putchar()
  926. * TRAP: HV_FAST_TRAP
  927. * FUNCTION: HV_FAST_CONS_PUTCHAR
  928. * ARG0: character
  929. * RET0: status
  930. * ERRORS: EINVAL Illegal character
  931. * EWOULDBLOCK Output buffer currently full, would block
  932. *
  933. * Send a character to the console device. Only character values
  934. * between 0 and 255 may be used. Values outside this range are
  935. * invalid except for the 64-bit value -1 which is used to send a
  936. * virtual BREAK.
  937. */
  938. #define HV_FAST_CONS_PUTCHAR 0x61
  939. /* con_read()
  940. * TRAP: HV_FAST_TRAP
  941. * FUNCTION: HV_FAST_CONS_READ
  942. * ARG0: buffer real address
  943. * ARG1: buffer size in bytes
  944. * RET0: status
  945. * RET1: bytes read or BREAK or HUP
  946. * ERRORS: EWOULDBLOCK No character available.
  947. *
  948. * Reads characters into a buffer from the console device. If no
  949. * character is available then an EWOULDBLOCK error is returned.
  950. * If a character is available, then the returned status is EOK
  951. * and the number of bytes read into the given buffer is provided
  952. * in RET1.
  953. *
  954. * A virtual BREAK is represented by the 64-bit RET1 value -1.
  955. *
  956. * A virtual HUP signal is represented by the 64-bit RET1 value -2.
  957. *
  958. * If BREAK or HUP are indicated, no bytes were read into buffer.
  959. */
  960. #define HV_FAST_CONS_READ 0x62
  961. /* con_write()
  962. * TRAP: HV_FAST_TRAP
  963. * FUNCTION: HV_FAST_CONS_WRITE
  964. * ARG0: buffer real address
  965. * ARG1: buffer size in bytes
  966. * RET0: status
  967. * RET1: bytes written
  968. * ERRORS: EWOULDBLOCK Output buffer currently full, would block
  969. *
  970. * Send a characters in buffer to the console device. Breaks must be
  971. * sent using con_putchar().
  972. */
  973. #define HV_FAST_CONS_WRITE 0x63
  974. #ifndef __ASSEMBLY__
  975. extern long sun4v_con_getchar(long *status);
  976. extern long sun4v_con_putchar(long c);
  977. extern long sun4v_con_read(unsigned long buffer,
  978. unsigned long size,
  979. unsigned long *bytes_read);
  980. extern unsigned long sun4v_con_write(unsigned long buffer,
  981. unsigned long size,
  982. unsigned long *bytes_written);
  983. #endif
  984. /* mach_set_soft_state()
  985. * TRAP: HV_FAST_TRAP
  986. * FUNCTION: HV_FAST_MACH_SET_SOFT_STATE
  987. * ARG0: software state
  988. * ARG1: software state description pointer
  989. * RET0: status
  990. * ERRORS: EINVAL software state not valid or software state
  991. * description is not NULL terminated
  992. * ENORADDR software state description pointer is not a
  993. * valid real address
  994. * EBADALIGNED software state description is not correctly
  995. * aligned
  996. *
  997. * This allows the guest to report it's soft state to the hypervisor. There
  998. * are two primary components to this state. The first part states whether
  999. * the guest software is running or not. The second containts optional
  1000. * details specific to the software.
  1001. *
  1002. * The software state argument is defined below in HV_SOFT_STATE_*, and
  1003. * indicates whether the guest is operating normally or in a transitional
  1004. * state.
  1005. *
  1006. * The software state description argument is a real address of a data buffer
  1007. * of size 32-bytes aligned on a 32-byte boundary. It is treated as a NULL
  1008. * terminated 7-bit ASCII string of up to 31 characters not including the
  1009. * NULL termination.
  1010. */
  1011. #define HV_FAST_MACH_SET_SOFT_STATE 0x70
  1012. #define HV_SOFT_STATE_NORMAL 0x01
  1013. #define HV_SOFT_STATE_TRANSITION 0x02
  1014. #ifndef __ASSEMBLY__
  1015. extern unsigned long sun4v_mach_set_soft_state(unsigned long soft_state,
  1016. unsigned long msg_string_ra);
  1017. #endif
  1018. /* mach_get_soft_state()
  1019. * TRAP: HV_FAST_TRAP
  1020. * FUNCTION: HV_FAST_MACH_GET_SOFT_STATE
  1021. * ARG0: software state description pointer
  1022. * RET0: status
  1023. * RET1: software state
  1024. * ERRORS: ENORADDR software state description pointer is not a
  1025. * valid real address
  1026. * EBADALIGNED software state description is not correctly
  1027. * aligned
  1028. *
  1029. * Retrieve the current value of the guest's software state. The rules
  1030. * for the software state pointer are the same as for mach_set_soft_state()
  1031. * above.
  1032. */
  1033. #define HV_FAST_MACH_GET_SOFT_STATE 0x71
  1034. /* svc_send()
  1035. * TRAP: HV_FAST_TRAP
  1036. * FUNCTION: HV_FAST_SVC_SEND
  1037. * ARG0: service ID
  1038. * ARG1: buffer real address
  1039. * ARG2: buffer size
  1040. * RET0: STATUS
  1041. * RET1: sent_bytes
  1042. *
  1043. * Be careful, all output registers are clobbered by this operation,
  1044. * so for example it is not possible to save away a value in %o4
  1045. * across the trap.
  1046. */
  1047. #define HV_FAST_SVC_SEND 0x80
  1048. /* svc_recv()
  1049. * TRAP: HV_FAST_TRAP
  1050. * FUNCTION: HV_FAST_SVC_RECV
  1051. * ARG0: service ID
  1052. * ARG1: buffer real address
  1053. * ARG2: buffer size
  1054. * RET0: STATUS
  1055. * RET1: recv_bytes
  1056. *
  1057. * Be careful, all output registers are clobbered by this operation,
  1058. * so for example it is not possible to save away a value in %o4
  1059. * across the trap.
  1060. */
  1061. #define HV_FAST_SVC_RECV 0x81
  1062. /* svc_getstatus()
  1063. * TRAP: HV_FAST_TRAP
  1064. * FUNCTION: HV_FAST_SVC_GETSTATUS
  1065. * ARG0: service ID
  1066. * RET0: STATUS
  1067. * RET1: status bits
  1068. */
  1069. #define HV_FAST_SVC_GETSTATUS 0x82
  1070. /* svc_setstatus()
  1071. * TRAP: HV_FAST_TRAP
  1072. * FUNCTION: HV_FAST_SVC_SETSTATUS
  1073. * ARG0: service ID
  1074. * ARG1: bits to set
  1075. * RET0: STATUS
  1076. */
  1077. #define HV_FAST_SVC_SETSTATUS 0x83
  1078. /* svc_clrstatus()
  1079. * TRAP: HV_FAST_TRAP
  1080. * FUNCTION: HV_FAST_SVC_CLRSTATUS
  1081. * ARG0: service ID
  1082. * ARG1: bits to clear
  1083. * RET0: STATUS
  1084. */
  1085. #define HV_FAST_SVC_CLRSTATUS 0x84
  1086. #ifndef __ASSEMBLY__
  1087. extern unsigned long sun4v_svc_send(unsigned long svc_id,
  1088. unsigned long buffer,
  1089. unsigned long buffer_size,
  1090. unsigned long *sent_bytes);
  1091. extern unsigned long sun4v_svc_recv(unsigned long svc_id,
  1092. unsigned long buffer,
  1093. unsigned long buffer_size,
  1094. unsigned long *recv_bytes);
  1095. extern unsigned long sun4v_svc_getstatus(unsigned long svc_id,
  1096. unsigned long *status_bits);
  1097. extern unsigned long sun4v_svc_setstatus(unsigned long svc_id,
  1098. unsigned long status_bits);
  1099. extern unsigned long sun4v_svc_clrstatus(unsigned long svc_id,
  1100. unsigned long status_bits);
  1101. #endif
  1102. /* Trap trace services.
  1103. *
  1104. * The hypervisor provides a trap tracing capability for privileged
  1105. * code running on each virtual CPU. Privileged code provides a
  1106. * round-robin trap trace queue within which the hypervisor writes
  1107. * 64-byte entries detailing hyperprivileged traps taken n behalf of
  1108. * privileged code. This is provided as a debugging capability for
  1109. * privileged code.
  1110. *
  1111. * The trap trace control structure is 64-bytes long and placed at the
  1112. * start (offset 0) of the trap trace buffer, and is described as
  1113. * follows:
  1114. */
  1115. #ifndef __ASSEMBLY__
  1116. struct hv_trap_trace_control {
  1117. unsigned long head_offset;
  1118. unsigned long tail_offset;
  1119. unsigned long __reserved[0x30 / sizeof(unsigned long)];
  1120. };
  1121. #endif
  1122. #define HV_TRAP_TRACE_CTRL_HEAD_OFFSET 0x00
  1123. #define HV_TRAP_TRACE_CTRL_TAIL_OFFSET 0x08
  1124. /* The head offset is the offset of the most recently completed entry
  1125. * in the trap-trace buffer. The tail offset is the offset of the
  1126. * next entry to be written. The control structure is owned and
  1127. * modified by the hypervisor. A guest may not modify the control
  1128. * structure contents. Attempts to do so will result in undefined
  1129. * behavior for the guest.
  1130. *
  1131. * Each trap trace buffer entry is layed out as follows:
  1132. */
  1133. #ifndef __ASSEMBLY__
  1134. struct hv_trap_trace_entry {
  1135. unsigned char type; /* Hypervisor or guest entry? */
  1136. unsigned char hpstate; /* Hyper-privileged state */
  1137. unsigned char tl; /* Trap level */
  1138. unsigned char gl; /* Global register level */
  1139. unsigned short tt; /* Trap type */
  1140. unsigned short tag; /* Extended trap identifier */
  1141. unsigned long tstate; /* Trap state */
  1142. unsigned long tick; /* Tick */
  1143. unsigned long tpc; /* Trap PC */
  1144. unsigned long f1; /* Entry specific */
  1145. unsigned long f2; /* Entry specific */
  1146. unsigned long f3; /* Entry specific */
  1147. unsigned long f4; /* Entry specific */
  1148. };
  1149. #endif
  1150. #define HV_TRAP_TRACE_ENTRY_TYPE 0x00
  1151. #define HV_TRAP_TRACE_ENTRY_HPSTATE 0x01
  1152. #define HV_TRAP_TRACE_ENTRY_TL 0x02
  1153. #define HV_TRAP_TRACE_ENTRY_GL 0x03
  1154. #define HV_TRAP_TRACE_ENTRY_TT 0x04
  1155. #define HV_TRAP_TRACE_ENTRY_TAG 0x06
  1156. #define HV_TRAP_TRACE_ENTRY_TSTATE 0x08
  1157. #define HV_TRAP_TRACE_ENTRY_TICK 0x10
  1158. #define HV_TRAP_TRACE_ENTRY_TPC 0x18
  1159. #define HV_TRAP_TRACE_ENTRY_F1 0x20
  1160. #define HV_TRAP_TRACE_ENTRY_F2 0x28
  1161. #define HV_TRAP_TRACE_ENTRY_F3 0x30
  1162. #define HV_TRAP_TRACE_ENTRY_F4 0x38
  1163. /* The type field is encoded as follows. */
  1164. #define HV_TRAP_TYPE_UNDEF 0x00 /* Entry content undefined */
  1165. #define HV_TRAP_TYPE_HV 0x01 /* Hypervisor trap entry */
  1166. #define HV_TRAP_TYPE_GUEST 0xff /* Added via ttrace_addentry() */
  1167. /* ttrace_buf_conf()
  1168. * TRAP: HV_FAST_TRAP
  1169. * FUNCTION: HV_FAST_TTRACE_BUF_CONF
  1170. * ARG0: real address
  1171. * ARG1: number of entries
  1172. * RET0: status
  1173. * RET1: number of entries
  1174. * ERRORS: ENORADDR Invalid real address
  1175. * EINVAL Size is too small
  1176. * EBADALIGN Real address not aligned on 64-byte boundary
  1177. *
  1178. * Requests hypervisor trap tracing and declares a virtual CPU's trap
  1179. * trace buffer to the hypervisor. The real address supplies the real
  1180. * base address of the trap trace queue and must be 64-byte aligned.
  1181. * Specifying a value of 0 for the number of entries disables trap
  1182. * tracing for the calling virtual CPU. The buffer allocated must be
  1183. * sized for a power of two number of 64-byte trap trace entries plus
  1184. * an initial 64-byte control structure.
  1185. *
  1186. * This may be invoked any number of times so that a virtual CPU may
  1187. * relocate a trap trace buffer or create "snapshots" of information.
  1188. *
  1189. * If the real address is illegal or badly aligned, then trap tracing
  1190. * is disabled and an error is returned.
  1191. *
  1192. * Upon failure with EINVAL, this service call returns in RET1 the
  1193. * minimum number of buffer entries required. Upon other failures
  1194. * RET1 is undefined.
  1195. */
  1196. #define HV_FAST_TTRACE_BUF_CONF 0x90
  1197. /* ttrace_buf_info()
  1198. * TRAP: HV_FAST_TRAP
  1199. * FUNCTION: HV_FAST_TTRACE_BUF_INFO
  1200. * RET0: status
  1201. * RET1: real address
  1202. * RET2: size
  1203. * ERRORS: None defined.
  1204. *
  1205. * Returns the size and location of the previously declared trap-trace
  1206. * buffer. In the event that no buffer was previously defined, or the
  1207. * buffer is disabled, this call will return a size of zero bytes.
  1208. */
  1209. #define HV_FAST_TTRACE_BUF_INFO 0x91
  1210. /* ttrace_enable()
  1211. * TRAP: HV_FAST_TRAP
  1212. * FUNCTION: HV_FAST_TTRACE_ENABLE
  1213. * ARG0: enable
  1214. * RET0: status
  1215. * RET1: previous enable state
  1216. * ERRORS: EINVAL No trap trace buffer currently defined
  1217. *
  1218. * Enable or disable trap tracing, and return the previous enabled
  1219. * state in RET1. Future systems may define various flags for the
  1220. * enable argument (ARG0), for the moment a guest should pass
  1221. * "(uint64_t) -1" to enable, and "(uint64_t) 0" to disable all
  1222. * tracing - which will ensure future compatability.
  1223. */
  1224. #define HV_FAST_TTRACE_ENABLE 0x92
  1225. /* ttrace_freeze()
  1226. * TRAP: HV_FAST_TRAP
  1227. * FUNCTION: HV_FAST_TTRACE_FREEZE
  1228. * ARG0: freeze
  1229. * RET0: status
  1230. * RET1: previous freeze state
  1231. * ERRORS: EINVAL No trap trace buffer currently defined
  1232. *
  1233. * Freeze or unfreeze trap tracing, returning the previous freeze
  1234. * state in RET1. A guest should pass a non-zero value to freeze and
  1235. * a zero value to unfreeze all tracing. The returned previous state
  1236. * is 0 for not frozen and 1 for frozen.
  1237. */
  1238. #define HV_FAST_TTRACE_FREEZE 0x93
  1239. /* ttrace_addentry()
  1240. * TRAP: HV_TTRACE_ADDENTRY_TRAP
  1241. * ARG0: tag (16-bits)
  1242. * ARG1: data word 0
  1243. * ARG2: data word 1
  1244. * ARG3: data word 2
  1245. * ARG4: data word 3
  1246. * RET0: status
  1247. * ERRORS: EINVAL No trap trace buffer currently defined
  1248. *
  1249. * Add an entry to the trap trace buffer. Upon return only ARG0/RET0
  1250. * is modified - none of the other registers holding arguments are
  1251. * volatile across this hypervisor service.
  1252. */
  1253. /* Core dump services.
  1254. *
  1255. * Since the hypervisor viraulizes and thus obscures a lot of the
  1256. * physical machine layout and state, traditional OS crash dumps can
  1257. * be difficult to diagnose especially when the problem is a
  1258. * configuration error of some sort.
  1259. *
  1260. * The dump services provide an opaque buffer into which the
  1261. * hypervisor can place it's internal state in order to assist in
  1262. * debugging such situations. The contents are opaque and extremely
  1263. * platform and hypervisor implementation specific. The guest, during
  1264. * a core dump, requests that the hypervisor update any information in
  1265. * the dump buffer in preparation to being dumped as part of the
  1266. * domain's memory image.
  1267. */
  1268. /* dump_buf_update()
  1269. * TRAP: HV_FAST_TRAP
  1270. * FUNCTION: HV_FAST_DUMP_BUF_UPDATE
  1271. * ARG0: real address
  1272. * ARG1: size
  1273. * RET0: status
  1274. * RET1: required size of dump buffer
  1275. * ERRORS: ENORADDR Invalid real address
  1276. * EBADALIGN Real address is not aligned on a 64-byte
  1277. * boundary
  1278. * EINVAL Size is non-zero but less than minimum size
  1279. * required
  1280. * ENOTSUPPORTED Operation not supported on current logical
  1281. * domain
  1282. *
  1283. * Declare a domain dump buffer to the hypervisor. The real address
  1284. * provided for the domain dump buffer must be 64-byte aligned. The
  1285. * size specifies the size of the dump buffer and may be larger than
  1286. * the minimum size specified in the machine description. The
  1287. * hypervisor will fill the dump buffer with opaque data.
  1288. *
  1289. * Note: A guest may elect to include dump buffer contents as part of a crash
  1290. * dump to assist with debugging. This function may be called any number
  1291. * of times so that a guest may relocate a dump buffer, or create
  1292. * "snapshots" of any dump-buffer information. Each call to
  1293. * dump_buf_update() atomically declares the new dump buffer to the
  1294. * hypervisor.
  1295. *
  1296. * A specified size of 0 unconfigures the dump buffer. If the real
  1297. * address is illegal or badly aligned, then any currently active dump
  1298. * buffer is disabled and an error is returned.
  1299. *
  1300. * In the event that the call fails with EINVAL, RET1 contains the
  1301. * minimum size requires by the hypervisor for a valid dump buffer.
  1302. */
  1303. #define HV_FAST_DUMP_BUF_UPDATE 0x94
  1304. /* dump_buf_info()
  1305. * TRAP: HV_FAST_TRAP
  1306. * FUNCTION: HV_FAST_DUMP_BUF_INFO
  1307. * RET0: status
  1308. * RET1: real address of current dump buffer
  1309. * RET2: size of current dump buffer
  1310. * ERRORS: No errors defined.
  1311. *
  1312. * Return the currently configures dump buffer description. A
  1313. * returned size of 0 bytes indicates an undefined dump buffer. In
  1314. * this case the return address in RET1 is undefined.
  1315. */
  1316. #define HV_FAST_DUMP_BUF_INFO 0x95
  1317. /* Device interrupt services.
  1318. *
  1319. * Device interrupts are allocated to system bus bridges by the hypervisor,
  1320. * and described to OBP in the machine description. OBP then describes
  1321. * these interrupts to the OS via properties in the device tree.
  1322. *
  1323. * Terminology:
  1324. *
  1325. * cpuid Unique opaque value which represents a target cpu.
  1326. *
  1327. * devhandle Device handle. It uniquely identifies a device, and
  1328. * consistes of the lower 28-bits of the hi-cell of the
  1329. * first entry of the device's "reg" property in the
  1330. * OBP device tree.
  1331. *
  1332. * devino Device interrupt number. Specifies the relative
  1333. * interrupt number within the device. The unique
  1334. * combination of devhandle and devino are used to
  1335. * identify a specific device interrupt.
  1336. *
  1337. * Note: The devino value is the same as the values in the
  1338. * "interrupts" property or "interrupt-map" property
  1339. * in the OBP device tree for that device.
  1340. *
  1341. * sysino System interrupt number. A 64-bit unsigned interger
  1342. * representing a unique interrupt within a virtual
  1343. * machine.
  1344. *
  1345. * intr_state A flag representing the interrupt state for a given
  1346. * sysino. The state values are defined below.
  1347. *
  1348. * intr_enabled A flag representing the 'enabled' state for a given
  1349. * sysino. The enable values are defined below.
  1350. */
  1351. #define HV_INTR_STATE_IDLE 0 /* Nothing pending */
  1352. #define HV_INTR_STATE_RECEIVED 1 /* Interrupt received by hardware */
  1353. #define HV_INTR_STATE_DELIVERED 2 /* Interrupt delivered to queue */
  1354. #define HV_INTR_DISABLED 0 /* sysino not enabled */
  1355. #define HV_INTR_ENABLED 1 /* sysino enabled */
  1356. /* intr_devino_to_sysino()
  1357. * TRAP: HV_FAST_TRAP
  1358. * FUNCTION: HV_FAST_INTR_DEVINO2SYSINO
  1359. * ARG0: devhandle
  1360. * ARG1: devino
  1361. * RET0: status
  1362. * RET1: sysino
  1363. * ERRORS: EINVAL Invalid devhandle/devino
  1364. *
  1365. * Converts a device specific interrupt number of the given
  1366. * devhandle/devino into a system specific ino (sysino).
  1367. */
  1368. #define HV_FAST_INTR_DEVINO2SYSINO 0xa0
  1369. #ifndef __ASSEMBLY__
  1370. extern unsigned long sun4v_devino_to_sysino(unsigned long devhandle,
  1371. unsigned long devino);
  1372. #endif
  1373. /* intr_getenabled()
  1374. * TRAP: HV_FAST_TRAP
  1375. * FUNCTION: HV_FAST_INTR_GETENABLED
  1376. * ARG0: sysino
  1377. * RET0: status
  1378. * RET1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1379. * ERRORS: EINVAL Invalid sysino
  1380. *
  1381. * Returns interrupt enabled state in RET1 for the interrupt defined
  1382. * by the given sysino.
  1383. */
  1384. #define HV_FAST_INTR_GETENABLED 0xa1
  1385. #ifndef __ASSEMBLY__
  1386. extern unsigned long sun4v_intr_getenabled(unsigned long sysino);
  1387. #endif
  1388. /* intr_setenabled()
  1389. * TRAP: HV_FAST_TRAP
  1390. * FUNCTION: HV_FAST_INTR_SETENABLED
  1391. * ARG0: sysino
  1392. * ARG1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
  1393. * RET0: status
  1394. * ERRORS: EINVAL Invalid sysino or intr_enabled value
  1395. *
  1396. * Set the 'enabled' state of the interrupt sysino.
  1397. */
  1398. #define HV_FAST_INTR_SETENABLED 0xa2
  1399. #ifndef __ASSEMBLY__
  1400. extern unsigned long sun4v_intr_setenabled(unsigned long sysino, unsigned long intr_enabled);
  1401. #endif
  1402. /* intr_getstate()
  1403. * TRAP: HV_FAST_TRAP
  1404. * FUNCTION: HV_FAST_INTR_GETSTATE
  1405. * ARG0: sysino
  1406. * RET0: status
  1407. * RET1: intr_state (HV_INTR_STATE_*)
  1408. * ERRORS: EINVAL Invalid sysino
  1409. *
  1410. * Returns current state of the interrupt defined by the given sysino.
  1411. */
  1412. #define HV_FAST_INTR_GETSTATE 0xa3
  1413. #ifndef __ASSEMBLY__
  1414. extern unsigned long sun4v_intr_getstate(unsigned long sysino);
  1415. #endif
  1416. /* intr_setstate()
  1417. * TRAP: HV_FAST_TRAP
  1418. * FUNCTION: HV_FAST_INTR_SETSTATE
  1419. * ARG0: sysino
  1420. * ARG1: intr_state (HV_INTR_STATE_*)
  1421. * RET0: status
  1422. * ERRORS: EINVAL Invalid sysino or intr_state value
  1423. *
  1424. * Sets the current state of the interrupt described by the given sysino
  1425. * value.
  1426. *
  1427. * Note: Setting the state to HV_INTR_STATE_IDLE clears any pending
  1428. * interrupt for sysino.
  1429. */
  1430. #define HV_FAST_INTR_SETSTATE 0xa4
  1431. #ifndef __ASSEMBLY__
  1432. extern unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long intr_state);
  1433. #endif
  1434. /* intr_gettarget()
  1435. * TRAP: HV_FAST_TRAP
  1436. * FUNCTION: HV_FAST_INTR_GETTARGET
  1437. * ARG0: sysino
  1438. * RET0: status
  1439. * RET1: cpuid
  1440. * ERRORS: EINVAL Invalid sysino
  1441. *
  1442. * Returns CPU that is the current target of the interrupt defined by
  1443. * the given sysino. The CPU value returned is undefined if the target
  1444. * has not been set via intr_settarget().
  1445. */
  1446. #define HV_FAST_INTR_GETTARGET 0xa5
  1447. #ifndef __ASSEMBLY__
  1448. extern unsigned long sun4v_intr_gettarget(unsigned long sysino);
  1449. #endif
  1450. /* intr_settarget()
  1451. * TRAP: HV_FAST_TRAP
  1452. * FUNCTION: HV_FAST_INTR_SETTARGET
  1453. * ARG0: sysino
  1454. * ARG1: cpuid
  1455. * RET0: status
  1456. * ERRORS: EINVAL Invalid sysino
  1457. * ENOCPU Invalid cpuid
  1458. *
  1459. * Set the target CPU for the interrupt defined by the given sysino.
  1460. */
  1461. #define HV_FAST_INTR_SETTARGET 0xa6
  1462. #ifndef __ASSEMBLY__
  1463. extern unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cpuid);
  1464. #endif
  1465. /* vintr_get_cookie()
  1466. * TRAP: HV_FAST_TRAP
  1467. * FUNCTION: HV_FAST_VINTR_GET_COOKIE
  1468. * ARG0: device handle
  1469. * ARG1: device ino
  1470. * RET0: status
  1471. * RET1: cookie
  1472. */
  1473. #define HV_FAST_VINTR_GET_COOKIE 0xa7
  1474. /* vintr_set_cookie()
  1475. * TRAP: HV_FAST_TRAP
  1476. * FUNCTION: HV_FAST_VINTR_SET_COOKIE
  1477. * ARG0: device handle
  1478. * ARG1: device ino
  1479. * ARG2: cookie
  1480. * RET0: status
  1481. */
  1482. #define HV_FAST_VINTR_SET_COOKIE 0xa8
  1483. /* vintr_get_valid()
  1484. * TRAP: HV_FAST_TRAP
  1485. * FUNCTION: HV_FAST_VINTR_GET_VALID
  1486. * ARG0: device handle
  1487. * ARG1: device ino
  1488. * RET0: status
  1489. * RET1: valid state
  1490. */
  1491. #define HV_FAST_VINTR_GET_VALID 0xa9
  1492. /* vintr_set_valid()
  1493. * TRAP: HV_FAST_TRAP
  1494. * FUNCTION: HV_FAST_VINTR_SET_VALID
  1495. * ARG0: device handle
  1496. * ARG1: device ino
  1497. * ARG2: valid state
  1498. * RET0: status
  1499. */
  1500. #define HV_FAST_VINTR_SET_VALID 0xaa
  1501. /* vintr_get_state()
  1502. * TRAP: HV_FAST_TRAP
  1503. * FUNCTION: HV_FAST_VINTR_GET_STATE
  1504. * ARG0: device handle
  1505. * ARG1: device ino
  1506. * RET0: status
  1507. * RET1: state
  1508. */
  1509. #define HV_FAST_VINTR_GET_STATE 0xab
  1510. /* vintr_set_state()
  1511. * TRAP: HV_FAST_TRAP
  1512. * FUNCTION: HV_FAST_VINTR_SET_STATE
  1513. * ARG0: device handle
  1514. * ARG1: device ino
  1515. * ARG2: state
  1516. * RET0: status
  1517. */
  1518. #define HV_FAST_VINTR_SET_STATE 0xac
  1519. /* vintr_get_target()
  1520. * TRAP: HV_FAST_TRAP
  1521. * FUNCTION: HV_FAST_VINTR_GET_TARGET
  1522. * ARG0: device handle
  1523. * ARG1: device ino
  1524. * RET0: status
  1525. * RET1: cpuid
  1526. */
  1527. #define HV_FAST_VINTR_GET_TARGET 0xad
  1528. /* vintr_set_target()
  1529. * TRAP: HV_FAST_TRAP
  1530. * FUNCTION: HV_FAST_VINTR_SET_TARGET
  1531. * ARG0: device handle
  1532. * ARG1: device ino
  1533. * ARG2: cpuid
  1534. * RET0: status
  1535. */
  1536. #define HV_FAST_VINTR_SET_TARGET 0xae
  1537. #ifndef __ASSEMBLY__
  1538. extern unsigned long sun4v_vintr_get_cookie(unsigned long dev_handle,
  1539. unsigned long dev_ino,
  1540. unsigned long *cookie);
  1541. extern unsigned long sun4v_vintr_set_cookie(unsigned long dev_handle,
  1542. unsigned long dev_ino,
  1543. unsigned long cookie);
  1544. extern unsigned long sun4v_vintr_get_valid(unsigned long dev_handle,
  1545. unsigned long dev_ino,
  1546. unsigned long *valid);
  1547. extern unsigned long sun4v_vintr_set_valid(unsigned long dev_handle,
  1548. unsigned long dev_ino,
  1549. unsigned long valid);
  1550. extern unsigned long sun4v_vintr_get_state(unsigned long dev_handle,
  1551. unsigned long dev_ino,
  1552. unsigned long *state);
  1553. extern unsigned long sun4v_vintr_set_state(unsigned long dev_handle,
  1554. unsigned long dev_ino,
  1555. unsigned long state);
  1556. extern unsigned long sun4v_vintr_get_target(unsigned long dev_handle,
  1557. unsigned long dev_ino,
  1558. unsigned long *cpuid);
  1559. extern unsigned long sun4v_vintr_set_target(unsigned long dev_handle,
  1560. unsigned long dev_ino,
  1561. unsigned long cpuid);
  1562. #endif
  1563. /* PCI IO services.
  1564. *
  1565. * See the terminology descriptions in the device interrupt services
  1566. * section above as those apply here too. Here are terminology
  1567. * definitions specific to these PCI IO services:
  1568. *
  1569. * tsbnum TSB number. Indentifies which io-tsb is used.
  1570. * For this version of the specification, tsbnum
  1571. * must be zero.
  1572. *
  1573. * tsbindex TSB index. Identifies which entry in the TSB
  1574. * is used. The first entry is zero.
  1575. *
  1576. * tsbid A 64-bit aligned data structure which contains
  1577. * a tsbnum and a tsbindex. Bits 63:32 contain the
  1578. * tsbnum and bits 31:00 contain the tsbindex.
  1579. *
  1580. * Use the HV_PCI_TSBID() macro to construct such
  1581. * values.
  1582. *
  1583. * io_attributes IO attributes for IOMMU mappings. One of more
  1584. * of the attritbute bits are stores in a 64-bit
  1585. * value. The values are defined below.
  1586. *
  1587. * r_addr 64-bit real address
  1588. *
  1589. * pci_device PCI device address. A PCI device address identifies
  1590. * a specific device on a specific PCI bus segment.
  1591. * A PCI device address ia a 32-bit unsigned integer
  1592. * with the following format:
  1593. *
  1594. * 00000000.bbbbbbbb.dddddfff.00000000
  1595. *
  1596. * Use the HV_PCI_DEVICE_BUILD() macro to construct
  1597. * such values.
  1598. *
  1599. * pci_config_offset
  1600. * PCI configureation space offset. For conventional
  1601. * PCI a value between 0 and 255. For extended
  1602. * configuration space, a value between 0 and 4095.
  1603. *
  1604. * Note: For PCI configuration space accesses, the offset
  1605. * must be aligned to the access size.
  1606. *
  1607. * error_flag A return value which specifies if the action succeeded
  1608. * or failed. 0 means no error, non-0 means some error
  1609. * occurred while performing the service.
  1610. *
  1611. * io_sync_direction
  1612. * Direction definition for pci_dma_sync(), defined
  1613. * below in HV_PCI_SYNC_*.
  1614. *
  1615. * io_page_list A list of io_page_addresses, an io_page_address is
  1616. * a real address.
  1617. *
  1618. * io_page_list_p A pointer to an io_page_list.
  1619. *
  1620. * "size based byte swap" - Some functions do size based byte swapping
  1621. * which allows sw to access pointers and
  1622. * counters in native form when the processor
  1623. * operates in a different endianness than the
  1624. * IO bus. Size-based byte swapping converts a
  1625. * multi-byte field between big-endian and
  1626. * little-endian format.
  1627. */
  1628. #define HV_PCI_MAP_ATTR_READ 0x01
  1629. #define HV_PCI_MAP_ATTR_WRITE 0x02
  1630. #define HV_PCI_DEVICE_BUILD(b,d,f) \
  1631. ((((b) & 0xff) << 16) | \
  1632. (((d) & 0x1f) << 11) | \
  1633. (((f) & 0x07) << 8))
  1634. #define HV_PCI_TSBID(__tsb_num, __tsb_index) \
  1635. ((((u64)(__tsb_num)) << 32UL) | ((u64)(__tsb_index)))
  1636. #define HV_PCI_SYNC_FOR_DEVICE 0x01
  1637. #define HV_PCI_SYNC_FOR_CPU 0x02
  1638. /* pci_iommu_map()
  1639. * TRAP: HV_FAST_TRAP
  1640. * FUNCTION: HV_FAST_PCI_IOMMU_MAP
  1641. * ARG0: devhandle
  1642. * ARG1: tsbid
  1643. * ARG2: #ttes
  1644. * ARG3: io_attributes
  1645. * ARG4: io_page_list_p
  1646. * RET0: status
  1647. * RET1: #ttes mapped
  1648. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex/io_attributes
  1649. * EBADALIGN Improperly aligned real address
  1650. * ENORADDR Invalid real address
  1651. *
  1652. * Create IOMMU mappings in the sun4v device defined by the given
  1653. * devhandle. The mappings are created in the TSB defined by the
  1654. * tsbnum component of the given tsbid. The first mapping is created
  1655. * in the TSB i ndex defined by the tsbindex component of the given tsbid.
  1656. * The call creates up to #ttes mappings, the first one at tsbnum, tsbindex,
  1657. * the second at tsbnum, tsbindex + 1, etc.
  1658. *
  1659. * All mappings are created with the attributes defined by the io_attributes
  1660. * argument. The page mapping addresses are described in the io_page_list
  1661. * defined by the given io_page_list_p, which is a pointer to the io_page_list.
  1662. * The first entry in the io_page_list is the address for the first iotte, the
  1663. * 2nd for the 2nd iotte, and so on.
  1664. *
  1665. * Each io_page_address in the io_page_list must be appropriately aligned.
  1666. * #ttes must be greater than zero. For this version of the spec, the tsbnum
  1667. * component of the given tsbid must be zero.
  1668. *
  1669. * Returns the actual number of mappings creates, which may be less than
  1670. * or equal to the argument #ttes. If the function returns a value which
  1671. * is less than the #ttes, the caller may continus to call the function with
  1672. * an updated tsbid, #ttes, io_page_list_p arguments until all pages are
  1673. * mapped.
  1674. *
  1675. * Note: This function does not imply an iotte cache flush. The guest must
  1676. * demap an entry before re-mapping it.
  1677. */
  1678. #define HV_FAST_PCI_IOMMU_MAP 0xb0
  1679. /* pci_iommu_demap()
  1680. * TRAP: HV_FAST_TRAP
  1681. * FUNCTION: HV_FAST_PCI_IOMMU_DEMAP
  1682. * ARG0: devhandle
  1683. * ARG1: tsbid
  1684. * ARG2: #ttes
  1685. * RET0: status
  1686. * RET1: #ttes demapped
  1687. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex
  1688. *
  1689. * Demap and flush IOMMU mappings in the device defined by the given
  1690. * devhandle. Demaps up to #ttes entries in the TSB defined by the tsbnum
  1691. * component of the given tsbid, starting at the TSB index defined by the
  1692. * tsbindex component of the given tsbid.
  1693. *
  1694. * For this version of the spec, the tsbnum of the given tsbid must be zero.
  1695. * #ttes must be greater than zero.
  1696. *
  1697. * Returns the actual number of ttes demapped, which may be less than or equal
  1698. * to the argument #ttes. If #ttes demapped is less than #ttes, the caller
  1699. * may continue to call this function with updated tsbid and #ttes arguments
  1700. * until all pages are demapped.
  1701. *
  1702. * Note: Entries do not have to be mapped to be demapped. A demap of an
  1703. * unmapped page will flush the entry from the tte cache.
  1704. */
  1705. #define HV_FAST_PCI_IOMMU_DEMAP 0xb1
  1706. /* pci_iommu_getmap()
  1707. * TRAP: HV_FAST_TRAP
  1708. * FUNCTION: HV_FAST_PCI_IOMMU_GETMAP
  1709. * ARG0: devhandle
  1710. * ARG1: tsbid
  1711. * RET0: status
  1712. * RET1: io_attributes
  1713. * RET2: real address
  1714. * ERRORS: EINVAL Invalid devhandle/tsbnum/tsbindex
  1715. * ENOMAP Mapping is not valid, no translation exists
  1716. *
  1717. * Read and return the mapping in the device described by the given devhandle
  1718. * and tsbid. If successful, the io_attributes shall be returned in RET1
  1719. * and the page address of the mapping shall be returned in RET2.
  1720. *
  1721. * For this version of the spec, the tsbnum component of the given tsbid
  1722. * must be zero.
  1723. */
  1724. #define HV_FAST_PCI_IOMMU_GETMAP 0xb2
  1725. /* pci_iommu_getbypass()
  1726. * TRAP: HV_FAST_TRAP
  1727. * FUNCTION: HV_FAST_PCI_IOMMU_GETBYPASS
  1728. * ARG0: devhandle
  1729. * ARG1: real address
  1730. * ARG2: io_attributes
  1731. * RET0: status
  1732. * RET1: io_addr
  1733. * ERRORS: EINVAL Invalid devhandle/io_attributes
  1734. * ENORADDR Invalid real address
  1735. * ENOTSUPPORTED Function not supported in this implementation.
  1736. *
  1737. * Create a "special" mapping in the device described by the given devhandle,
  1738. * for the given real address and attributes. Return the IO address in RET1
  1739. * if successful.
  1740. */
  1741. #define HV_FAST_PCI_IOMMU_GETBYPASS 0xb3
  1742. /* pci_config_get()
  1743. * TRAP: HV_FAST_TRAP
  1744. * FUNCTION: HV_FAST_PCI_CONFIG_GET
  1745. * ARG0: devhandle
  1746. * ARG1: pci_device
  1747. * ARG2: pci_config_offset
  1748. * ARG3: size
  1749. * RET0: status
  1750. * RET1: error_flag
  1751. * RET2: data
  1752. * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size
  1753. * EBADALIGN pci_config_offset not size aligned
  1754. * ENOACCESS Access to this offset is not permitted
  1755. *
  1756. * Read PCI configuration space for the adapter described by the given
  1757. * devhandle. Read size (1, 2, or 4) bytes of data from the given
  1758. * pci_device, at pci_config_offset from the beginning of the device's
  1759. * configuration space. If there was no error, RET1 is set to zero and
  1760. * RET2 is set to the data read. Insignificant bits in RET2 are not
  1761. * guarenteed to have any specific value and therefore must be ignored.
  1762. *
  1763. * The data returned in RET2 is size based byte swapped.
  1764. *
  1765. * If an error occurs during the read, set RET1 to a non-zero value. The
  1766. * given pci_config_offset must be 'size' aligned.
  1767. */
  1768. #define HV_FAST_PCI_CONFIG_GET 0xb4
  1769. /* pci_config_put()
  1770. * TRAP: HV_FAST_TRAP
  1771. * FUNCTION: HV_FAST_PCI_CONFIG_PUT
  1772. * ARG0: devhandle
  1773. * ARG1: pci_device
  1774. * ARG2: pci_config_offset
  1775. * ARG3: size
  1776. * ARG4: data
  1777. * RET0: status
  1778. * RET1: error_flag
  1779. * ERRORS: EINVAL Invalid devhandle/pci_device/offset/size
  1780. * EBADALIGN pci_config_offset not size aligned
  1781. * ENOACCESS Access to this offset is not permitted
  1782. *
  1783. * Write PCI configuration space for the adapter described by the given
  1784. * devhandle. Write size (1, 2, or 4) bytes of data in a single operation,
  1785. * at pci_config_offset from the beginning of the device's configuration
  1786. * space. The data argument contains the data to be written to configuration
  1787. * space. Prior to writing, the data is size based byte swapped.
  1788. *
  1789. * If an error occurs during the write access, do not generate an error
  1790. * report, do set RET1 to a non-zero value. Otherwise RET1 is zero.
  1791. * The given pci_config_offset must be 'size' aligned.
  1792. *
  1793. * This function is permitted to read from offset zero in the configuration
  1794. * space described by the given pci_device if necessary to ensure that the
  1795. * write access to config space completes.
  1796. */
  1797. #define HV_FAST_PCI_CONFIG_PUT 0xb5
  1798. /* pci_peek()
  1799. * TRAP: HV_FAST_TRAP
  1800. * FUNCTION: HV_FAST_PCI_PEEK
  1801. * ARG0: devhandle
  1802. * ARG1: real address
  1803. * ARG2: size
  1804. * RET0: status
  1805. * RET1: error_flag
  1806. * RET2: data
  1807. * ERRORS: EINVAL Invalid devhandle or size
  1808. * EBADALIGN Improperly aligned real address
  1809. * ENORADDR Bad real address
  1810. * ENOACCESS Guest access prohibited
  1811. *
  1812. * Attempt to read the IO address given by the given devhandle, real address,
  1813. * and size. Size must be 1, 2, 4, or 8. The read is performed as a single
  1814. * access operation using the given size. If an error occurs when reading
  1815. * from the given location, do not generate an error report, but return a
  1816. * non-zero value in RET1. If the read was successful, return zero in RET1
  1817. * and return the actual data read in RET2. The data returned is size based
  1818. * byte swapped.
  1819. *
  1820. * Non-significant bits in RET2 are not guarenteed to have any specific value
  1821. * and therefore must be ignored. If RET1 is returned as non-zero, the data
  1822. * value is not guarenteed to have any specific value and should be ignored.
  1823. *
  1824. * The caller must have permission to read from the given devhandle, real
  1825. * address, which must be an IO address. The argument real address must be a
  1826. * size aligned address.
  1827. *
  1828. * The hypervisor implementation of this function must block access to any
  1829. * IO address that the guest does not have explicit permission to access.
  1830. */
  1831. #define HV_FAST_PCI_PEEK 0xb6
  1832. /* pci_poke()
  1833. * TRAP: HV_FAST_TRAP
  1834. * FUNCTION: HV_FAST_PCI_POKE
  1835. * ARG0: devhandle
  1836. * ARG1: real address
  1837. * ARG2: size
  1838. * ARG3: data
  1839. * ARG4: pci_device
  1840. * RET0: status
  1841. * RET1: error_flag
  1842. * ERRORS: EINVAL Invalid devhandle, size, or pci_device
  1843. * EBADALIGN Improperly aligned real address
  1844. * ENORADDR Bad real address
  1845. * ENOACCESS Guest access prohibited
  1846. * ENOTSUPPORTED Function is not supported by implementation
  1847. *
  1848. * Attempt to write data to the IO address given by the given devhandle,
  1849. * real address, and size. Size must be 1, 2, 4, or 8. The write is
  1850. * performed as a single access operation using the given size. Prior to
  1851. * writing the data is size based swapped.
  1852. *
  1853. * If an error occurs when writing to the given location, do not generate an
  1854. * error report, but return a non-zero value in RET1. If the write was
  1855. * successful, return zero in RET1.
  1856. *
  1857. * pci_device describes the configuration address of the device being
  1858. * written to. The implementation may safely read from offset 0 with
  1859. * the configuration space of the device described by devhandle and
  1860. * pci_device in order to guarantee that the write portion of the operation
  1861. * completes
  1862. *
  1863. * Any error that occurs due to the read shall be reported using the normal
  1864. * error reporting mechanisms .. the read error is not suppressed.
  1865. *
  1866. * The caller must have permission to write to the given devhandle, real
  1867. * address, which must be an IO address. The argument real address must be a
  1868. * size aligned address. The caller must have permission to read from
  1869. * the given devhandle, pci_device cofiguration space offset 0.
  1870. *
  1871. * The hypervisor implementation of this function must block access to any
  1872. * IO address that the guest does not have explicit permission to access.
  1873. */
  1874. #define HV_FAST_PCI_POKE 0xb7
  1875. /* pci_dma_sync()
  1876. * TRAP: HV_FAST_TRAP
  1877. * FUNCTION: HV_FAST_PCI_DMA_SYNC
  1878. * ARG0: devhandle
  1879. * ARG1: real address
  1880. * ARG2: size
  1881. * ARG3: io_sync_direction
  1882. * RET0: status
  1883. * RET1: #synced
  1884. * ERRORS: EINVAL Invalid devhandle or io_sync_direction
  1885. * ENORADDR Bad real address
  1886. *
  1887. * Synchronize a memory region described by the given real address and size,
  1888. * for the device defined by the given devhandle using the direction(s)
  1889. * defined by the given io_sync_direction. The argument size is the size of
  1890. * the memory region in bytes.
  1891. *
  1892. * Return the actual number of bytes synchronized in the return value #synced,
  1893. * which may be less than or equal to the argument size. If the return
  1894. * value #synced is less than size, the caller must continue to call this
  1895. * function with updated real address and size arguments until the entire
  1896. * memory region is synchronized.
  1897. */
  1898. #define HV_FAST_PCI_DMA_SYNC 0xb8
  1899. /* PCI MSI services. */
  1900. #define HV_MSITYPE_MSI32 0x00
  1901. #define HV_MSITYPE_MSI64 0x01
  1902. #define HV_MSIQSTATE_IDLE 0x00
  1903. #define HV_MSIQSTATE_ERROR 0x01
  1904. #define HV_MSIQ_INVALID 0x00
  1905. #define HV_MSIQ_VALID 0x01
  1906. #define HV_MSISTATE_IDLE 0x00
  1907. #define HV_MSISTATE_DELIVERED 0x01
  1908. #define HV_MSIVALID_INVALID 0x00
  1909. #define HV_MSIVALID_VALID 0x01
  1910. #define HV_PCIE_MSGTYPE_PME_MSG 0x18
  1911. #define HV_PCIE_MSGTYPE_PME_ACK_MSG 0x1b
  1912. #define HV_PCIE_MSGTYPE_CORR_MSG 0x30
  1913. #define HV_PCIE_MSGTYPE_NONFATAL_MSG 0x31
  1914. #define HV_PCIE_MSGTYPE_FATAL_MSG 0x33
  1915. #define HV_MSG_INVALID 0x00
  1916. #define HV_MSG_VALID 0x01
  1917. /* pci_msiq_conf()
  1918. * TRAP: HV_FAST_TRAP
  1919. * FUNCTION: HV_FAST_PCI_MSIQ_CONF
  1920. * ARG0: devhandle
  1921. * ARG1: msiqid
  1922. * ARG2: real address
  1923. * ARG3: number of entries
  1924. * RET0: status
  1925. * ERRORS: EINVAL Invalid devhandle, msiqid or nentries
  1926. * EBADALIGN Improperly aligned real address
  1927. * ENORADDR Bad real address
  1928. *
  1929. * Configure the MSI queue given by the devhandle and msiqid arguments,
  1930. * and to be placed at the given real address and be of the given
  1931. * number of entries. The real address must be aligned exactly to match
  1932. * the queue size. Each queue entry is 64-bytes long, so f.e. a 32 entry
  1933. * queue must be aligned on a 2048 byte real address boundary. The MSI-EQ
  1934. * Head and Tail are initialized so that the MSI-EQ is 'empty'.
  1935. *
  1936. * Implementation Note: Certain implementations have fixed sized queues. In
  1937. * that case, number of entries must contain the correct
  1938. * value.
  1939. */
  1940. #define HV_FAST_PCI_MSIQ_CONF 0xc0
  1941. /* pci_msiq_info()
  1942. * TRAP: HV_FAST_TRAP
  1943. * FUNCTION: HV_FAST_PCI_MSIQ_INFO
  1944. * ARG0: devhandle
  1945. * ARG1: msiqid
  1946. * RET0: status
  1947. * RET1: real address
  1948. * RET2: number of entries
  1949. * ERRORS: EINVAL Invalid devhandle or msiqid
  1950. *
  1951. * Return the configuration information for the MSI queue described
  1952. * by the given devhandle and msiqid. The base address of the queue
  1953. * is returned in ARG1 and the number of entries is returned in ARG2.
  1954. * If the queue is unconfigured, the real address is undefined and the
  1955. * number of entries will be returned as zero.
  1956. */
  1957. #define HV_FAST_PCI_MSIQ_INFO 0xc1
  1958. /* pci_msiq_getvalid()
  1959. * TRAP: HV_FAST_TRAP
  1960. * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID
  1961. * ARG0: devhandle
  1962. * ARG1: msiqid
  1963. * RET0: status
  1964. * RET1: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID)
  1965. * ERRORS: EINVAL Invalid devhandle or msiqid
  1966. *
  1967. * Get the valid state of the MSI-EQ described by the given devhandle and
  1968. * msiqid.
  1969. */
  1970. #define HV_FAST_PCI_MSIQ_GETVALID 0xc2
  1971. /* pci_msiq_setvalid()
  1972. * TRAP: HV_FAST_TRAP
  1973. * FUNCTION: HV_FAST_PCI_MSIQ_SETVALID
  1974. * ARG0: devhandle
  1975. * ARG1: msiqid
  1976. * ARG2: msiqvalid (HV_MSIQ_VALID or HV_MSIQ_INVALID)
  1977. * RET0: status
  1978. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqvalid
  1979. * value or MSI EQ is uninitialized
  1980. *
  1981. * Set the valid state of the MSI-EQ described by the given devhandle and
  1982. * msiqid to the given msiqvalid.
  1983. */
  1984. #define HV_FAST_PCI_MSIQ_SETVALID 0xc3
  1985. /* pci_msiq_getstate()
  1986. * TRAP: HV_FAST_TRAP
  1987. * FUNCTION: HV_FAST_PCI_MSIQ_GETSTATE
  1988. * ARG0: devhandle
  1989. * ARG1: msiqid
  1990. * RET0: status
  1991. * RET1: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
  1992. * ERRORS: EINVAL Invalid devhandle or msiqid
  1993. *
  1994. * Get the state of the MSI-EQ described by the given devhandle and
  1995. * msiqid.
  1996. */
  1997. #define HV_FAST_PCI_MSIQ_GETSTATE 0xc4
  1998. /* pci_msiq_getvalid()
  1999. * TRAP: HV_FAST_TRAP
  2000. * FUNCTION: HV_FAST_PCI_MSIQ_GETVALID
  2001. * ARG0: devhandle
  2002. * ARG1: msiqid
  2003. * ARG2: msiqstate (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
  2004. * RET0: status
  2005. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqstate
  2006. * value or MSI EQ is uninitialized
  2007. *
  2008. * Set the state of the MSI-EQ described by the given devhandle and
  2009. * msiqid to the given msiqvalid.
  2010. */
  2011. #define HV_FAST_PCI_MSIQ_SETSTATE 0xc5
  2012. /* pci_msiq_gethead()
  2013. * TRAP: HV_FAST_TRAP
  2014. * FUNCTION: HV_FAST_PCI_MSIQ_GETHEAD
  2015. * ARG0: devhandle
  2016. * ARG1: msiqid
  2017. * RET0: status
  2018. * RET1: msiqhead
  2019. * ERRORS: EINVAL Invalid devhandle or msiqid
  2020. *
  2021. * Get the current MSI EQ queue head for the MSI-EQ described by the
  2022. * given devhandle and msiqid.
  2023. */
  2024. #define HV_FAST_PCI_MSIQ_GETHEAD 0xc6
  2025. /* pci_msiq_sethead()
  2026. * TRAP: HV_FAST_TRAP
  2027. * FUNCTION: HV_FAST_PCI_MSIQ_SETHEAD
  2028. * ARG0: devhandle
  2029. * ARG1: msiqid
  2030. * ARG2: msiqhead
  2031. * RET0: status
  2032. * ERRORS: EINVAL Invalid devhandle or msiqid or msiqhead,
  2033. * or MSI EQ is uninitialized
  2034. *
  2035. * Set the current MSI EQ queue head for the MSI-EQ described by the
  2036. * given devhandle and msiqid.
  2037. */
  2038. #define HV_FAST_PCI_MSIQ_SETHEAD 0xc7
  2039. /* pci_msiq_gettail()
  2040. * TRAP: HV_FAST_TRAP
  2041. * FUNCTION: HV_FAST_PCI_MSIQ_GETTAIL
  2042. * ARG0: devhandle
  2043. * ARG1: msiqid
  2044. * RET0: status
  2045. * RET1: msiqtail
  2046. * ERRORS: EINVAL Invalid devhandle or msiqid
  2047. *
  2048. * Get the current MSI EQ queue tail for the MSI-EQ described by the
  2049. * given devhandle and msiqid.
  2050. */
  2051. #define HV_FAST_PCI_MSIQ_GETTAIL 0xc8
  2052. /* pci_msi_getvalid()
  2053. * TRAP: HV_FAST_TRAP
  2054. * FUNCTION: HV_FAST_PCI_MSI_GETVALID
  2055. * ARG0: devhandle
  2056. * ARG1: msinum
  2057. * RET0: status
  2058. * RET1: msivalidstate
  2059. * ERRORS: EINVAL Invalid devhandle or msinum
  2060. *
  2061. * Get the current valid/enabled state for the MSI defined by the
  2062. * given devhandle and msinum.
  2063. */
  2064. #define HV_FAST_PCI_MSI_GETVALID 0xc9
  2065. /* pci_msi_setvalid()
  2066. * TRAP: HV_FAST_TRAP
  2067. * FUNCTION: HV_FAST_PCI_MSI_SETVALID
  2068. * ARG0: devhandle
  2069. * ARG1: msinum
  2070. * ARG2: msivalidstate
  2071. * RET0: status
  2072. * ERRORS: EINVAL Invalid devhandle or msinum or msivalidstate
  2073. *
  2074. * Set the current valid/enabled state for the MSI defined by the
  2075. * given devhandle and msinum.
  2076. */
  2077. #define HV_FAST_PCI_MSI_SETVALID 0xca
  2078. /* pci_msi_getmsiq()
  2079. * TRAP: HV_FAST_TRAP
  2080. * FUNCTION: HV_FAST_PCI_MSI_GETMSIQ
  2081. * ARG0: devhandle
  2082. * ARG1: msinum
  2083. * RET0: status
  2084. * RET1: msiqid
  2085. * ERRORS: EINVAL Invalid devhandle or msinum or MSI is unbound
  2086. *
  2087. * Get the MSI EQ that the MSI defined by the given devhandle and
  2088. * msinum is bound to.
  2089. */
  2090. #define HV_FAST_PCI_MSI_GETMSIQ 0xcb
  2091. /* pci_msi_setmsiq()
  2092. * TRAP: HV_FAST_TRAP
  2093. * FUNCTION: HV_FAST_PCI_MSI_SETMSIQ
  2094. * ARG0: devhandle
  2095. * ARG1: msinum
  2096. * ARG2: msitype
  2097. * ARG3: msiqid
  2098. * RET0: status
  2099. * ERRORS: EINVAL Invalid devhandle or msinum or msiqid
  2100. *
  2101. * Set the MSI EQ that the MSI defined by the given devhandle and
  2102. * msinum is bound to.
  2103. */
  2104. #define HV_FAST_PCI_MSI_SETMSIQ 0xcc
  2105. /* pci_msi_getstate()
  2106. * TRAP: HV_FAST_TRAP
  2107. * FUNCTION: HV_FAST_PCI_MSI_GETSTATE
  2108. * ARG0: devhandle
  2109. * ARG1: msinum
  2110. * RET0: status
  2111. * RET1: msistate
  2112. * ERRORS: EINVAL Invalid devhandle or msinum
  2113. *
  2114. * Get the state of the MSI defined by the given devhandle and msinum.
  2115. * If not initialized, return HV_MSISTATE_IDLE.
  2116. */
  2117. #define HV_FAST_PCI_MSI_GETSTATE 0xcd
  2118. /* pci_msi_setstate()
  2119. * TRAP: HV_FAST_TRAP
  2120. * FUNCTION: HV_FAST_PCI_MSI_SETSTATE
  2121. * ARG0: devhandle
  2122. * ARG1: msinum
  2123. * ARG2: msistate
  2124. * RET0: status
  2125. * ERRORS: EINVAL Invalid devhandle or msinum or msistate
  2126. *
  2127. * Set the state of the MSI defined by the given devhandle and msinum.
  2128. */
  2129. #define HV_FAST_PCI_MSI_SETSTATE 0xce
  2130. /* pci_msg_getmsiq()
  2131. * TRAP: HV_FAST_TRAP
  2132. * FUNCTION: HV_FAST_PCI_MSG_GETMSIQ
  2133. * ARG0: devhandle
  2134. * ARG1: msgtype
  2135. * RET0: status
  2136. * RET1: msiqid
  2137. * ERRORS: EINVAL Invalid devhandle or msgtype
  2138. *
  2139. * Get the MSI EQ of the MSG defined by the given devhandle and msgtype.
  2140. */
  2141. #define HV_FAST_PCI_MSG_GETMSIQ 0xd0
  2142. /* pci_msg_setmsiq()
  2143. * TRAP: HV_FAST_TRAP
  2144. * FUNCTION: HV_FAST_PCI_MSG_SETMSIQ
  2145. * ARG0: devhandle
  2146. * ARG1: msgtype
  2147. * ARG2: msiqid
  2148. * RET0: status
  2149. * ERRORS: EINVAL Invalid devhandle, msgtype, or msiqid
  2150. *
  2151. * Set the MSI EQ of the MSG defined by the given devhandle and msgtype.
  2152. */
  2153. #define HV_FAST_PCI_MSG_SETMSIQ 0xd1
  2154. /* pci_msg_getvalid()
  2155. * TRAP: HV_FAST_TRAP
  2156. * FUNCTION: HV_FAST_PCI_MSG_GETVALID
  2157. * ARG0: devhandle
  2158. * ARG1: msgtype
  2159. * RET0: status
  2160. * RET1: msgvalidstate
  2161. * ERRORS: EINVAL Invalid devhandle or msgtype
  2162. *
  2163. * Get the valid/enabled state of the MSG defined by the given
  2164. * devhandle and msgtype.
  2165. */
  2166. #define HV_FAST_PCI_MSG_GETVALID 0xd2
  2167. /* pci_msg_setvalid()
  2168. * TRAP: HV_FAST_TRAP
  2169. * FUNCTION: HV_FAST_PCI_MSG_SETVALID
  2170. * ARG0: devhandle
  2171. * ARG1: msgtype
  2172. * ARG2: msgvalidstate
  2173. * RET0: status
  2174. * ERRORS: EINVAL Invalid devhandle or msgtype or msgvalidstate
  2175. *
  2176. * Set the valid/enabled state of the MSG defined by the given
  2177. * devhandle and msgtype.
  2178. */
  2179. #define HV_FAST_PCI_MSG_SETVALID 0xd3
  2180. /* Logical Domain Channel services. */
  2181. #define LDC_CHANNEL_DOWN 0
  2182. #define LDC_CHANNEL_UP 1
  2183. #define LDC_CHANNEL_RESETTING 2
  2184. /* ldc_tx_qconf()
  2185. * TRAP: HV_FAST_TRAP
  2186. * FUNCTION: HV_FAST_LDC_TX_QCONF
  2187. * ARG0: channel ID
  2188. * ARG1: real address base of queue
  2189. * ARG2: num entries in queue
  2190. * RET0: status
  2191. *
  2192. * Configure transmit queue for the LDC endpoint specified by the
  2193. * given channel ID, to be placed at the given real address, and
  2194. * be of the given num entries. Num entries must be a power of two.
  2195. * The real address base of the queue must be aligned on the queue
  2196. * size. Each queue entry is 64-bytes, so for example, a 32 entry
  2197. * queue must be aligned on a 2048 byte real address boundary.
  2198. *
  2199. * Upon configuration of a valid transmit queue the head and tail
  2200. * pointers are set to a hypervisor specific identical value indicating
  2201. * that the queue initially is empty.
  2202. *
  2203. * The endpoint's transmit queue is un-configured if num entries is zero.
  2204. *
  2205. * The maximum number of entries for each queue for a specific cpu may be
  2206. * determined from the machine description. A transmit queue may be
  2207. * specified even in the event that the LDC is down (peer endpoint has no
  2208. * receive queue specified). Transmission will begin as soon as the peer
  2209. * endpoint defines a receive queue.
  2210. *
  2211. * It is recommended that a guest wait for a transmit queue to empty prior
  2212. * to reconfiguring it, or un-configuring it. Re or un-configuring of a
  2213. * non-empty transmit queue behaves exactly as defined above, however it
  2214. * is undefined as to how many of the pending entries in the original queue
  2215. * will be delivered prior to the re-configuration taking effect.
  2216. * Furthermore, as the queue configuration causes a reset of the head and
  2217. * tail pointers there is no way for a guest to determine how many entries
  2218. * have been sent after the configuration operation.
  2219. */
  2220. #define HV_FAST_LDC_TX_QCONF 0xe0
  2221. /* ldc_tx_qinfo()
  2222. * TRAP: HV_FAST_TRAP
  2223. * FUNCTION: HV_FAST_LDC_TX_QINFO
  2224. * ARG0: channel ID
  2225. * RET0: status
  2226. * RET1: real address base of queue
  2227. * RET2: num entries in queue
  2228. *
  2229. * Return the configuration info for the transmit queue of LDC endpoint
  2230. * defined by the given channel ID. The real address is the currently
  2231. * defined real address base of the defined queue, and num entries is the
  2232. * size of the queue in terms of number of entries.
  2233. *
  2234. * If the specified channel ID is a valid endpoint number, but no transmit
  2235. * queue has been defined this service will return success, but with num
  2236. * entries set to zero and the real address will have an undefined value.
  2237. */
  2238. #define HV_FAST_LDC_TX_QINFO 0xe1
  2239. /* ldc_tx_get_state()
  2240. * TRAP: HV_FAST_TRAP
  2241. * FUNCTION: HV_FAST_LDC_TX_GET_STATE
  2242. * ARG0: channel ID
  2243. * RET0: status
  2244. * RET1: head offset
  2245. * RET2: tail offset
  2246. * RET3: channel state
  2247. *
  2248. * Return the transmit state, and the head and tail queue pointers, for
  2249. * the transmit queue of the LDC endpoint defined by the given channel ID.
  2250. * The head and tail values are the byte offset of the head and tail
  2251. * positions of the transmit queue for the specified endpoint.
  2252. */
  2253. #define HV_FAST_LDC_TX_GET_STATE 0xe2
  2254. /* ldc_tx_set_qtail()
  2255. * TRAP: HV_FAST_TRAP
  2256. * FUNCTION: HV_FAST_LDC_TX_SET_QTAIL
  2257. * ARG0: channel ID
  2258. * ARG1: tail offset
  2259. * RET0: status
  2260. *
  2261. * Update the tail pointer for the transmit queue associated with the LDC
  2262. * endpoint defined by the given channel ID. The tail offset specified
  2263. * must be aligned on a 64 byte boundary, and calculated so as to increase
  2264. * the number of pending entries on the transmit queue. Any attempt to
  2265. * decrease the number of pending transmit queue entires is considered
  2266. * an invalid tail offset and will result in an EINVAL error.
  2267. *
  2268. * Since the tail of the transmit queue may not be moved backwards, the
  2269. * transmit queue may be flushed by configuring a new transmit queue,
  2270. * whereupon the hypervisor will configure the initial transmit head and
  2271. * tail pointers to be equal.
  2272. */
  2273. #define HV_FAST_LDC_TX_SET_QTAIL 0xe3
  2274. /* ldc_rx_qconf()
  2275. * TRAP: HV_FAST_TRAP
  2276. * FUNCTION: HV_FAST_LDC_RX_QCONF
  2277. * ARG0: channel ID
  2278. * ARG1: real address base of queue
  2279. * ARG2: num entries in queue
  2280. * RET0: status
  2281. *
  2282. * Configure receive queue for the LDC endpoint specified by the
  2283. * given channel ID, to be placed at the given real address, and
  2284. * be of the given num entries. Num entries must be a power of two.
  2285. * The real address base of the queue must be aligned on the queue
  2286. * size. Each queue entry is 64-bytes, so for example, a 32 entry
  2287. * queue must be aligned on a 2048 byte real address boundary.
  2288. *
  2289. * The endpoint's transmit queue is un-configured if num entries is zero.
  2290. *
  2291. * If a valid receive queue is specified for a local endpoint the LDC is
  2292. * in the up state for the purpose of transmission to this endpoint.
  2293. *
  2294. * The maximum number of entries for each queue for a specific cpu may be
  2295. * determined from the machine description.
  2296. *
  2297. * As receive queue configuration causes a reset of the queue's head and
  2298. * tail pointers there is no way for a gues to determine how many entries
  2299. * have been received between a preceeding ldc_get_rx_state() API call
  2300. * and the completion of the configuration operation. It should be noted
  2301. * that datagram delivery is not guarenteed via domain channels anyway,
  2302. * and therefore any higher protocol should be resilient to datagram
  2303. * loss if necessary. However, to overcome this specific race potential
  2304. * it is recommended, for example, that a higher level protocol be employed
  2305. * to ensure either retransmission, or ensure that no datagrams are pending
  2306. * on the peer endpoint's transmit queue prior to the configuration process.
  2307. */
  2308. #define HV_FAST_LDC_RX_QCONF 0xe4
  2309. /* ldc_rx_qinfo()
  2310. * TRAP: HV_FAST_TRAP
  2311. * FUNCTION: HV_FAST_LDC_RX_QINFO
  2312. * ARG0: channel ID
  2313. * RET0: status
  2314. * RET1: real address base of queue
  2315. * RET2: num entries in queue
  2316. *
  2317. * Return the configuration info for the receive queue of LDC endpoint
  2318. * defined by the given channel ID. The real address is the currently
  2319. * defined real address base of the defined queue, and num entries is the
  2320. * size of the queue in terms of number of entries.
  2321. *
  2322. * If the specified channel ID is a valid endpoint number, but no receive
  2323. * queue has been defined this service will return success, but with num
  2324. * entries set to zero and the real address will have an undefined value.
  2325. */
  2326. #define HV_FAST_LDC_RX_QINFO 0xe5
  2327. /* ldc_rx_get_state()
  2328. * TRAP: HV_FAST_TRAP
  2329. * FUNCTION: HV_FAST_LDC_RX_GET_STATE
  2330. * ARG0: channel ID
  2331. * RET0: status
  2332. * RET1: head offset
  2333. * RET2: tail offset
  2334. * RET3: channel state
  2335. *
  2336. * Return the receive state, and the head and tail queue pointers, for
  2337. * the receive queue of the LDC endpoint defined by the given channel ID.
  2338. * The head and tail values are the byte offset of the head and tail
  2339. * positions of the receive queue for the specified endpoint.
  2340. */
  2341. #define HV_FAST_LDC_RX_GET_STATE 0xe6
  2342. /* ldc_rx_set_qhead()
  2343. * TRAP: HV_FAST_TRAP
  2344. * FUNCTION: HV_FAST_LDC_RX_SET_QHEAD
  2345. * ARG0: channel ID
  2346. * ARG1: head offset
  2347. * RET0: status
  2348. *
  2349. * Update the head pointer for the receive queue associated with the LDC
  2350. * endpoint defined by the given channel ID. The head offset specified
  2351. * must be aligned on a 64 byte boundary, and calculated so as to decrease
  2352. * the number of pending entries on the receive queue. Any attempt to
  2353. * increase the number of pending receive queue entires is considered
  2354. * an invalid head offset and will result in an EINVAL error.
  2355. *
  2356. * The receive queue may be flushed by setting the head offset equal
  2357. * to the current tail offset.
  2358. */
  2359. #define HV_FAST_LDC_RX_SET_QHEAD 0xe7
  2360. /* LDC Map Table Entry. Each slot is defined by a translation table
  2361. * entry, as specified by the LDC_MTE_* bits below, and a 64-bit
  2362. * hypervisor invalidation cookie.
  2363. */
  2364. #define LDC_MTE_PADDR 0x0fffffffffffe000 /* pa[55:13] */
  2365. #define LDC_MTE_COPY_W 0x0000000000000400 /* copy write access */
  2366. #define LDC_MTE_COPY_R 0x0000000000000200 /* copy read access */
  2367. #define LDC_MTE_IOMMU_W 0x0000000000000100 /* IOMMU write access */
  2368. #define LDC_MTE_IOMMU_R 0x0000000000000080 /* IOMMU read access */
  2369. #define LDC_MTE_EXEC 0x0000000000000040 /* execute */
  2370. #define LDC_MTE_WRITE 0x0000000000000020 /* read */
  2371. #define LDC_MTE_READ 0x0000000000000010 /* write */
  2372. #define LDC_MTE_SZALL 0x000000000000000f /* page size bits */
  2373. #define LDC_MTE_SZ16GB 0x0000000000000007 /* 16GB page */
  2374. #define LDC_MTE_SZ2GB 0x0000000000000006 /* 2GB page */
  2375. #define LDC_MTE_SZ256MB 0x0000000000000005 /* 256MB page */
  2376. #define LDC_MTE_SZ32MB 0x0000000000000004 /* 32MB page */
  2377. #define LDC_MTE_SZ4MB 0x0000000000000003 /* 4MB page */
  2378. #define LDC_MTE_SZ512K 0x0000000000000002 /* 512K page */
  2379. #define LDC_MTE_SZ64K 0x0000000000000001 /* 64K page */
  2380. #define LDC_MTE_SZ8K 0x0000000000000000 /* 8K page */
  2381. #ifndef __ASSEMBLY__
  2382. struct ldc_mtable_entry {
  2383. unsigned long mte;
  2384. unsigned long cookie;
  2385. };
  2386. #endif
  2387. /* ldc_set_map_table()
  2388. * TRAP: HV_FAST_TRAP
  2389. * FUNCTION: HV_FAST_LDC_SET_MAP_TABLE
  2390. * ARG0: channel ID
  2391. * ARG1: table real address
  2392. * ARG2: num entries
  2393. * RET0: status
  2394. *
  2395. * Register the MTE table at the given table real address, with the
  2396. * specified num entries, for the LDC indicated by the given channel
  2397. * ID.
  2398. */
  2399. #define HV_FAST_LDC_SET_MAP_TABLE 0xea
  2400. /* ldc_get_map_table()
  2401. * TRAP: HV_FAST_TRAP
  2402. * FUNCTION: HV_FAST_LDC_GET_MAP_TABLE
  2403. * ARG0: channel ID
  2404. * RET0: status
  2405. * RET1: table real address
  2406. * RET2: num entries
  2407. *
  2408. * Return the configuration of the current mapping table registered
  2409. * for the given channel ID.
  2410. */
  2411. #define HV_FAST_LDC_GET_MAP_TABLE 0xeb
  2412. #define LDC_COPY_IN 0
  2413. #define LDC_COPY_OUT 1
  2414. /* ldc_copy()
  2415. * TRAP: HV_FAST_TRAP
  2416. * FUNCTION: HV_FAST_LDC_COPY
  2417. * ARG0: channel ID
  2418. * ARG1: LDC_COPY_* direction code
  2419. * ARG2: target real address
  2420. * ARG3: local real address
  2421. * ARG4: length in bytes
  2422. * RET0: status
  2423. * RET1: actual length in bytes
  2424. */
  2425. #define HV_FAST_LDC_COPY 0xec
  2426. #define LDC_MEM_READ 1
  2427. #define LDC_MEM_WRITE 2
  2428. #define LDC_MEM_EXEC 4
  2429. /* ldc_mapin()
  2430. * TRAP: HV_FAST_TRAP
  2431. * FUNCTION: HV_FAST_LDC_MAPIN
  2432. * ARG0: channel ID
  2433. * ARG1: cookie
  2434. * RET0: status
  2435. * RET1: real address
  2436. * RET2: LDC_MEM_* permissions
  2437. */
  2438. #define HV_FAST_LDC_MAPIN 0xed
  2439. /* ldc_unmap()
  2440. * TRAP: HV_FAST_TRAP
  2441. * FUNCTION: HV_FAST_LDC_UNMAP
  2442. * ARG0: real address
  2443. * RET0: status
  2444. */
  2445. #define HV_FAST_LDC_UNMAP 0xee
  2446. /* ldc_revoke()
  2447. * TRAP: HV_FAST_TRAP
  2448. * FUNCTION: HV_FAST_LDC_REVOKE
  2449. * ARG0: channel ID
  2450. * ARG1: cookie
  2451. * ARG2: ldc_mtable_entry cookie
  2452. * RET0: status
  2453. */
  2454. #define HV_FAST_LDC_REVOKE 0xef
  2455. #ifndef __ASSEMBLY__
  2456. extern unsigned long sun4v_ldc_tx_qconf(unsigned long channel,
  2457. unsigned long ra,
  2458. unsigned long num_entries);
  2459. extern unsigned long sun4v_ldc_tx_qinfo(unsigned long channel,
  2460. unsigned long *ra,
  2461. unsigned long *num_entries);
  2462. extern unsigned long sun4v_ldc_tx_get_state(unsigned long channel,
  2463. unsigned long *head_off,
  2464. unsigned long *tail_off,
  2465. unsigned long *chan_state);
  2466. extern unsigned long sun4v_ldc_tx_set_qtail(unsigned long channel,
  2467. unsigned long tail_off);
  2468. extern unsigned long sun4v_ldc_rx_qconf(unsigned long channel,
  2469. unsigned long ra,
  2470. unsigned long num_entries);
  2471. extern unsigned long sun4v_ldc_rx_qinfo(unsigned long channel,
  2472. unsigned long *ra,
  2473. unsigned long *num_entries);
  2474. extern unsigned long sun4v_ldc_rx_get_state(unsigned long channel,
  2475. unsigned long *head_off,
  2476. unsigned long *tail_off,
  2477. unsigned long *chan_state);
  2478. extern unsigned long sun4v_ldc_rx_set_qhead(unsigned long channel,
  2479. unsigned long head_off);
  2480. extern unsigned long sun4v_ldc_set_map_table(unsigned long channel,
  2481. unsigned long ra,
  2482. unsigned long num_entries);
  2483. extern unsigned long sun4v_ldc_get_map_table(unsigned long channel,
  2484. unsigned long *ra,
  2485. unsigned long *num_entries);
  2486. extern unsigned long sun4v_ldc_copy(unsigned long channel,
  2487. unsigned long dir_code,
  2488. unsigned long tgt_raddr,
  2489. unsigned long lcl_raddr,
  2490. unsigned long len,
  2491. unsigned long *actual_len);
  2492. extern unsigned long sun4v_ldc_mapin(unsigned long channel,
  2493. unsigned long cookie,
  2494. unsigned long *ra,
  2495. unsigned long *perm);
  2496. extern unsigned long sun4v_ldc_unmap(unsigned long ra);
  2497. extern unsigned long sun4v_ldc_revoke(unsigned long channel,
  2498. unsigned long cookie,
  2499. unsigned long mte_cookie);
  2500. #endif
  2501. /* Performance counter services. */
  2502. #define HV_PERF_JBUS_PERF_CTRL_REG 0x00
  2503. #define HV_PERF_JBUS_PERF_CNT_REG 0x01
  2504. #define HV_PERF_DRAM_PERF_CTRL_REG_0 0x02
  2505. #define HV_PERF_DRAM_PERF_CNT_REG_0 0x03
  2506. #define HV_PERF_DRAM_PERF_CTRL_REG_1 0x04
  2507. #define HV_PERF_DRAM_PERF_CNT_REG_1 0x05
  2508. #define HV_PERF_DRAM_PERF_CTRL_REG_2 0x06
  2509. #define HV_PERF_DRAM_PERF_CNT_REG_2 0x07
  2510. #define HV_PERF_DRAM_PERF_CTRL_REG_3 0x08
  2511. #define HV_PERF_DRAM_PERF_CNT_REG_3 0x09
  2512. /* get_perfreg()
  2513. * TRAP: HV_FAST_TRAP
  2514. * FUNCTION: HV_FAST_GET_PERFREG
  2515. * ARG0: performance reg number
  2516. * RET0: status
  2517. * RET1: performance reg value
  2518. * ERRORS: EINVAL Invalid performance register number
  2519. * ENOACCESS No access allowed to performance counters
  2520. *
  2521. * Read the value of the given DRAM/JBUS performance counter/control register.
  2522. */
  2523. #define HV_FAST_GET_PERFREG 0x100
  2524. /* set_perfreg()
  2525. * TRAP: HV_FAST_TRAP
  2526. * FUNCTION: HV_FAST_SET_PERFREG
  2527. * ARG0: performance reg number
  2528. * ARG1: performance reg value
  2529. * RET0: status
  2530. * ERRORS: EINVAL Invalid performance register number
  2531. * ENOACCESS No access allowed to performance counters
  2532. *
  2533. * Write the given performance reg value to the given DRAM/JBUS
  2534. * performance counter/control register.
  2535. */
  2536. #define HV_FAST_SET_PERFREG 0x101
  2537. /* MMU statistics services.
  2538. *
  2539. * The hypervisor maintains MMU statistics and privileged code provides
  2540. * a buffer where these statistics can be collected. It is continually
  2541. * updated once configured. The layout is as follows:
  2542. */
  2543. #ifndef __ASSEMBLY__
  2544. struct hv_mmu_statistics {
  2545. unsigned long immu_tsb_hits_ctx0_8k_tte;
  2546. unsigned long immu_tsb_ticks_ctx0_8k_tte;
  2547. unsigned long immu_tsb_hits_ctx0_64k_tte;
  2548. unsigned long immu_tsb_ticks_ctx0_64k_tte;
  2549. unsigned long __reserved1[2];
  2550. unsigned long immu_tsb_hits_ctx0_4mb_tte;
  2551. unsigned long immu_tsb_ticks_ctx0_4mb_tte;
  2552. unsigned long __reserved2[2];
  2553. unsigned long immu_tsb_hits_ctx0_256mb_tte;
  2554. unsigned long immu_tsb_ticks_ctx0_256mb_tte;
  2555. unsigned long __reserved3[4];
  2556. unsigned long immu_tsb_hits_ctxnon0_8k_tte;
  2557. unsigned long immu_tsb_ticks_ctxnon0_8k_tte;
  2558. unsigned long immu_tsb_hits_ctxnon0_64k_tte;
  2559. unsigned long immu_tsb_ticks_ctxnon0_64k_tte;
  2560. unsigned long __reserved4[2];
  2561. unsigned long immu_tsb_hits_ctxnon0_4mb_tte;
  2562. unsigned long immu_tsb_ticks_ctxnon0_4mb_tte;
  2563. unsigned long __reserved5[2];
  2564. unsigned long immu_tsb_hits_ctxnon0_256mb_tte;
  2565. unsigned long immu_tsb_ticks_ctxnon0_256mb_tte;
  2566. unsigned long __reserved6[4];
  2567. unsigned long dmmu_tsb_hits_ctx0_8k_tte;
  2568. unsigned long dmmu_tsb_ticks_ctx0_8k_tte;
  2569. unsigned long dmmu_tsb_hits_ctx0_64k_tte;
  2570. unsigned long dmmu_tsb_ticks_ctx0_64k_tte;
  2571. unsigned long __reserved7[2];
  2572. unsigned long dmmu_tsb_hits_ctx0_4mb_tte;
  2573. unsigned long dmmu_tsb_ticks_ctx0_4mb_tte;
  2574. unsigned long __reserved8[2];
  2575. unsigned long dmmu_tsb_hits_ctx0_256mb_tte;
  2576. unsigned long dmmu_tsb_ticks_ctx0_256mb_tte;
  2577. unsigned long __reserved9[4];
  2578. unsigned long dmmu_tsb_hits_ctxnon0_8k_tte;
  2579. unsigned long dmmu_tsb_ticks_ctxnon0_8k_tte;
  2580. unsigned long dmmu_tsb_hits_ctxnon0_64k_tte;
  2581. unsigned long dmmu_tsb_ticks_ctxnon0_64k_tte;
  2582. unsigned long __reserved10[2];
  2583. unsigned long dmmu_tsb_hits_ctxnon0_4mb_tte;
  2584. unsigned long dmmu_tsb_ticks_ctxnon0_4mb_tte;
  2585. unsigned long __reserved11[2];
  2586. unsigned long dmmu_tsb_hits_ctxnon0_256mb_tte;
  2587. unsigned long dmmu_tsb_ticks_ctxnon0_256mb_tte;
  2588. unsigned long __reserved12[4];
  2589. };
  2590. #endif
  2591. /* mmustat_conf()
  2592. * TRAP: HV_FAST_TRAP
  2593. * FUNCTION: HV_FAST_MMUSTAT_CONF
  2594. * ARG0: real address
  2595. * RET0: status
  2596. * RET1: real address
  2597. * ERRORS: ENORADDR Invalid real address
  2598. * EBADALIGN Real address not aligned on 64-byte boundary
  2599. * EBADTRAP API not supported on this processor
  2600. *
  2601. * Enable MMU statistic gathering using the buffer at the given real
  2602. * address on the current virtual CPU. The new buffer real address
  2603. * is given in ARG1, and the previously specified buffer real address
  2604. * is returned in RET1, or is returned as zero for the first invocation.
  2605. *
  2606. * If the passed in real address argument is zero, this will disable
  2607. * MMU statistic collection on the current virtual CPU. If an error is
  2608. * returned then no statistics are collected.
  2609. *
  2610. * The buffer contents should be initialized to all zeros before being
  2611. * given to the hypervisor or else the statistics will be meaningless.
  2612. */
  2613. #define HV_FAST_MMUSTAT_CONF 0x102
  2614. /* mmustat_info()
  2615. * TRAP: HV_FAST_TRAP
  2616. * FUNCTION: HV_FAST_MMUSTAT_INFO
  2617. * RET0: status
  2618. * RET1: real address
  2619. * ERRORS: EBADTRAP API not supported on this processor
  2620. *
  2621. * Return the current state and real address of the currently configured
  2622. * MMU statistics buffer on the current virtual CPU.
  2623. */
  2624. #define HV_FAST_MMUSTAT_INFO 0x103
  2625. #ifndef __ASSEMBLY__
  2626. extern unsigned long sun4v_mmustat_conf(unsigned long ra, unsigned long *orig_ra);
  2627. extern unsigned long sun4v_mmustat_info(unsigned long *ra);
  2628. #endif
  2629. /* NCS crypto services */
  2630. /* ncs_request() sub-function numbers */
  2631. #define HV_NCS_QCONF 0x01
  2632. #define HV_NCS_QTAIL_UPDATE 0x02
  2633. #ifndef __ASSEMBLY__
  2634. struct hv_ncs_queue_entry {
  2635. /* MAU Control Register */
  2636. unsigned long mau_control;
  2637. #define MAU_CONTROL_INV_PARITY 0x0000000000002000
  2638. #define MAU_CONTROL_STRAND 0x0000000000001800
  2639. #define MAU_CONTROL_BUSY 0x0000000000000400
  2640. #define MAU_CONTROL_INT 0x0000000000000200
  2641. #define MAU_CONTROL_OP 0x00000000000001c0
  2642. #define MAU_CONTROL_OP_SHIFT 6
  2643. #define MAU_OP_LOAD_MA_MEMORY 0x0
  2644. #define MAU_OP_STORE_MA_MEMORY 0x1
  2645. #define MAU_OP_MODULAR_MULT 0x2
  2646. #define MAU_OP_MODULAR_REDUCE 0x3
  2647. #define MAU_OP_MODULAR_EXP_LOOP 0x4
  2648. #define MAU_CONTROL_LEN 0x000000000000003f
  2649. #define MAU_CONTROL_LEN_SHIFT 0
  2650. /* Real address of bytes to load or store bytes
  2651. * into/out-of the MAU.
  2652. */
  2653. unsigned long mau_mpa;
  2654. /* Modular Arithmetic MA Offset Register. */
  2655. unsigned long mau_ma;
  2656. /* Modular Arithmetic N Prime Register. */
  2657. unsigned long mau_np;
  2658. };
  2659. struct hv_ncs_qconf_arg {
  2660. unsigned long mid; /* MAU ID, 1 per core on Niagara */
  2661. unsigned long base; /* Real address base of queue */
  2662. unsigned long end; /* Real address end of queue */
  2663. unsigned long num_ents; /* Number of entries in queue */
  2664. };
  2665. struct hv_ncs_qtail_update_arg {
  2666. unsigned long mid; /* MAU ID, 1 per core on Niagara */
  2667. unsigned long tail; /* New tail index to use */
  2668. unsigned long syncflag; /* only SYNCFLAG_SYNC is implemented */
  2669. #define HV_NCS_SYNCFLAG_SYNC 0x00
  2670. #define HV_NCS_SYNCFLAG_ASYNC 0x01
  2671. };
  2672. #endif
  2673. /* ncs_request()
  2674. * TRAP: HV_FAST_TRAP
  2675. * FUNCTION: HV_FAST_NCS_REQUEST
  2676. * ARG0: NCS sub-function
  2677. * ARG1: sub-function argument real address
  2678. * ARG2: size in bytes of sub-function argument
  2679. * RET0: status
  2680. *
  2681. * The MAU chip of the Niagara processor is not directly accessible
  2682. * to privileged code, instead it is programmed indirectly via this
  2683. * hypervisor API.
  2684. *
  2685. * The interfaces defines a queue of MAU operations to perform.
  2686. * Privileged code registers a queue with the hypervisor by invoking
  2687. * this HVAPI with the HV_NCS_QCONF sub-function, which defines the
  2688. * base, end, and number of entries of the queue. Each queue entry
  2689. * contains a MAU register struct block.
  2690. *
  2691. * The privileged code then proceeds to add entries to the queue and
  2692. * then invoke the HV_NCS_QTAIL_UPDATE sub-function. Since only
  2693. * synchronous operations are supported by the current hypervisor,
  2694. * HV_NCS_QTAIL_UPDATE will run all the pending queue entries to
  2695. * completion and return HV_EOK, or return an error code.
  2696. *
  2697. * The real address of the sub-function argument must be aligned on at
  2698. * least an 8-byte boundary.
  2699. *
  2700. * The tail argument of HV_NCS_QTAIL_UPDATE is an index, not a byte
  2701. * offset, into the queue and must be less than or equal the 'num_ents'
  2702. * argument given in the HV_NCS_QCONF call.
  2703. */
  2704. #define HV_FAST_NCS_REQUEST 0x110
  2705. #ifndef __ASSEMBLY__
  2706. extern unsigned long sun4v_ncs_request(unsigned long request,
  2707. unsigned long arg_ra,
  2708. unsigned long arg_size);
  2709. #endif
  2710. #define HV_FAST_FIRE_GET_PERFREG 0x120
  2711. #define HV_FAST_FIRE_SET_PERFREG 0x121
  2712. /* Function numbers for HV_CORE_TRAP. */
  2713. #define HV_CORE_SET_VER 0x00
  2714. #define HV_CORE_PUTCHAR 0x01
  2715. #define HV_CORE_EXIT 0x02
  2716. #define HV_CORE_GET_VER 0x03
  2717. /* Hypervisor API groups for use with HV_CORE_SET_VER and
  2718. * HV_CORE_GET_VER.
  2719. */
  2720. #define HV_GRP_SUN4V 0x0000
  2721. #define HV_GRP_CORE 0x0001
  2722. #define HV_GRP_INTR 0x0002
  2723. #define HV_GRP_SOFT_STATE 0x0003
  2724. #define HV_GRP_PCI 0x0100
  2725. #define HV_GRP_LDOM 0x0101
  2726. #define HV_GRP_SVC_CHAN 0x0102
  2727. #define HV_GRP_NCS 0x0103
  2728. #define HV_GRP_RNG 0x0104
  2729. #define HV_GRP_NIAG_PERF 0x0200
  2730. #define HV_GRP_FIRE_PERF 0x0201
  2731. #define HV_GRP_N2_CPU 0x0202
  2732. #define HV_GRP_NIU 0x0204
  2733. #define HV_GRP_VF_CPU 0x0205
  2734. #define HV_GRP_DIAG 0x0300
  2735. #ifndef __ASSEMBLY__
  2736. extern unsigned long sun4v_get_version(unsigned long group,
  2737. unsigned long *major,
  2738. unsigned long *minor);
  2739. extern unsigned long sun4v_set_version(unsigned long group,
  2740. unsigned long major,
  2741. unsigned long minor,
  2742. unsigned long *actual_minor);
  2743. extern int sun4v_hvapi_register(unsigned long group, unsigned long major,
  2744. unsigned long *minor);
  2745. extern void sun4v_hvapi_unregister(unsigned long group);
  2746. extern int sun4v_hvapi_get(unsigned long group,
  2747. unsigned long *major,
  2748. unsigned long *minor);
  2749. extern void sun4v_hvapi_init(void);
  2750. #endif
  2751. #endif /* !(_SPARC64_HYPERVISOR_H) */