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