hypervisor.h 115 KB

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