sn_sal.h 33 KB

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