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