hypervisor.h 115 KB

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