sn_sal.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. #ifndef _ASM_IA64_SN_SN_SAL_H
  2. #define _ASM_IA64_SN_SN_SAL_H
  3. /*
  4. * System Abstraction Layer definitions for IA64
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. *
  10. * Copyright (c) 2000-2006 Silicon Graphics, Inc. All rights reserved.
  11. */
  12. #include <asm/sal.h>
  13. #include <asm/sn/sn_cpuid.h>
  14. #include <asm/sn/arch.h>
  15. #include <asm/sn/geo.h>
  16. #include <asm/sn/nodepda.h>
  17. #include <asm/sn/shub_mmr.h>
  18. // SGI Specific Calls
  19. #define SN_SAL_POD_MODE 0x02000001
  20. #define SN_SAL_SYSTEM_RESET 0x02000002
  21. #define SN_SAL_PROBE 0x02000003
  22. #define SN_SAL_GET_MASTER_NASID 0x02000004
  23. #define SN_SAL_GET_KLCONFIG_ADDR 0x02000005
  24. #define SN_SAL_LOG_CE 0x02000006
  25. #define SN_SAL_REGISTER_CE 0x02000007
  26. #define SN_SAL_GET_PARTITION_ADDR 0x02000009
  27. #define SN_SAL_XP_ADDR_REGION 0x0200000f
  28. #define SN_SAL_NO_FAULT_ZONE_VIRTUAL 0x02000010
  29. #define SN_SAL_NO_FAULT_ZONE_PHYSICAL 0x02000011
  30. #define SN_SAL_PRINT_ERROR 0x02000012
  31. #define SN_SAL_REGISTER_PMI_HANDLER 0x02000014
  32. #define SN_SAL_SET_ERROR_HANDLING_FEATURES 0x0200001a // reentrant
  33. #define SN_SAL_GET_FIT_COMPT 0x0200001b // reentrant
  34. #define SN_SAL_GET_SAPIC_INFO 0x0200001d
  35. #define SN_SAL_GET_SN_INFO 0x0200001e
  36. #define SN_SAL_CONSOLE_PUTC 0x02000021
  37. #define SN_SAL_CONSOLE_GETC 0x02000022
  38. #define SN_SAL_CONSOLE_PUTS 0x02000023
  39. #define SN_SAL_CONSOLE_GETS 0x02000024
  40. #define SN_SAL_CONSOLE_GETS_TIMEOUT 0x02000025
  41. #define SN_SAL_CONSOLE_POLL 0x02000026
  42. #define SN_SAL_CONSOLE_INTR 0x02000027
  43. #define SN_SAL_CONSOLE_PUTB 0x02000028
  44. #define SN_SAL_CONSOLE_XMIT_CHARS 0x0200002a
  45. #define SN_SAL_CONSOLE_READC 0x0200002b
  46. #define SN_SAL_SYSCTL_OP 0x02000030
  47. #define SN_SAL_SYSCTL_MODID_GET 0x02000031
  48. #define SN_SAL_SYSCTL_GET 0x02000032
  49. #define SN_SAL_SYSCTL_IOBRICK_MODULE_GET 0x02000033
  50. #define SN_SAL_SYSCTL_IO_PORTSPEED_GET 0x02000035
  51. #define SN_SAL_SYSCTL_SLAB_GET 0x02000036
  52. #define SN_SAL_BUS_CONFIG 0x02000037
  53. #define SN_SAL_SYS_SERIAL_GET 0x02000038
  54. #define SN_SAL_PARTITION_SERIAL_GET 0x02000039
  55. #define SN_SAL_SYSCTL_PARTITION_GET 0x0200003a
  56. #define SN_SAL_SYSTEM_POWER_DOWN 0x0200003b
  57. #define SN_SAL_GET_MASTER_BASEIO_NASID 0x0200003c
  58. #define SN_SAL_COHERENCE 0x0200003d
  59. #define SN_SAL_MEMPROTECT 0x0200003e
  60. #define SN_SAL_SYSCTL_FRU_CAPTURE 0x0200003f
  61. #define SN_SAL_SYSCTL_IOBRICK_PCI_OP 0x02000042 // reentrant
  62. #define SN_SAL_IROUTER_OP 0x02000043
  63. #define SN_SAL_SYSCTL_EVENT 0x02000044
  64. #define SN_SAL_IOIF_INTERRUPT 0x0200004a
  65. #define SN_SAL_HWPERF_OP 0x02000050 // lock
  66. #define SN_SAL_IOIF_ERROR_INTERRUPT 0x02000051
  67. #define SN_SAL_IOIF_PCI_SAFE 0x02000052
  68. #define SN_SAL_IOIF_SLOT_ENABLE 0x02000053
  69. #define SN_SAL_IOIF_SLOT_DISABLE 0x02000054
  70. #define SN_SAL_IOIF_GET_HUBDEV_INFO 0x02000055
  71. #define SN_SAL_IOIF_GET_PCIBUS_INFO 0x02000056
  72. #define SN_SAL_IOIF_GET_PCIDEV_INFO 0x02000057
  73. #define SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST 0x02000058 // deprecated
  74. #define SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST 0x0200005a
  75. #define SN_SAL_IOIF_INIT 0x0200005f
  76. #define SN_SAL_HUB_ERROR_INTERRUPT 0x02000060
  77. #define SN_SAL_BTE_RECOVER 0x02000061
  78. #define SN_SAL_RESERVED_DO_NOT_USE 0x02000062
  79. #define SN_SAL_IOIF_GET_PCI_TOPOLOGY 0x02000064
  80. #define SN_SAL_GET_PROM_FEATURE_SET 0x02000065
  81. #define SN_SAL_SET_OS_FEATURE_SET 0x02000066
  82. #define SN_SAL_INJECT_ERROR 0x02000067
  83. #define SN_SAL_SET_CPU_NUMBER 0x02000068
  84. #define SN_SAL_KERNEL_LAUNCH_EVENT 0x02000069
  85. /*
  86. * Service-specific constants
  87. */
  88. /* Console interrupt manipulation */
  89. /* action codes */
  90. #define SAL_CONSOLE_INTR_OFF 0 /* turn the interrupt off */
  91. #define SAL_CONSOLE_INTR_ON 1 /* turn the interrupt on */
  92. #define SAL_CONSOLE_INTR_STATUS 2 /* retrieve the interrupt status */
  93. /* interrupt specification & status return codes */
  94. #define SAL_CONSOLE_INTR_XMIT 1 /* output interrupt */
  95. #define SAL_CONSOLE_INTR_RECV 2 /* input interrupt */
  96. /* interrupt handling */
  97. #define SAL_INTR_ALLOC 1
  98. #define SAL_INTR_FREE 2
  99. #define SAL_INTR_REDIRECT 3
  100. /*
  101. * operations available on the generic SN_SAL_SYSCTL_OP
  102. * runtime service
  103. */
  104. #define SAL_SYSCTL_OP_IOBOARD 0x0001 /* retrieve board type */
  105. #define SAL_SYSCTL_OP_TIO_JLCK_RST 0x0002 /* issue TIO clock reset */
  106. /*
  107. * IRouter (i.e. generalized system controller) operations
  108. */
  109. #define SAL_IROUTER_OPEN 0 /* open a subchannel */
  110. #define SAL_IROUTER_CLOSE 1 /* close a subchannel */
  111. #define SAL_IROUTER_SEND 2 /* send part of an IRouter packet */
  112. #define SAL_IROUTER_RECV 3 /* receive part of an IRouter packet */
  113. #define SAL_IROUTER_INTR_STATUS 4 /* check the interrupt status for
  114. * an open subchannel
  115. */
  116. #define SAL_IROUTER_INTR_ON 5 /* enable an interrupt */
  117. #define SAL_IROUTER_INTR_OFF 6 /* disable an interrupt */
  118. #define SAL_IROUTER_INIT 7 /* initialize IRouter driver */
  119. /* IRouter interrupt mask bits */
  120. #define SAL_IROUTER_INTR_XMIT SAL_CONSOLE_INTR_XMIT
  121. #define SAL_IROUTER_INTR_RECV SAL_CONSOLE_INTR_RECV
  122. /*
  123. * Error Handling Features
  124. */
  125. #define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1 // obsolete
  126. #define SAL_ERR_FEAT_LOG_SBES 0x2 // obsolete
  127. #define SAL_ERR_FEAT_MFR_OVERRIDE 0x4
  128. #define SAL_ERR_FEAT_SBE_THRESHOLD 0xffff0000
  129. /*
  130. * SAL Error Codes
  131. */
  132. #define SALRET_MORE_PASSES 1
  133. #define SALRET_OK 0
  134. #define SALRET_NOT_IMPLEMENTED (-1)
  135. #define SALRET_INVALID_ARG (-2)
  136. #define SALRET_ERROR (-3)
  137. #define SN_SAL_FAKE_PROM 0x02009999
  138. /**
  139. * sn_sal_revision - get the SGI SAL revision number
  140. *
  141. * The SGI PROM stores its version in the sal_[ab]_rev_(major|minor).
  142. * This routine simply extracts the major and minor values and
  143. * presents them in a u32 format.
  144. *
  145. * For example, version 4.05 would be represented at 0x0405.
  146. */
  147. static inline u32
  148. sn_sal_rev(void)
  149. {
  150. struct ia64_sal_systab *systab = __va(efi.sal_systab);
  151. return (u32)(systab->sal_b_rev_major << 8 | systab->sal_b_rev_minor);
  152. }
  153. /*
  154. * Returns the master console nasid, if the call fails, return an illegal
  155. * value.
  156. */
  157. static inline u64
  158. ia64_sn_get_console_nasid(void)
  159. {
  160. struct ia64_sal_retval ret_stuff;
  161. ret_stuff.status = 0;
  162. ret_stuff.v0 = 0;
  163. ret_stuff.v1 = 0;
  164. ret_stuff.v2 = 0;
  165. SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_NASID, 0, 0, 0, 0, 0, 0, 0);
  166. if (ret_stuff.status < 0)
  167. return ret_stuff.status;
  168. /* Master console nasid is in 'v0' */
  169. return ret_stuff.v0;
  170. }
  171. /*
  172. * Returns the master baseio nasid, if the call fails, return an illegal
  173. * value.
  174. */
  175. static inline u64
  176. ia64_sn_get_master_baseio_nasid(void)
  177. {
  178. struct ia64_sal_retval ret_stuff;
  179. ret_stuff.status = 0;
  180. ret_stuff.v0 = 0;
  181. ret_stuff.v1 = 0;
  182. ret_stuff.v2 = 0;
  183. SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_BASEIO_NASID, 0, 0, 0, 0, 0, 0, 0);
  184. if (ret_stuff.status < 0)
  185. return ret_stuff.status;
  186. /* Master baseio nasid is in 'v0' */
  187. return ret_stuff.v0;
  188. }
  189. static inline void *
  190. ia64_sn_get_klconfig_addr(nasid_t nasid)
  191. {
  192. struct ia64_sal_retval ret_stuff;
  193. ret_stuff.status = 0;
  194. ret_stuff.v0 = 0;
  195. ret_stuff.v1 = 0;
  196. ret_stuff.v2 = 0;
  197. SAL_CALL(ret_stuff, SN_SAL_GET_KLCONFIG_ADDR, (u64)nasid, 0, 0, 0, 0, 0, 0);
  198. return ret_stuff.v0 ? __va(ret_stuff.v0) : NULL;
  199. }
  200. /*
  201. * Returns the next console character.
  202. */
  203. static inline u64
  204. ia64_sn_console_getc(int *ch)
  205. {
  206. struct ia64_sal_retval ret_stuff;
  207. ret_stuff.status = 0;
  208. ret_stuff.v0 = 0;
  209. ret_stuff.v1 = 0;
  210. ret_stuff.v2 = 0;
  211. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_GETC, 0, 0, 0, 0, 0, 0, 0);
  212. /* character is in 'v0' */
  213. *ch = (int)ret_stuff.v0;
  214. return ret_stuff.status;
  215. }
  216. /*
  217. * Read a character from the SAL console device, after a previous interrupt
  218. * or poll operation has given us to know that a character is available
  219. * to be read.
  220. */
  221. static inline u64
  222. ia64_sn_console_readc(void)
  223. {
  224. struct ia64_sal_retval ret_stuff;
  225. ret_stuff.status = 0;
  226. ret_stuff.v0 = 0;
  227. ret_stuff.v1 = 0;
  228. ret_stuff.v2 = 0;
  229. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_READC, 0, 0, 0, 0, 0, 0, 0);
  230. /* character is in 'v0' */
  231. return ret_stuff.v0;
  232. }
  233. /*
  234. * Sends the given character to the console.
  235. */
  236. static inline u64
  237. ia64_sn_console_putc(char ch)
  238. {
  239. struct ia64_sal_retval ret_stuff;
  240. ret_stuff.status = 0;
  241. ret_stuff.v0 = 0;
  242. ret_stuff.v1 = 0;
  243. ret_stuff.v2 = 0;
  244. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTC, (u64)ch, 0, 0, 0, 0, 0, 0);
  245. return ret_stuff.status;
  246. }
  247. /*
  248. * Sends the given buffer to the console.
  249. */
  250. static inline u64
  251. ia64_sn_console_putb(const char *buf, int len)
  252. {
  253. struct ia64_sal_retval ret_stuff;
  254. ret_stuff.status = 0;
  255. ret_stuff.v0 = 0;
  256. ret_stuff.v1 = 0;
  257. ret_stuff.v2 = 0;
  258. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTB, (u64)buf, (u64)len, 0, 0, 0, 0, 0);
  259. if ( ret_stuff.status == 0 ) {
  260. return ret_stuff.v0;
  261. }
  262. return (u64)0;
  263. }
  264. /*
  265. * Print a platform error record
  266. */
  267. static inline u64
  268. ia64_sn_plat_specific_err_print(int (*hook)(const char*, ...), char *rec)
  269. {
  270. struct ia64_sal_retval ret_stuff;
  271. ret_stuff.status = 0;
  272. ret_stuff.v0 = 0;
  273. ret_stuff.v1 = 0;
  274. ret_stuff.v2 = 0;
  275. SAL_CALL_REENTRANT(ret_stuff, SN_SAL_PRINT_ERROR, (u64)hook, (u64)rec, 0, 0, 0, 0, 0);
  276. return ret_stuff.status;
  277. }
  278. /*
  279. * Check for Platform errors
  280. */
  281. static inline u64
  282. ia64_sn_plat_cpei_handler(void)
  283. {
  284. struct ia64_sal_retval ret_stuff;
  285. ret_stuff.status = 0;
  286. ret_stuff.v0 = 0;
  287. ret_stuff.v1 = 0;
  288. ret_stuff.v2 = 0;
  289. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_LOG_CE, 0, 0, 0, 0, 0, 0, 0);
  290. return ret_stuff.status;
  291. }
  292. /*
  293. * Set Error Handling Features (Obsolete)
  294. */
  295. static inline u64
  296. ia64_sn_plat_set_error_handling_features(void)
  297. {
  298. struct ia64_sal_retval ret_stuff;
  299. ret_stuff.status = 0;
  300. ret_stuff.v0 = 0;
  301. ret_stuff.v1 = 0;
  302. ret_stuff.v2 = 0;
  303. SAL_CALL_REENTRANT(ret_stuff, SN_SAL_SET_ERROR_HANDLING_FEATURES,
  304. SAL_ERR_FEAT_LOG_SBES,
  305. 0, 0, 0, 0, 0, 0);
  306. return ret_stuff.status;
  307. }
  308. /*
  309. * Checks for console input.
  310. */
  311. static inline u64
  312. ia64_sn_console_check(int *result)
  313. {
  314. struct ia64_sal_retval ret_stuff;
  315. ret_stuff.status = 0;
  316. ret_stuff.v0 = 0;
  317. ret_stuff.v1 = 0;
  318. ret_stuff.v2 = 0;
  319. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_POLL, 0, 0, 0, 0, 0, 0, 0);
  320. /* result is in 'v0' */
  321. *result = (int)ret_stuff.v0;
  322. return ret_stuff.status;
  323. }
  324. /*
  325. * Checks console interrupt status
  326. */
  327. static inline u64
  328. ia64_sn_console_intr_status(void)
  329. {
  330. struct ia64_sal_retval ret_stuff;
  331. ret_stuff.status = 0;
  332. ret_stuff.v0 = 0;
  333. ret_stuff.v1 = 0;
  334. ret_stuff.v2 = 0;
  335. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR,
  336. 0, SAL_CONSOLE_INTR_STATUS,
  337. 0, 0, 0, 0, 0);
  338. if (ret_stuff.status == 0) {
  339. return ret_stuff.v0;
  340. }
  341. return 0;
  342. }
  343. /*
  344. * Enable an interrupt on the SAL console device.
  345. */
  346. static inline void
  347. ia64_sn_console_intr_enable(u64 intr)
  348. {
  349. struct ia64_sal_retval ret_stuff;
  350. ret_stuff.status = 0;
  351. ret_stuff.v0 = 0;
  352. ret_stuff.v1 = 0;
  353. ret_stuff.v2 = 0;
  354. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR,
  355. intr, SAL_CONSOLE_INTR_ON,
  356. 0, 0, 0, 0, 0);
  357. }
  358. /*
  359. * Disable an interrupt on the SAL console device.
  360. */
  361. static inline void
  362. ia64_sn_console_intr_disable(u64 intr)
  363. {
  364. struct ia64_sal_retval ret_stuff;
  365. ret_stuff.status = 0;
  366. ret_stuff.v0 = 0;
  367. ret_stuff.v1 = 0;
  368. ret_stuff.v2 = 0;
  369. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR,
  370. intr, SAL_CONSOLE_INTR_OFF,
  371. 0, 0, 0, 0, 0);
  372. }
  373. /*
  374. * Sends a character buffer to the console asynchronously.
  375. */
  376. static inline u64
  377. ia64_sn_console_xmit_chars(char *buf, int len)
  378. {
  379. struct ia64_sal_retval ret_stuff;
  380. ret_stuff.status = 0;
  381. ret_stuff.v0 = 0;
  382. ret_stuff.v1 = 0;
  383. ret_stuff.v2 = 0;
  384. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_XMIT_CHARS,
  385. (u64)buf, (u64)len,
  386. 0, 0, 0, 0, 0);
  387. if (ret_stuff.status == 0) {
  388. return ret_stuff.v0;
  389. }
  390. return 0;
  391. }
  392. /*
  393. * Returns the iobrick module Id
  394. */
  395. static inline u64
  396. ia64_sn_sysctl_iobrick_module_get(nasid_t nasid, int *result)
  397. {
  398. struct ia64_sal_retval ret_stuff;
  399. ret_stuff.status = 0;
  400. ret_stuff.v0 = 0;
  401. ret_stuff.v1 = 0;
  402. ret_stuff.v2 = 0;
  403. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYSCTL_IOBRICK_MODULE_GET, nasid, 0, 0, 0, 0, 0, 0);
  404. /* result is in 'v0' */
  405. *result = (int)ret_stuff.v0;
  406. return ret_stuff.status;
  407. }
  408. /**
  409. * ia64_sn_pod_mode - call the SN_SAL_POD_MODE function
  410. *
  411. * SN_SAL_POD_MODE actually takes an argument, but it's always
  412. * 0 when we call it from the kernel, so we don't have to expose
  413. * it to the caller.
  414. */
  415. static inline u64
  416. ia64_sn_pod_mode(void)
  417. {
  418. struct ia64_sal_retval isrv;
  419. SAL_CALL_REENTRANT(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0);
  420. if (isrv.status)
  421. return 0;
  422. return isrv.v0;
  423. }
  424. /**
  425. * ia64_sn_probe_mem - read from memory safely
  426. * @addr: address to probe
  427. * @size: number bytes to read (1,2,4,8)
  428. * @data_ptr: address to store value read by probe (-1 returned if probe fails)
  429. *
  430. * Call into the SAL to do a memory read. If the read generates a machine
  431. * check, this routine will recover gracefully and return -1 to the caller.
  432. * @addr is usually a kernel virtual address in uncached space (i.e. the
  433. * address starts with 0xc), but if called in physical mode, @addr should
  434. * be a physical address.
  435. *
  436. * Return values:
  437. * 0 - probe successful
  438. * 1 - probe failed (generated MCA)
  439. * 2 - Bad arg
  440. * <0 - PAL error
  441. */
  442. static inline u64
  443. ia64_sn_probe_mem(long addr, long size, void *data_ptr)
  444. {
  445. struct ia64_sal_retval isrv;
  446. SAL_CALL(isrv, SN_SAL_PROBE, addr, size, 0, 0, 0, 0, 0);
  447. if (data_ptr) {
  448. switch (size) {
  449. case 1:
  450. *((u8*)data_ptr) = (u8)isrv.v0;
  451. break;
  452. case 2:
  453. *((u16*)data_ptr) = (u16)isrv.v0;
  454. break;
  455. case 4:
  456. *((u32*)data_ptr) = (u32)isrv.v0;
  457. break;
  458. case 8:
  459. *((u64*)data_ptr) = (u64)isrv.v0;
  460. break;
  461. default:
  462. isrv.status = 2;
  463. }
  464. }
  465. return isrv.status;
  466. }
  467. /*
  468. * Retrieve the system serial number as an ASCII string.
  469. */
  470. static inline u64
  471. ia64_sn_sys_serial_get(char *buf)
  472. {
  473. struct ia64_sal_retval ret_stuff;
  474. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYS_SERIAL_GET, buf, 0, 0, 0, 0, 0, 0);
  475. return ret_stuff.status;
  476. }
  477. extern char sn_system_serial_number_string[];
  478. extern u64 sn_partition_serial_number;
  479. static inline char *
  480. sn_system_serial_number(void) {
  481. if (sn_system_serial_number_string[0]) {
  482. return(sn_system_serial_number_string);
  483. } else {
  484. ia64_sn_sys_serial_get(sn_system_serial_number_string);
  485. return(sn_system_serial_number_string);
  486. }
  487. }
  488. /*
  489. * Returns a unique id number for this system and partition (suitable for
  490. * use with license managers), based in part on the system serial number.
  491. */
  492. static inline u64
  493. ia64_sn_partition_serial_get(void)
  494. {
  495. struct ia64_sal_retval ret_stuff;
  496. ia64_sal_oemcall_reentrant(&ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0,
  497. 0, 0, 0, 0, 0, 0);
  498. if (ret_stuff.status != 0)
  499. return 0;
  500. return ret_stuff.v0;
  501. }
  502. static inline u64
  503. sn_partition_serial_number_val(void) {
  504. if (unlikely(sn_partition_serial_number == 0)) {
  505. sn_partition_serial_number = ia64_sn_partition_serial_get();
  506. }
  507. return sn_partition_serial_number;
  508. }
  509. /*
  510. * Returns the partition id of the nasid passed in as an argument,
  511. * or INVALID_PARTID if the partition id cannot be retrieved.
  512. */
  513. static inline partid_t
  514. ia64_sn_sysctl_partition_get(nasid_t nasid)
  515. {
  516. struct ia64_sal_retval ret_stuff;
  517. SAL_CALL(ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid,
  518. 0, 0, 0, 0, 0, 0);
  519. if (ret_stuff.status != 0)
  520. return -1;
  521. return ((partid_t)ret_stuff.v0);
  522. }
  523. /*
  524. * Returns the physical address of the partition's reserved page through
  525. * an iterative number of calls.
  526. *
  527. * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
  528. * set to the nasid of the partition whose reserved page's address is
  529. * being sought.
  530. * On subsequent calls, pass the values, that were passed back on the
  531. * previous call.
  532. *
  533. * While the return status equals SALRET_MORE_PASSES, keep calling
  534. * this function after first copying 'len' bytes starting at 'addr'
  535. * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
  536. * be the physical address of the partition's reserved page. If the
  537. * return status equals neither of these, an error as occurred.
  538. */
  539. static inline s64
  540. sn_partition_reserved_page_pa(u64 buf, u64 *cookie, u64 *addr, u64 *len)
  541. {
  542. struct ia64_sal_retval rv;
  543. ia64_sal_oemcall_reentrant(&rv, SN_SAL_GET_PARTITION_ADDR, *cookie,
  544. *addr, buf, *len, 0, 0, 0);
  545. *cookie = rv.v0;
  546. *addr = rv.v1;
  547. *len = rv.v2;
  548. return rv.status;
  549. }
  550. /*
  551. * Register or unregister a physical address range being referenced across
  552. * a partition boundary for which certain SAL errors should be scanned for,
  553. * cleaned up and ignored. This is of value for kernel partitioning code only.
  554. * Values for the operation argument:
  555. * 1 = register this address range with SAL
  556. * 0 = unregister this address range with SAL
  557. *
  558. * SAL maintains a reference count on an address range in case it is registered
  559. * multiple times.
  560. *
  561. * On success, returns the reference count of the address range after the SAL
  562. * call has performed the current registration/unregistration. Returns a
  563. * negative value if an error occurred.
  564. */
  565. static inline int
  566. sn_register_xp_addr_region(u64 paddr, u64 len, int operation)
  567. {
  568. struct ia64_sal_retval ret_stuff;
  569. ia64_sal_oemcall(&ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len,
  570. (u64)operation, 0, 0, 0, 0);
  571. return ret_stuff.status;
  572. }
  573. /*
  574. * Register or unregister an instruction range for which SAL errors should
  575. * be ignored. If an error occurs while in the registered range, SAL jumps
  576. * to return_addr after ignoring the error. Values for the operation argument:
  577. * 1 = register this instruction range with SAL
  578. * 0 = unregister this instruction range with SAL
  579. *
  580. * Returns 0 on success, or a negative value if an error occurred.
  581. */
  582. static inline int
  583. sn_register_nofault_code(u64 start_addr, u64 end_addr, u64 return_addr,
  584. int virtual, int operation)
  585. {
  586. struct ia64_sal_retval ret_stuff;
  587. u64 call;
  588. if (virtual) {
  589. call = SN_SAL_NO_FAULT_ZONE_VIRTUAL;
  590. } else {
  591. call = SN_SAL_NO_FAULT_ZONE_PHYSICAL;
  592. }
  593. ia64_sal_oemcall(&ret_stuff, call, start_addr, end_addr, return_addr,
  594. (u64)1, 0, 0, 0);
  595. return ret_stuff.status;
  596. }
  597. /*
  598. * Register or unregister a function to handle a PMI received by a CPU.
  599. * Before calling the registered handler, SAL sets r1 to the value that
  600. * was passed in as the global_pointer.
  601. *
  602. * If the handler pointer is NULL, then the currently registered handler
  603. * will be unregistered.
  604. *
  605. * Returns 0 on success, or a negative value if an error occurred.
  606. */
  607. static inline int
  608. sn_register_pmi_handler(u64 handler, u64 global_pointer)
  609. {
  610. struct ia64_sal_retval ret_stuff;
  611. ia64_sal_oemcall(&ret_stuff, SN_SAL_REGISTER_PMI_HANDLER, handler,
  612. global_pointer, 0, 0, 0, 0, 0);
  613. return ret_stuff.status;
  614. }
  615. /*
  616. * Change or query the coherence domain for this partition. Each cpu-based
  617. * nasid is represented by a bit in an array of 64-bit words:
  618. * 0 = not in this partition's coherency domain
  619. * 1 = in this partition's coherency domain
  620. *
  621. * It is not possible for the local system's nasids to be removed from
  622. * the coherency domain. Purpose of the domain arguments:
  623. * new_domain = set the coherence domain to the given nasids
  624. * old_domain = return the current coherence domain
  625. *
  626. * Returns 0 on success, or a negative value if an error occurred.
  627. */
  628. static inline int
  629. sn_change_coherence(u64 *new_domain, u64 *old_domain)
  630. {
  631. struct ia64_sal_retval ret_stuff;
  632. ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_COHERENCE, (u64)new_domain,
  633. (u64)old_domain, 0, 0, 0, 0, 0);
  634. return ret_stuff.status;
  635. }
  636. /*
  637. * Change memory access protections for a physical address range.
  638. * nasid_array is not used on Altix, but may be in future architectures.
  639. * Available memory protection access classes are defined after the function.
  640. */
  641. static inline int
  642. sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
  643. {
  644. struct ia64_sal_retval ret_stuff;
  645. ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_MEMPROTECT, paddr, len,
  646. (u64)nasid_array, perms, 0, 0, 0);
  647. return ret_stuff.status;
  648. }
  649. #define SN_MEMPROT_ACCESS_CLASS_0 0x14a080
  650. #define SN_MEMPROT_ACCESS_CLASS_1 0x2520c2
  651. #define SN_MEMPROT_ACCESS_CLASS_2 0x14a1ca
  652. #define SN_MEMPROT_ACCESS_CLASS_3 0x14a290
  653. #define SN_MEMPROT_ACCESS_CLASS_6 0x084080
  654. #define SN_MEMPROT_ACCESS_CLASS_7 0x021080
  655. /*
  656. * Turns off system power.
  657. */
  658. static inline void
  659. ia64_sn_power_down(void)
  660. {
  661. struct ia64_sal_retval ret_stuff;
  662. SAL_CALL(ret_stuff, SN_SAL_SYSTEM_POWER_DOWN, 0, 0, 0, 0, 0, 0, 0);
  663. while(1)
  664. cpu_relax();
  665. /* never returns */
  666. }
  667. /**
  668. * ia64_sn_fru_capture - tell the system controller to capture hw state
  669. *
  670. * This routine will call the SAL which will tell the system controller(s)
  671. * to capture hw mmr information from each SHub in the system.
  672. */
  673. static inline u64
  674. ia64_sn_fru_capture(void)
  675. {
  676. struct ia64_sal_retval isrv;
  677. SAL_CALL(isrv, SN_SAL_SYSCTL_FRU_CAPTURE, 0, 0, 0, 0, 0, 0, 0);
  678. if (isrv.status)
  679. return 0;
  680. return isrv.v0;
  681. }
  682. /*
  683. * Performs an operation on a PCI bus or slot -- power up, power down
  684. * or reset.
  685. */
  686. static inline u64
  687. ia64_sn_sysctl_iobrick_pci_op(nasid_t n, u64 connection_type,
  688. u64 bus, char slot,
  689. u64 action)
  690. {
  691. struct ia64_sal_retval rv = {0, 0, 0, 0};
  692. SAL_CALL_NOLOCK(rv, SN_SAL_SYSCTL_IOBRICK_PCI_OP, connection_type, n, action,
  693. bus, (u64) slot, 0, 0);
  694. if (rv.status)
  695. return rv.v0;
  696. return 0;
  697. }
  698. /*
  699. * Open a subchannel for sending arbitrary data to the system
  700. * controller network via the system controller device associated with
  701. * 'nasid'. Return the subchannel number or a negative error code.
  702. */
  703. static inline int
  704. ia64_sn_irtr_open(nasid_t nasid)
  705. {
  706. struct ia64_sal_retval rv;
  707. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_OPEN, nasid,
  708. 0, 0, 0, 0, 0);
  709. return (int) rv.v0;
  710. }
  711. /*
  712. * Close system controller subchannel 'subch' previously opened on 'nasid'.
  713. */
  714. static inline int
  715. ia64_sn_irtr_close(nasid_t nasid, int subch)
  716. {
  717. struct ia64_sal_retval rv;
  718. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_CLOSE,
  719. (u64) nasid, (u64) subch, 0, 0, 0, 0);
  720. return (int) rv.status;
  721. }
  722. /*
  723. * Read data from system controller associated with 'nasid' on
  724. * subchannel 'subch'. The buffer to be filled is pointed to by
  725. * 'buf', and its capacity is in the integer pointed to by 'len'. The
  726. * referent of 'len' is set to the number of bytes read by the SAL
  727. * call. The return value is either SALRET_OK (for bytes read) or
  728. * SALRET_ERROR (for error or "no data available").
  729. */
  730. static inline int
  731. ia64_sn_irtr_recv(nasid_t nasid, int subch, char *buf, int *len)
  732. {
  733. struct ia64_sal_retval rv;
  734. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_RECV,
  735. (u64) nasid, (u64) subch, (u64) buf, (u64) len,
  736. 0, 0);
  737. return (int) rv.status;
  738. }
  739. /*
  740. * Write data to the system controller network via the system
  741. * controller associated with 'nasid' on suchannel 'subch'. The
  742. * buffer to be written out is pointed to by 'buf', and 'len' is the
  743. * number of bytes to be written. The return value is either the
  744. * number of bytes written (which could be zero) or a negative error
  745. * code.
  746. */
  747. static inline int
  748. ia64_sn_irtr_send(nasid_t nasid, int subch, char *buf, int len)
  749. {
  750. struct ia64_sal_retval rv;
  751. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_SEND,
  752. (u64) nasid, (u64) subch, (u64) buf, (u64) len,
  753. 0, 0);
  754. return (int) rv.v0;
  755. }
  756. /*
  757. * Check whether any interrupts are pending for the system controller
  758. * associated with 'nasid' and its subchannel 'subch'. The return
  759. * value is a mask of pending interrupts (SAL_IROUTER_INTR_XMIT and/or
  760. * SAL_IROUTER_INTR_RECV).
  761. */
  762. static inline int
  763. ia64_sn_irtr_intr(nasid_t nasid, int subch)
  764. {
  765. struct ia64_sal_retval rv;
  766. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_STATUS,
  767. (u64) nasid, (u64) subch, 0, 0, 0, 0);
  768. return (int) rv.v0;
  769. }
  770. /*
  771. * Enable the interrupt indicated by the intr parameter (either
  772. * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
  773. */
  774. static inline int
  775. ia64_sn_irtr_intr_enable(nasid_t nasid, int subch, u64 intr)
  776. {
  777. struct ia64_sal_retval rv;
  778. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_ON,
  779. (u64) nasid, (u64) subch, intr, 0, 0, 0);
  780. return (int) rv.v0;
  781. }
  782. /*
  783. * Disable the interrupt indicated by the intr parameter (either
  784. * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
  785. */
  786. static inline int
  787. ia64_sn_irtr_intr_disable(nasid_t nasid, int subch, u64 intr)
  788. {
  789. struct ia64_sal_retval rv;
  790. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_OFF,
  791. (u64) nasid, (u64) subch, intr, 0, 0, 0);
  792. return (int) rv.v0;
  793. }
  794. /*
  795. * Set up a node as the point of contact for system controller
  796. * environmental event delivery.
  797. */
  798. static inline int
  799. ia64_sn_sysctl_event_init(nasid_t nasid)
  800. {
  801. struct ia64_sal_retval rv;
  802. SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_EVENT, (u64) nasid,
  803. 0, 0, 0, 0, 0, 0);
  804. return (int) rv.v0;
  805. }
  806. /*
  807. * Ask the system controller on the specified nasid to reset
  808. * the CX corelet clock. Only valid on TIO nodes.
  809. */
  810. static inline int
  811. ia64_sn_sysctl_tio_clock_reset(nasid_t nasid)
  812. {
  813. struct ia64_sal_retval rv;
  814. SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_TIO_JLCK_RST,
  815. nasid, 0, 0, 0, 0, 0);
  816. if (rv.status != 0)
  817. return (int)rv.status;
  818. if (rv.v0 != 0)
  819. return (int)rv.v0;
  820. return 0;
  821. }
  822. /*
  823. * Get the associated ioboard type for a given nasid.
  824. */
  825. static inline s64
  826. ia64_sn_sysctl_ioboard_get(nasid_t nasid, u16 *ioboard)
  827. {
  828. struct ia64_sal_retval isrv;
  829. SAL_CALL_REENTRANT(isrv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_IOBOARD,
  830. nasid, 0, 0, 0, 0, 0);
  831. if (isrv.v0 != 0) {
  832. *ioboard = isrv.v0;
  833. return isrv.status;
  834. }
  835. if (isrv.v1 != 0) {
  836. *ioboard = isrv.v1;
  837. return isrv.status;
  838. }
  839. return isrv.status;
  840. }
  841. /**
  842. * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
  843. * @nasid: NASID of node to read
  844. * @index: FIT entry index to be retrieved (0..n)
  845. * @fitentry: 16 byte buffer where FIT entry will be stored.
  846. * @banbuf: optional buffer for retrieving banner
  847. * @banlen: length of banner buffer
  848. *
  849. * Access to the physical PROM chips needs to be serialized since reads and
  850. * writes can't occur at the same time, so we need to call into the SAL when
  851. * we want to look at the FIT entries on the chips.
  852. *
  853. * Returns:
  854. * %SALRET_OK if ok
  855. * %SALRET_INVALID_ARG if index too big
  856. * %SALRET_NOT_IMPLEMENTED if running on older PROM
  857. * ??? if nasid invalid OR banner buffer not large enough
  858. */
  859. static inline int
  860. ia64_sn_get_fit_compt(u64 nasid, u64 index, void *fitentry, void *banbuf,
  861. u64 banlen)
  862. {
  863. struct ia64_sal_retval rv;
  864. SAL_CALL_NOLOCK(rv, SN_SAL_GET_FIT_COMPT, nasid, index, fitentry,
  865. banbuf, banlen, 0, 0);
  866. return (int) rv.status;
  867. }
  868. /*
  869. * Initialize the SAL components of the system controller
  870. * communication driver; specifically pass in a sizable buffer that
  871. * can be used for allocation of subchannel queues as new subchannels
  872. * are opened. "buf" points to the buffer, and "len" specifies its
  873. * length.
  874. */
  875. static inline int
  876. ia64_sn_irtr_init(nasid_t nasid, void *buf, int len)
  877. {
  878. struct ia64_sal_retval rv;
  879. SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INIT,
  880. (u64) nasid, (u64) buf, (u64) len, 0, 0, 0);
  881. return (int) rv.status;
  882. }
  883. /*
  884. * Returns the nasid, subnode & slice corresponding to a SAPIC ID
  885. *
  886. * In:
  887. * arg0 - SN_SAL_GET_SAPIC_INFO
  888. * arg1 - sapicid (lid >> 16)
  889. * Out:
  890. * v0 - nasid
  891. * v1 - subnode
  892. * v2 - slice
  893. */
  894. static inline u64
  895. ia64_sn_get_sapic_info(int sapicid, int *nasid, int *subnode, int *slice)
  896. {
  897. struct ia64_sal_retval ret_stuff;
  898. ret_stuff.status = 0;
  899. ret_stuff.v0 = 0;
  900. ret_stuff.v1 = 0;
  901. ret_stuff.v2 = 0;
  902. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SAPIC_INFO, sapicid, 0, 0, 0, 0, 0, 0);
  903. /***** BEGIN HACK - temp til old proms no longer supported ********/
  904. if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
  905. if (nasid) *nasid = sapicid & 0xfff;
  906. if (subnode) *subnode = (sapicid >> 13) & 1;
  907. if (slice) *slice = (sapicid >> 12) & 3;
  908. return 0;
  909. }
  910. /***** END HACK *******/
  911. if (ret_stuff.status < 0)
  912. return ret_stuff.status;
  913. if (nasid) *nasid = (int) ret_stuff.v0;
  914. if (subnode) *subnode = (int) ret_stuff.v1;
  915. if (slice) *slice = (int) ret_stuff.v2;
  916. return 0;
  917. }
  918. /*
  919. * Returns information about the HUB/SHUB.
  920. * In:
  921. * arg0 - SN_SAL_GET_SN_INFO
  922. * arg1 - 0 (other values reserved for future use)
  923. * Out:
  924. * v0
  925. * [7:0] - shub type (0=shub1, 1=shub2)
  926. * [15:8] - Log2 max number of nodes in entire system (includes
  927. * C-bricks, I-bricks, etc)
  928. * [23:16] - Log2 of nodes per sharing domain
  929. * [31:24] - partition ID
  930. * [39:32] - coherency_id
  931. * [47:40] - regionsize
  932. * v1
  933. * [15:0] - nasid mask (ex., 0x7ff for 11 bit nasid)
  934. * [23:15] - bit position of low nasid bit
  935. */
  936. static inline u64
  937. ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift,
  938. u8 *systemsize, u8 *sharing_domain_size, u8 *partid, u8 *coher, u8 *reg)
  939. {
  940. struct ia64_sal_retval ret_stuff;
  941. ret_stuff.status = 0;
  942. ret_stuff.v0 = 0;
  943. ret_stuff.v1 = 0;
  944. ret_stuff.v2 = 0;
  945. SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SN_INFO, fc, 0, 0, 0, 0, 0, 0);
  946. /***** BEGIN HACK - temp til old proms no longer supported ********/
  947. if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
  948. int nasid = get_sapicid() & 0xfff;
  949. #define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL
  950. #define SH_SHUB_ID_NODES_PER_BIT_SHFT 48
  951. if (shubtype) *shubtype = 0;
  952. if (nasid_bitmask) *nasid_bitmask = 0x7ff;
  953. if (nasid_shift) *nasid_shift = 38;
  954. if (systemsize) *systemsize = 10;
  955. if (sharing_domain_size) *sharing_domain_size = 8;
  956. if (partid) *partid = ia64_sn_sysctl_partition_get(nasid);
  957. if (coher) *coher = nasid >> 9;
  958. if (reg) *reg = (HUB_L((u64 *) LOCAL_MMR_ADDR(SH1_SHUB_ID)) & SH_SHUB_ID_NODES_PER_BIT_MASK) >>
  959. SH_SHUB_ID_NODES_PER_BIT_SHFT;
  960. return 0;
  961. }
  962. /***** END HACK *******/
  963. if (ret_stuff.status < 0)
  964. return ret_stuff.status;
  965. if (shubtype) *shubtype = ret_stuff.v0 & 0xff;
  966. if (systemsize) *systemsize = (ret_stuff.v0 >> 8) & 0xff;
  967. if (sharing_domain_size) *sharing_domain_size = (ret_stuff.v0 >> 16) & 0xff;
  968. if (partid) *partid = (ret_stuff.v0 >> 24) & 0xff;
  969. if (coher) *coher = (ret_stuff.v0 >> 32) & 0xff;
  970. if (reg) *reg = (ret_stuff.v0 >> 40) & 0xff;
  971. if (nasid_bitmask) *nasid_bitmask = (ret_stuff.v1 & 0xffff);
  972. if (nasid_shift) *nasid_shift = (ret_stuff.v1 >> 16) & 0xff;
  973. return 0;
  974. }
  975. /*
  976. * This is the access point to the Altix PROM hardware performance
  977. * and status monitoring interface. For info on using this, see
  978. * arch/ia64/include/asm/sn/sn2/sn_hwperf.h
  979. */
  980. static inline int
  981. ia64_sn_hwperf_op(nasid_t nasid, u64 opcode, u64 a0, u64 a1, u64 a2,
  982. u64 a3, u64 a4, int *v0)
  983. {
  984. struct ia64_sal_retval rv;
  985. SAL_CALL_NOLOCK(rv, SN_SAL_HWPERF_OP, (u64)nasid,
  986. opcode, a0, a1, a2, a3, a4);
  987. if (v0)
  988. *v0 = (int) rv.v0;
  989. return (int) rv.status;
  990. }
  991. static inline int
  992. ia64_sn_ioif_get_pci_topology(u64 buf, u64 len)
  993. {
  994. struct ia64_sal_retval rv;
  995. SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY, buf, len, 0, 0, 0, 0, 0);
  996. return (int) rv.status;
  997. }
  998. /*
  999. * BTE error recovery is implemented in SAL
  1000. */
  1001. static inline int
  1002. ia64_sn_bte_recovery(nasid_t nasid)
  1003. {
  1004. struct ia64_sal_retval rv;
  1005. rv.status = 0;
  1006. SAL_CALL_NOLOCK(rv, SN_SAL_BTE_RECOVER, (u64)nasid, 0, 0, 0, 0, 0, 0);
  1007. if (rv.status == SALRET_NOT_IMPLEMENTED)
  1008. return 0;
  1009. return (int) rv.status;
  1010. }
  1011. static inline int
  1012. ia64_sn_is_fake_prom(void)
  1013. {
  1014. struct ia64_sal_retval rv;
  1015. SAL_CALL_NOLOCK(rv, SN_SAL_FAKE_PROM, 0, 0, 0, 0, 0, 0, 0);
  1016. return (rv.status == 0);
  1017. }
  1018. static inline int
  1019. ia64_sn_get_prom_feature_set(int set, unsigned long *feature_set)
  1020. {
  1021. struct ia64_sal_retval rv;
  1022. SAL_CALL_NOLOCK(rv, SN_SAL_GET_PROM_FEATURE_SET, set, 0, 0, 0, 0, 0, 0);
  1023. if (rv.status != 0)
  1024. return rv.status;
  1025. *feature_set = rv.v0;
  1026. return 0;
  1027. }
  1028. static inline int
  1029. ia64_sn_set_os_feature(int feature)
  1030. {
  1031. struct ia64_sal_retval rv;
  1032. SAL_CALL_NOLOCK(rv, SN_SAL_SET_OS_FEATURE_SET, feature, 0, 0, 0, 0, 0, 0);
  1033. return rv.status;
  1034. }
  1035. static inline int
  1036. sn_inject_error(u64 paddr, u64 *data, u64 *ecc)
  1037. {
  1038. struct ia64_sal_retval ret_stuff;
  1039. ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_INJECT_ERROR, paddr, (u64)data,
  1040. (u64)ecc, 0, 0, 0, 0);
  1041. return ret_stuff.status;
  1042. }
  1043. static inline int
  1044. ia64_sn_set_cpu_number(int cpu)
  1045. {
  1046. struct ia64_sal_retval rv;
  1047. SAL_CALL_NOLOCK(rv, SN_SAL_SET_CPU_NUMBER, cpu, 0, 0, 0, 0, 0, 0);
  1048. return rv.status;
  1049. }
  1050. static inline int
  1051. ia64_sn_kernel_launch_event(void)
  1052. {
  1053. struct ia64_sal_retval rv;
  1054. SAL_CALL_NOLOCK(rv, SN_SAL_KERNEL_LAUNCH_EVENT, 0, 0, 0, 0, 0, 0, 0);
  1055. return rv.status;
  1056. }
  1057. #endif /* _ASM_IA64_SN_SN_SAL_H */