hypervisor.h 98 KB

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