ia64/xen-unstable

changeset 13099:97a369d8da43

[IA64] Use sn_sal.h directly from upstream Linux

Take a straight copy of sn_sal.h from linux 2.6.19 - there is no reason
to hide parts of this file as it's all macros and inline functions

Signed-off-by: Jes Sorensen <jes@sgi.com>
author awilliam@xenbuild2.aw
date Thu Dec 14 11:01:37 2006 -0700 (2006-12-14)
parents d45d361c8ad0
children ba79a17ff715
files xen/include/asm-ia64/linux-xen/asm/sn/README.origin xen/include/asm-ia64/linux-xen/asm/sn/sn_sal.h xen/include/asm-ia64/linux/asm/sn/README.origin xen/include/asm-ia64/linux/asm/sn/sn_sal.h
line diff
     1.1 --- a/xen/include/asm-ia64/linux-xen/asm/sn/README.origin	Wed Dec 13 15:23:28 2006 -0700
     1.2 +++ b/xen/include/asm-ia64/linux-xen/asm/sn/README.origin	Thu Dec 14 11:01:37 2006 -0700
     1.3 @@ -13,5 +13,4 @@ io.h			-> linux/include/asm-ia64/sn/io.h
     1.4  nodepda.h		-> linux/include/asm-ia64/sn/nodepda.h
     1.5  pcibr_provider.h	-> linux/include/asm-ia64/sn/pcibr_provider.h
     1.6  rw_mmr.h		-> linux/include/asm-ia64/sn/rw_mmr.h
     1.7 -sn_sal.h		-> linux/include/asm-ia64/sn/sn_sal.h
     1.8  types.h			-> linux/include/asm-ia64/sn/types.h
     2.1 --- a/xen/include/asm-ia64/linux-xen/asm/sn/sn_sal.h	Wed Dec 13 15:23:28 2006 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,1161 +0,0 @@
     2.4 -#ifndef _ASM_IA64_SN_SN_SAL_H
     2.5 -#define _ASM_IA64_SN_SN_SAL_H
     2.6 -
     2.7 -/*
     2.8 - * System Abstraction Layer definitions for IA64
     2.9 - *
    2.10 - * This file is subject to the terms and conditions of the GNU General Public
    2.11 - * License.  See the file "COPYING" in the main directory of this archive
    2.12 - * for more details.
    2.13 - *
    2.14 - * Copyright (c) 2000-2006 Silicon Graphics, Inc.  All rights reserved.
    2.15 - */
    2.16 -
    2.17 -
    2.18 -#include <asm/sal.h>
    2.19 -#include <asm/sn/sn_cpuid.h>
    2.20 -#include <asm/sn/arch.h>
    2.21 -#include <asm/sn/geo.h>
    2.22 -#include <asm/sn/nodepda.h>
    2.23 -#include <asm/sn/shub_mmr.h>
    2.24 -
    2.25 -// SGI Specific Calls
    2.26 -#define  SN_SAL_POD_MODE                           0x02000001
    2.27 -#define  SN_SAL_SYSTEM_RESET                       0x02000002
    2.28 -#define  SN_SAL_PROBE                              0x02000003
    2.29 -#define  SN_SAL_GET_MASTER_NASID                   0x02000004
    2.30 -#define	 SN_SAL_GET_KLCONFIG_ADDR		   0x02000005
    2.31 -#define  SN_SAL_LOG_CE				   0x02000006
    2.32 -#define  SN_SAL_REGISTER_CE			   0x02000007
    2.33 -#define  SN_SAL_GET_PARTITION_ADDR		   0x02000009
    2.34 -#define  SN_SAL_XP_ADDR_REGION			   0x0200000f
    2.35 -#define  SN_SAL_NO_FAULT_ZONE_VIRTUAL		   0x02000010
    2.36 -#define  SN_SAL_NO_FAULT_ZONE_PHYSICAL		   0x02000011
    2.37 -#define  SN_SAL_PRINT_ERROR			   0x02000012
    2.38 -#define  SN_SAL_SET_ERROR_HANDLING_FEATURES	   0x0200001a	// reentrant
    2.39 -#define  SN_SAL_GET_FIT_COMPT			   0x0200001b	// reentrant
    2.40 -#define  SN_SAL_GET_SAPIC_INFO                     0x0200001d
    2.41 -#define  SN_SAL_GET_SN_INFO                        0x0200001e
    2.42 -#define  SN_SAL_CONSOLE_PUTC                       0x02000021
    2.43 -#define  SN_SAL_CONSOLE_GETC                       0x02000022
    2.44 -#define  SN_SAL_CONSOLE_PUTS                       0x02000023
    2.45 -#define  SN_SAL_CONSOLE_GETS                       0x02000024
    2.46 -#define  SN_SAL_CONSOLE_GETS_TIMEOUT               0x02000025
    2.47 -#define  SN_SAL_CONSOLE_POLL                       0x02000026
    2.48 -#define  SN_SAL_CONSOLE_INTR                       0x02000027
    2.49 -#define  SN_SAL_CONSOLE_PUTB			   0x02000028
    2.50 -#define  SN_SAL_CONSOLE_XMIT_CHARS		   0x0200002a
    2.51 -#define  SN_SAL_CONSOLE_READC			   0x0200002b
    2.52 -#define  SN_SAL_SYSCTL_OP			   0x02000030
    2.53 -#define  SN_SAL_SYSCTL_MODID_GET	           0x02000031
    2.54 -#define  SN_SAL_SYSCTL_GET                         0x02000032
    2.55 -#define  SN_SAL_SYSCTL_IOBRICK_MODULE_GET          0x02000033
    2.56 -#define  SN_SAL_SYSCTL_IO_PORTSPEED_GET            0x02000035
    2.57 -#define  SN_SAL_SYSCTL_SLAB_GET                    0x02000036
    2.58 -#define  SN_SAL_BUS_CONFIG		   	   0x02000037
    2.59 -#define  SN_SAL_SYS_SERIAL_GET			   0x02000038
    2.60 -#define  SN_SAL_PARTITION_SERIAL_GET		   0x02000039
    2.61 -#define  SN_SAL_SYSCTL_PARTITION_GET               0x0200003a
    2.62 -#define  SN_SAL_SYSTEM_POWER_DOWN		   0x0200003b
    2.63 -#define  SN_SAL_GET_MASTER_BASEIO_NASID		   0x0200003c
    2.64 -#define  SN_SAL_COHERENCE                          0x0200003d
    2.65 -#define  SN_SAL_MEMPROTECT                         0x0200003e
    2.66 -#define  SN_SAL_SYSCTL_FRU_CAPTURE		   0x0200003f
    2.67 -
    2.68 -#define  SN_SAL_SYSCTL_IOBRICK_PCI_OP		   0x02000042	// reentrant
    2.69 -#define	 SN_SAL_IROUTER_OP			   0x02000043
    2.70 -#define  SN_SAL_SYSCTL_EVENT                       0x02000044
    2.71 -#define  SN_SAL_IOIF_INTERRUPT			   0x0200004a
    2.72 -#define  SN_SAL_HWPERF_OP			   0x02000050   // lock
    2.73 -#define  SN_SAL_IOIF_ERROR_INTERRUPT		   0x02000051
    2.74 -#define  SN_SAL_IOIF_PCI_SAFE			   0x02000052
    2.75 -#define  SN_SAL_IOIF_SLOT_ENABLE		   0x02000053
    2.76 -#define  SN_SAL_IOIF_SLOT_DISABLE		   0x02000054
    2.77 -#define  SN_SAL_IOIF_GET_HUBDEV_INFO		   0x02000055
    2.78 -#define  SN_SAL_IOIF_GET_PCIBUS_INFO		   0x02000056
    2.79 -#define  SN_SAL_IOIF_GET_PCIDEV_INFO		   0x02000057
    2.80 -#define  SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST	   0x02000058	// deprecated
    2.81 -#define  SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST	   0x0200005a
    2.82 -
    2.83 -#define SN_SAL_HUB_ERROR_INTERRUPT		   0x02000060
    2.84 -#define SN_SAL_BTE_RECOVER			   0x02000061
    2.85 -#define SN_SAL_RESERVED_DO_NOT_USE		   0x02000062
    2.86 -#define SN_SAL_IOIF_GET_PCI_TOPOLOGY		   0x02000064
    2.87 -
    2.88 -#define  SN_SAL_GET_PROM_FEATURE_SET		   0x02000065
    2.89 -#define  SN_SAL_SET_OS_FEATURE_SET		   0x02000066
    2.90 -#define  SN_SAL_INJECT_ERROR			   0x02000067
    2.91 -#define  SN_SAL_SET_CPU_NUMBER			   0x02000068
    2.92 -
    2.93 -/*
    2.94 - * Service-specific constants
    2.95 - */
    2.96 -
    2.97 -/* Console interrupt manipulation */
    2.98 -	/* action codes */
    2.99 -#define SAL_CONSOLE_INTR_OFF    0       /* turn the interrupt off */
   2.100 -#define SAL_CONSOLE_INTR_ON     1       /* turn the interrupt on */
   2.101 -#define SAL_CONSOLE_INTR_STATUS 2	/* retrieve the interrupt status */
   2.102 -	/* interrupt specification & status return codes */
   2.103 -#define SAL_CONSOLE_INTR_XMIT	1	/* output interrupt */
   2.104 -#define SAL_CONSOLE_INTR_RECV	2	/* input interrupt */
   2.105 -
   2.106 -/* interrupt handling */
   2.107 -#define SAL_INTR_ALLOC		1
   2.108 -#define SAL_INTR_FREE		2
   2.109 -
   2.110 -/*
   2.111 - * operations available on the generic SN_SAL_SYSCTL_OP
   2.112 - * runtime service
   2.113 - */
   2.114 -#define SAL_SYSCTL_OP_IOBOARD		0x0001  /*  retrieve board type */
   2.115 -#define SAL_SYSCTL_OP_TIO_JLCK_RST      0x0002  /* issue TIO clock reset */
   2.116 -
   2.117 -/*
   2.118 - * IRouter (i.e. generalized system controller) operations
   2.119 - */
   2.120 -#define SAL_IROUTER_OPEN	0	/* open a subchannel */
   2.121 -#define SAL_IROUTER_CLOSE	1	/* close a subchannel */
   2.122 -#define SAL_IROUTER_SEND	2	/* send part of an IRouter packet */
   2.123 -#define SAL_IROUTER_RECV	3	/* receive part of an IRouter packet */
   2.124 -#define SAL_IROUTER_INTR_STATUS	4	/* check the interrupt status for
   2.125 -					 * an open subchannel
   2.126 -					 */
   2.127 -#define SAL_IROUTER_INTR_ON	5	/* enable an interrupt */
   2.128 -#define SAL_IROUTER_INTR_OFF	6	/* disable an interrupt */
   2.129 -#define SAL_IROUTER_INIT	7	/* initialize IRouter driver */
   2.130 -
   2.131 -/* IRouter interrupt mask bits */
   2.132 -#define SAL_IROUTER_INTR_XMIT	SAL_CONSOLE_INTR_XMIT
   2.133 -#define SAL_IROUTER_INTR_RECV	SAL_CONSOLE_INTR_RECV
   2.134 -
   2.135 -/*
   2.136 - * Error Handling Features
   2.137 - */
   2.138 -#define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV	0x1	// obsolete
   2.139 -#define SAL_ERR_FEAT_LOG_SBES			0x2	// obsolete
   2.140 -#define SAL_ERR_FEAT_MFR_OVERRIDE		0x4
   2.141 -#define SAL_ERR_FEAT_SBE_THRESHOLD		0xffff0000
   2.142 -
   2.143 -/*
   2.144 - * SAL Error Codes
   2.145 - */
   2.146 -#define SALRET_MORE_PASSES	1
   2.147 -#define SALRET_OK		0
   2.148 -#define SALRET_NOT_IMPLEMENTED	(-1)
   2.149 -#define SALRET_INVALID_ARG	(-2)
   2.150 -#define SALRET_ERROR		(-3)
   2.151 -
   2.152 -#define SN_SAL_FAKE_PROM			   0x02009999
   2.153 -
   2.154 -#ifndef XEN
   2.155 -/**
   2.156 -  * sn_sal_revision - get the SGI SAL revision number
   2.157 -  *
   2.158 -  * The SGI PROM stores its version in the sal_[ab]_rev_(major|minor).
   2.159 -  * This routine simply extracts the major and minor values and
   2.160 -  * presents them in a u32 format.
   2.161 -  *
   2.162 -  * For example, version 4.05 would be represented at 0x0405.
   2.163 -  */
   2.164 -static inline u32
   2.165 -sn_sal_rev(void)
   2.166 -{
   2.167 -	struct ia64_sal_systab *systab = __va(efi.sal_systab);
   2.168 -
   2.169 -	return (u32)(systab->sal_b_rev_major << 8 | systab->sal_b_rev_minor);
   2.170 -}
   2.171 -
   2.172 -/*
   2.173 - * Returns the master console nasid, if the call fails, return an illegal
   2.174 - * value.
   2.175 - */
   2.176 -static inline u64
   2.177 -ia64_sn_get_console_nasid(void)
   2.178 -{
   2.179 -	struct ia64_sal_retval ret_stuff;
   2.180 -
   2.181 -	ret_stuff.status = 0;
   2.182 -	ret_stuff.v0 = 0;
   2.183 -	ret_stuff.v1 = 0;
   2.184 -	ret_stuff.v2 = 0;
   2.185 -	SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_NASID, 0, 0, 0, 0, 0, 0, 0);
   2.186 -
   2.187 -	if (ret_stuff.status < 0)
   2.188 -		return ret_stuff.status;
   2.189 -
   2.190 -	/* Master console nasid is in 'v0' */
   2.191 -	return ret_stuff.v0;
   2.192 -}
   2.193 -
   2.194 -/*
   2.195 - * Returns the master baseio nasid, if the call fails, return an illegal
   2.196 - * value.
   2.197 - */
   2.198 -static inline u64
   2.199 -ia64_sn_get_master_baseio_nasid(void)
   2.200 -{
   2.201 -	struct ia64_sal_retval ret_stuff;
   2.202 -
   2.203 -	ret_stuff.status = 0;
   2.204 -	ret_stuff.v0 = 0;
   2.205 -	ret_stuff.v1 = 0;
   2.206 -	ret_stuff.v2 = 0;
   2.207 -	SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_BASEIO_NASID, 0, 0, 0, 0, 0, 0, 0);
   2.208 -
   2.209 -	if (ret_stuff.status < 0)
   2.210 -		return ret_stuff.status;
   2.211 -
   2.212 -	/* Master baseio nasid is in 'v0' */
   2.213 -	return ret_stuff.v0;
   2.214 -}
   2.215 -
   2.216 -static inline void *
   2.217 -ia64_sn_get_klconfig_addr(nasid_t nasid)
   2.218 -{
   2.219 -	struct ia64_sal_retval ret_stuff;
   2.220 -
   2.221 -	ret_stuff.status = 0;
   2.222 -	ret_stuff.v0 = 0;
   2.223 -	ret_stuff.v1 = 0;
   2.224 -	ret_stuff.v2 = 0;
   2.225 -	SAL_CALL(ret_stuff, SN_SAL_GET_KLCONFIG_ADDR, (u64)nasid, 0, 0, 0, 0, 0, 0);
   2.226 -	return ret_stuff.v0 ? __va(ret_stuff.v0) : NULL;
   2.227 -}
   2.228 -#endif /* !XEN */
   2.229 -
   2.230 -/*
   2.231 - * Returns the next console character.
   2.232 - */
   2.233 -static inline u64
   2.234 -ia64_sn_console_getc(int *ch)
   2.235 -{
   2.236 -	struct ia64_sal_retval ret_stuff;
   2.237 -
   2.238 -	ret_stuff.status = 0;
   2.239 -	ret_stuff.v0 = 0;
   2.240 -	ret_stuff.v1 = 0;
   2.241 -	ret_stuff.v2 = 0;
   2.242 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_GETC, 0, 0, 0, 0, 0, 0, 0);
   2.243 -
   2.244 -	/* character is in 'v0' */
   2.245 -	*ch = (int)ret_stuff.v0;
   2.246 -
   2.247 -	return ret_stuff.status;
   2.248 -}
   2.249 -
   2.250 -/*
   2.251 - * Read a character from the SAL console device, after a previous interrupt
   2.252 - * or poll operation has given us to know that a character is available
   2.253 - * to be read.
   2.254 - */
   2.255 -static inline u64
   2.256 -ia64_sn_console_readc(void)
   2.257 -{
   2.258 -	struct ia64_sal_retval ret_stuff;
   2.259 -
   2.260 -	ret_stuff.status = 0;
   2.261 -	ret_stuff.v0 = 0;
   2.262 -	ret_stuff.v1 = 0;
   2.263 -	ret_stuff.v2 = 0;
   2.264 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_READC, 0, 0, 0, 0, 0, 0, 0);
   2.265 -
   2.266 -	/* character is in 'v0' */
   2.267 -	return ret_stuff.v0;
   2.268 -}
   2.269 -
   2.270 -/*
   2.271 - * Sends the given character to the console.
   2.272 - */
   2.273 -static inline u64
   2.274 -ia64_sn_console_putc(char ch)
   2.275 -{
   2.276 -	struct ia64_sal_retval ret_stuff;
   2.277 -
   2.278 -	ret_stuff.status = 0;
   2.279 -	ret_stuff.v0 = 0;
   2.280 -	ret_stuff.v1 = 0;
   2.281 -	ret_stuff.v2 = 0;
   2.282 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTC, (u64)ch, 0, 0, 0, 0, 0, 0);
   2.283 -
   2.284 -	return ret_stuff.status;
   2.285 -}
   2.286 -
   2.287 -/*
   2.288 - * Sends the given buffer to the console.
   2.289 - */
   2.290 -static inline u64
   2.291 -ia64_sn_console_putb(const char *buf, int len)
   2.292 -{
   2.293 -	struct ia64_sal_retval ret_stuff;
   2.294 -
   2.295 -	ret_stuff.status = 0;
   2.296 -	ret_stuff.v0 = 0; 
   2.297 -	ret_stuff.v1 = 0;
   2.298 -	ret_stuff.v2 = 0;
   2.299 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTB, (u64)buf, (u64)len, 0, 0, 0, 0, 0);
   2.300 -
   2.301 -	if ( ret_stuff.status == 0 ) {
   2.302 -		return ret_stuff.v0;
   2.303 -	}
   2.304 -	return (u64)0;
   2.305 -}
   2.306 -
   2.307 -#ifndef XEN
   2.308 -/*
   2.309 - * Print a platform error record
   2.310 - */
   2.311 -static inline u64
   2.312 -ia64_sn_plat_specific_err_print(int (*hook)(const char*, ...), char *rec)
   2.313 -{
   2.314 -	struct ia64_sal_retval ret_stuff;
   2.315 -
   2.316 -	ret_stuff.status = 0;
   2.317 -	ret_stuff.v0 = 0;
   2.318 -	ret_stuff.v1 = 0;
   2.319 -	ret_stuff.v2 = 0;
   2.320 -	SAL_CALL_REENTRANT(ret_stuff, SN_SAL_PRINT_ERROR, (u64)hook, (u64)rec, 0, 0, 0, 0, 0);
   2.321 -
   2.322 -	return ret_stuff.status;
   2.323 -}
   2.324 -
   2.325 -/*
   2.326 - * Check for Platform errors
   2.327 - */
   2.328 -static inline u64
   2.329 -ia64_sn_plat_cpei_handler(void)
   2.330 -{
   2.331 -	struct ia64_sal_retval ret_stuff;
   2.332 -
   2.333 -	ret_stuff.status = 0;
   2.334 -	ret_stuff.v0 = 0;
   2.335 -	ret_stuff.v1 = 0;
   2.336 -	ret_stuff.v2 = 0;
   2.337 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_LOG_CE, 0, 0, 0, 0, 0, 0, 0);
   2.338 -
   2.339 -	return ret_stuff.status;
   2.340 -}
   2.341 -
   2.342 -/*
   2.343 - * Set Error Handling Features	(Obsolete)
   2.344 - */
   2.345 -static inline u64
   2.346 -ia64_sn_plat_set_error_handling_features(void)
   2.347 -{
   2.348 -	struct ia64_sal_retval ret_stuff;
   2.349 -
   2.350 -	ret_stuff.status = 0;
   2.351 -	ret_stuff.v0 = 0;
   2.352 -	ret_stuff.v1 = 0;
   2.353 -	ret_stuff.v2 = 0;
   2.354 -	SAL_CALL_REENTRANT(ret_stuff, SN_SAL_SET_ERROR_HANDLING_FEATURES,
   2.355 -		SAL_ERR_FEAT_LOG_SBES,
   2.356 -		0, 0, 0, 0, 0, 0);
   2.357 -
   2.358 -	return ret_stuff.status;
   2.359 -}
   2.360 -
   2.361 -/*
   2.362 - * Checks for console input.
   2.363 - */
   2.364 -static inline u64
   2.365 -ia64_sn_console_check(int *result)
   2.366 -{
   2.367 -	struct ia64_sal_retval ret_stuff;
   2.368 -
   2.369 -	ret_stuff.status = 0;
   2.370 -	ret_stuff.v0 = 0;
   2.371 -	ret_stuff.v1 = 0;
   2.372 -	ret_stuff.v2 = 0;
   2.373 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_POLL, 0, 0, 0, 0, 0, 0, 0);
   2.374 -
   2.375 -	/* result is in 'v0' */
   2.376 -	*result = (int)ret_stuff.v0;
   2.377 -
   2.378 -	return ret_stuff.status;
   2.379 -}
   2.380 -
   2.381 -/*
   2.382 - * Checks console interrupt status
   2.383 - */
   2.384 -static inline u64
   2.385 -ia64_sn_console_intr_status(void)
   2.386 -{
   2.387 -	struct ia64_sal_retval ret_stuff;
   2.388 -
   2.389 -	ret_stuff.status = 0;
   2.390 -	ret_stuff.v0 = 0;
   2.391 -	ret_stuff.v1 = 0;
   2.392 -	ret_stuff.v2 = 0;
   2.393 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR, 
   2.394 -		 0, SAL_CONSOLE_INTR_STATUS,
   2.395 -		 0, 0, 0, 0, 0);
   2.396 -
   2.397 -	if (ret_stuff.status == 0) {
   2.398 -	    return ret_stuff.v0;
   2.399 -	}
   2.400 -	
   2.401 -	return 0;
   2.402 -}
   2.403 -
   2.404 -/*
   2.405 - * Enable an interrupt on the SAL console device.
   2.406 - */
   2.407 -static inline void
   2.408 -ia64_sn_console_intr_enable(u64 intr)
   2.409 -{
   2.410 -	struct ia64_sal_retval ret_stuff;
   2.411 -
   2.412 -	ret_stuff.status = 0;
   2.413 -	ret_stuff.v0 = 0;
   2.414 -	ret_stuff.v1 = 0;
   2.415 -	ret_stuff.v2 = 0;
   2.416 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR, 
   2.417 -		 intr, SAL_CONSOLE_INTR_ON,
   2.418 -		 0, 0, 0, 0, 0);
   2.419 -}
   2.420 -
   2.421 -/*
   2.422 - * Disable an interrupt on the SAL console device.
   2.423 - */
   2.424 -static inline void
   2.425 -ia64_sn_console_intr_disable(u64 intr)
   2.426 -{
   2.427 -	struct ia64_sal_retval ret_stuff;
   2.428 -
   2.429 -	ret_stuff.status = 0;
   2.430 -	ret_stuff.v0 = 0;
   2.431 -	ret_stuff.v1 = 0;
   2.432 -	ret_stuff.v2 = 0;
   2.433 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR, 
   2.434 -		 intr, SAL_CONSOLE_INTR_OFF,
   2.435 -		 0, 0, 0, 0, 0);
   2.436 -}
   2.437 -
   2.438 -/*
   2.439 - * Sends a character buffer to the console asynchronously.
   2.440 - */
   2.441 -static inline u64
   2.442 -ia64_sn_console_xmit_chars(char *buf, int len)
   2.443 -{
   2.444 -	struct ia64_sal_retval ret_stuff;
   2.445 -
   2.446 -	ret_stuff.status = 0;
   2.447 -	ret_stuff.v0 = 0;
   2.448 -	ret_stuff.v1 = 0;
   2.449 -	ret_stuff.v2 = 0;
   2.450 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_XMIT_CHARS,
   2.451 -		 (u64)buf, (u64)len,
   2.452 -		 0, 0, 0, 0, 0);
   2.453 -
   2.454 -	if (ret_stuff.status == 0) {
   2.455 -	    return ret_stuff.v0;
   2.456 -	}
   2.457 -
   2.458 -	return 0;
   2.459 -}
   2.460 -
   2.461 -/*
   2.462 - * Returns the iobrick module Id
   2.463 - */
   2.464 -static inline u64
   2.465 -ia64_sn_sysctl_iobrick_module_get(nasid_t nasid, int *result)
   2.466 -{
   2.467 -	struct ia64_sal_retval ret_stuff;
   2.468 -
   2.469 -	ret_stuff.status = 0;
   2.470 -	ret_stuff.v0 = 0;
   2.471 -	ret_stuff.v1 = 0;
   2.472 -	ret_stuff.v2 = 0;
   2.473 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYSCTL_IOBRICK_MODULE_GET, nasid, 0, 0, 0, 0, 0, 0);
   2.474 -
   2.475 -	/* result is in 'v0' */
   2.476 -	*result = (int)ret_stuff.v0;
   2.477 -
   2.478 -	return ret_stuff.status;
   2.479 -}
   2.480 -
   2.481 -/**
   2.482 - * ia64_sn_pod_mode - call the SN_SAL_POD_MODE function
   2.483 - *
   2.484 - * SN_SAL_POD_MODE actually takes an argument, but it's always
   2.485 - * 0 when we call it from the kernel, so we don't have to expose
   2.486 - * it to the caller.
   2.487 - */
   2.488 -static inline u64
   2.489 -ia64_sn_pod_mode(void)
   2.490 -{
   2.491 -	struct ia64_sal_retval isrv;
   2.492 -	SAL_CALL_REENTRANT(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0);
   2.493 -	if (isrv.status)
   2.494 -		return 0;
   2.495 -	return isrv.v0;
   2.496 -}
   2.497 -
   2.498 -/**
   2.499 - * ia64_sn_probe_mem - read from memory safely
   2.500 - * @addr: address to probe
   2.501 - * @size: number bytes to read (1,2,4,8)
   2.502 - * @data_ptr: address to store value read by probe (-1 returned if probe fails)
   2.503 - *
   2.504 - * Call into the SAL to do a memory read.  If the read generates a machine
   2.505 - * check, this routine will recover gracefully and return -1 to the caller.
   2.506 - * @addr is usually a kernel virtual address in uncached space (i.e. the
   2.507 - * address starts with 0xc), but if called in physical mode, @addr should
   2.508 - * be a physical address.
   2.509 - *
   2.510 - * Return values:
   2.511 - *  0 - probe successful
   2.512 - *  1 - probe failed (generated MCA)
   2.513 - *  2 - Bad arg
   2.514 - * <0 - PAL error
   2.515 - */
   2.516 -static inline u64
   2.517 -ia64_sn_probe_mem(long addr, long size, void *data_ptr)
   2.518 -{
   2.519 -	struct ia64_sal_retval isrv;
   2.520 -
   2.521 -	SAL_CALL(isrv, SN_SAL_PROBE, addr, size, 0, 0, 0, 0, 0);
   2.522 -
   2.523 -	if (data_ptr) {
   2.524 -		switch (size) {
   2.525 -		case 1:
   2.526 -			*((u8*)data_ptr) = (u8)isrv.v0;
   2.527 -			break;
   2.528 -		case 2:
   2.529 -			*((u16*)data_ptr) = (u16)isrv.v0;
   2.530 -			break;
   2.531 -		case 4:
   2.532 -			*((u32*)data_ptr) = (u32)isrv.v0;
   2.533 -			break;
   2.534 -		case 8:
   2.535 -			*((u64*)data_ptr) = (u64)isrv.v0;
   2.536 -			break;
   2.537 -		default:
   2.538 -			isrv.status = 2;
   2.539 -		}
   2.540 -	}
   2.541 -	return isrv.status;
   2.542 -}
   2.543 -
   2.544 -/*
   2.545 - * Retrieve the system serial number as an ASCII string.
   2.546 - */
   2.547 -static inline u64
   2.548 -ia64_sn_sys_serial_get(char *buf)
   2.549 -{
   2.550 -	struct ia64_sal_retval ret_stuff;
   2.551 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYS_SERIAL_GET, buf, 0, 0, 0, 0, 0, 0);
   2.552 -	return ret_stuff.status;
   2.553 -}
   2.554 -
   2.555 -extern char sn_system_serial_number_string[];
   2.556 -extern u64 sn_partition_serial_number;
   2.557 -
   2.558 -static inline char *
   2.559 -sn_system_serial_number(void) {
   2.560 -	if (sn_system_serial_number_string[0]) {
   2.561 -		return(sn_system_serial_number_string);
   2.562 -	} else {
   2.563 -		ia64_sn_sys_serial_get(sn_system_serial_number_string);
   2.564 -		return(sn_system_serial_number_string);
   2.565 -	}
   2.566 -}
   2.567 -	
   2.568 -
   2.569 -/*
   2.570 - * Returns a unique id number for this system and partition (suitable for
   2.571 - * use with license managers), based in part on the system serial number.
   2.572 - */
   2.573 -static inline u64
   2.574 -ia64_sn_partition_serial_get(void)
   2.575 -{
   2.576 -	struct ia64_sal_retval ret_stuff;
   2.577 -	ia64_sal_oemcall_reentrant(&ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0,
   2.578 -				   0, 0, 0, 0, 0, 0);
   2.579 -	if (ret_stuff.status != 0)
   2.580 -	    return 0;
   2.581 -	return ret_stuff.v0;
   2.582 -}
   2.583 -
   2.584 -static inline u64
   2.585 -sn_partition_serial_number_val(void) {
   2.586 -	if (unlikely(sn_partition_serial_number == 0)) {
   2.587 -		sn_partition_serial_number = ia64_sn_partition_serial_get();
   2.588 -	}
   2.589 -	return sn_partition_serial_number;
   2.590 -}
   2.591 -
   2.592 -/*
   2.593 - * Returns the partition id of the nasid passed in as an argument,
   2.594 - * or INVALID_PARTID if the partition id cannot be retrieved.
   2.595 - */
   2.596 -static inline partid_t
   2.597 -ia64_sn_sysctl_partition_get(nasid_t nasid)
   2.598 -{
   2.599 -	struct ia64_sal_retval ret_stuff;
   2.600 -	SAL_CALL(ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid,
   2.601 -		0, 0, 0, 0, 0, 0);
   2.602 -	if (ret_stuff.status != 0)
   2.603 -	    return -1;
   2.604 -	return ((partid_t)ret_stuff.v0);
   2.605 -}
   2.606 -
   2.607 -/*
   2.608 - * Returns the physical address of the partition's reserved page through
   2.609 - * an iterative number of calls.
   2.610 - *
   2.611 - * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
   2.612 - * set to the nasid of the partition whose reserved page's address is
   2.613 - * being sought.
   2.614 - * On subsequent calls, pass the values, that were passed back on the
   2.615 - * previous call.
   2.616 - *
   2.617 - * While the return status equals SALRET_MORE_PASSES, keep calling
   2.618 - * this function after first copying 'len' bytes starting at 'addr'
   2.619 - * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
   2.620 - * be the physical address of the partition's reserved page. If the
   2.621 - * return status equals neither of these, an error as occurred.
   2.622 - */
   2.623 -static inline s64
   2.624 -sn_partition_reserved_page_pa(u64 buf, u64 *cookie, u64 *addr, u64 *len)
   2.625 -{
   2.626 -	struct ia64_sal_retval rv;
   2.627 -	ia64_sal_oemcall_reentrant(&rv, SN_SAL_GET_PARTITION_ADDR, *cookie,
   2.628 -				   *addr, buf, *len, 0, 0, 0);
   2.629 -	*cookie = rv.v0;
   2.630 -	*addr = rv.v1;
   2.631 -	*len = rv.v2;
   2.632 -	return rv.status;
   2.633 -}
   2.634 -
   2.635 -/*
   2.636 - * Register or unregister a physical address range being referenced across
   2.637 - * a partition boundary for which certain SAL errors should be scanned for,
   2.638 - * cleaned up and ignored.  This is of value for kernel partitioning code only.
   2.639 - * Values for the operation argument:
   2.640 - *	1 = register this address range with SAL
   2.641 - *	0 = unregister this address range with SAL
   2.642 - * 
   2.643 - * SAL maintains a reference count on an address range in case it is registered
   2.644 - * multiple times.
   2.645 - * 
   2.646 - * On success, returns the reference count of the address range after the SAL
   2.647 - * call has performed the current registration/unregistration.  Returns a
   2.648 - * negative value if an error occurred.
   2.649 - */
   2.650 -static inline int
   2.651 -sn_register_xp_addr_region(u64 paddr, u64 len, int operation)
   2.652 -{
   2.653 -	struct ia64_sal_retval ret_stuff;
   2.654 -	ia64_sal_oemcall(&ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len,
   2.655 -			 (u64)operation, 0, 0, 0, 0);
   2.656 -	return ret_stuff.status;
   2.657 -}
   2.658 -
   2.659 -/*
   2.660 - * Register or unregister an instruction range for which SAL errors should
   2.661 - * be ignored.  If an error occurs while in the registered range, SAL jumps
   2.662 - * to return_addr after ignoring the error.  Values for the operation argument:
   2.663 - *	1 = register this instruction range with SAL
   2.664 - *	0 = unregister this instruction range with SAL
   2.665 - *
   2.666 - * Returns 0 on success, or a negative value if an error occurred.
   2.667 - */
   2.668 -static inline int
   2.669 -sn_register_nofault_code(u64 start_addr, u64 end_addr, u64 return_addr,
   2.670 -			 int virtual, int operation)
   2.671 -{
   2.672 -	struct ia64_sal_retval ret_stuff;
   2.673 -	u64 call;
   2.674 -	if (virtual) {
   2.675 -		call = SN_SAL_NO_FAULT_ZONE_VIRTUAL;
   2.676 -	} else {
   2.677 -		call = SN_SAL_NO_FAULT_ZONE_PHYSICAL;
   2.678 -	}
   2.679 -	ia64_sal_oemcall(&ret_stuff, call, start_addr, end_addr, return_addr,
   2.680 -			 (u64)1, 0, 0, 0);
   2.681 -	return ret_stuff.status;
   2.682 -}
   2.683 -
   2.684 -/*
   2.685 - * Change or query the coherence domain for this partition. Each cpu-based
   2.686 - * nasid is represented by a bit in an array of 64-bit words:
   2.687 - *      0 = not in this partition's coherency domain
   2.688 - *      1 = in this partition's coherency domain
   2.689 - *
   2.690 - * It is not possible for the local system's nasids to be removed from
   2.691 - * the coherency domain.  Purpose of the domain arguments:
   2.692 - *      new_domain = set the coherence domain to the given nasids
   2.693 - *      old_domain = return the current coherence domain
   2.694 - *
   2.695 - * Returns 0 on success, or a negative value if an error occurred.
   2.696 - */
   2.697 -static inline int
   2.698 -sn_change_coherence(u64 *new_domain, u64 *old_domain)
   2.699 -{
   2.700 -	struct ia64_sal_retval ret_stuff;
   2.701 -	ia64_sal_oemcall(&ret_stuff, SN_SAL_COHERENCE, (u64)new_domain,
   2.702 -			 (u64)old_domain, 0, 0, 0, 0, 0);
   2.703 -	return ret_stuff.status;
   2.704 -}
   2.705 -
   2.706 -/*
   2.707 - * Change memory access protections for a physical address range.
   2.708 - * nasid_array is not used on Altix, but may be in future architectures.
   2.709 - * Available memory protection access classes are defined after the function.
   2.710 - */
   2.711 -static inline int
   2.712 -sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
   2.713 -{
   2.714 -	struct ia64_sal_retval ret_stuff;
   2.715 -
   2.716 -	ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_MEMPROTECT, paddr, len,
   2.717 -				(u64)nasid_array, perms, 0, 0, 0);
   2.718 -	return ret_stuff.status;
   2.719 -}
   2.720 -#define SN_MEMPROT_ACCESS_CLASS_0		0x14a080
   2.721 -#define SN_MEMPROT_ACCESS_CLASS_1		0x2520c2
   2.722 -#define SN_MEMPROT_ACCESS_CLASS_2		0x14a1ca
   2.723 -#define SN_MEMPROT_ACCESS_CLASS_3		0x14a290
   2.724 -#define SN_MEMPROT_ACCESS_CLASS_6		0x084080
   2.725 -#define SN_MEMPROT_ACCESS_CLASS_7		0x021080
   2.726 -
   2.727 -/*
   2.728 - * Turns off system power.
   2.729 - */
   2.730 -static inline void
   2.731 -ia64_sn_power_down(void)
   2.732 -{
   2.733 -	struct ia64_sal_retval ret_stuff;
   2.734 -	SAL_CALL(ret_stuff, SN_SAL_SYSTEM_POWER_DOWN, 0, 0, 0, 0, 0, 0, 0);
   2.735 -	while(1)
   2.736 -		cpu_relax();
   2.737 -	/* never returns */
   2.738 -}
   2.739 -
   2.740 -/**
   2.741 - * ia64_sn_fru_capture - tell the system controller to capture hw state
   2.742 - *
   2.743 - * This routine will call the SAL which will tell the system controller(s)
   2.744 - * to capture hw mmr information from each SHub in the system.
   2.745 - */
   2.746 -static inline u64
   2.747 -ia64_sn_fru_capture(void)
   2.748 -{
   2.749 -        struct ia64_sal_retval isrv;
   2.750 -        SAL_CALL(isrv, SN_SAL_SYSCTL_FRU_CAPTURE, 0, 0, 0, 0, 0, 0, 0);
   2.751 -        if (isrv.status)
   2.752 -                return 0;
   2.753 -        return isrv.v0;
   2.754 -}
   2.755 -
   2.756 -/*
   2.757 - * Performs an operation on a PCI bus or slot -- power up, power down
   2.758 - * or reset.
   2.759 - */
   2.760 -static inline u64
   2.761 -ia64_sn_sysctl_iobrick_pci_op(nasid_t n, u64 connection_type, 
   2.762 -			      u64 bus, char slot, 
   2.763 -			      u64 action)
   2.764 -{
   2.765 -	struct ia64_sal_retval rv = {0, 0, 0, 0};
   2.766 -
   2.767 -	SAL_CALL_NOLOCK(rv, SN_SAL_SYSCTL_IOBRICK_PCI_OP, connection_type, n, action,
   2.768 -		 bus, (u64) slot, 0, 0);
   2.769 -	if (rv.status)
   2.770 -	    	return rv.v0;
   2.771 -	return 0;
   2.772 -}
   2.773 -
   2.774 -
   2.775 -/*
   2.776 - * Open a subchannel for sending arbitrary data to the system
   2.777 - * controller network via the system controller device associated with
   2.778 - * 'nasid'.  Return the subchannel number or a negative error code.
   2.779 - */
   2.780 -static inline int
   2.781 -ia64_sn_irtr_open(nasid_t nasid)
   2.782 -{
   2.783 -	struct ia64_sal_retval rv;
   2.784 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_OPEN, nasid,
   2.785 -			   0, 0, 0, 0, 0);
   2.786 -	return (int) rv.v0;
   2.787 -}
   2.788 -
   2.789 -/*
   2.790 - * Close system controller subchannel 'subch' previously opened on 'nasid'.
   2.791 - */
   2.792 -static inline int
   2.793 -ia64_sn_irtr_close(nasid_t nasid, int subch)
   2.794 -{
   2.795 -	struct ia64_sal_retval rv;
   2.796 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_CLOSE,
   2.797 -			   (u64) nasid, (u64) subch, 0, 0, 0, 0);
   2.798 -	return (int) rv.status;
   2.799 -}
   2.800 -
   2.801 -/*
   2.802 - * Read data from system controller associated with 'nasid' on
   2.803 - * subchannel 'subch'.  The buffer to be filled is pointed to by
   2.804 - * 'buf', and its capacity is in the integer pointed to by 'len'.  The
   2.805 - * referent of 'len' is set to the number of bytes read by the SAL
   2.806 - * call.  The return value is either SALRET_OK (for bytes read) or
   2.807 - * SALRET_ERROR (for error or "no data available").
   2.808 - */
   2.809 -static inline int
   2.810 -ia64_sn_irtr_recv(nasid_t nasid, int subch, char *buf, int *len)
   2.811 -{
   2.812 -	struct ia64_sal_retval rv;
   2.813 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_RECV,
   2.814 -			   (u64) nasid, (u64) subch, (u64) buf, (u64) len,
   2.815 -			   0, 0);
   2.816 -	return (int) rv.status;
   2.817 -}
   2.818 -
   2.819 -/*
   2.820 - * Write data to the system controller network via the system
   2.821 - * controller associated with 'nasid' on suchannel 'subch'.  The
   2.822 - * buffer to be written out is pointed to by 'buf', and 'len' is the
   2.823 - * number of bytes to be written.  The return value is either the
   2.824 - * number of bytes written (which could be zero) or a negative error
   2.825 - * code.
   2.826 - */
   2.827 -static inline int
   2.828 -ia64_sn_irtr_send(nasid_t nasid, int subch, char *buf, int len)
   2.829 -{
   2.830 -	struct ia64_sal_retval rv;
   2.831 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_SEND,
   2.832 -			   (u64) nasid, (u64) subch, (u64) buf, (u64) len,
   2.833 -			   0, 0);
   2.834 -	return (int) rv.v0;
   2.835 -}
   2.836 -
   2.837 -/*
   2.838 - * Check whether any interrupts are pending for the system controller
   2.839 - * associated with 'nasid' and its subchannel 'subch'.  The return
   2.840 - * value is a mask of pending interrupts (SAL_IROUTER_INTR_XMIT and/or
   2.841 - * SAL_IROUTER_INTR_RECV).
   2.842 - */
   2.843 -static inline int
   2.844 -ia64_sn_irtr_intr(nasid_t nasid, int subch)
   2.845 -{
   2.846 -	struct ia64_sal_retval rv;
   2.847 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_STATUS,
   2.848 -			   (u64) nasid, (u64) subch, 0, 0, 0, 0);
   2.849 -	return (int) rv.v0;
   2.850 -}
   2.851 -
   2.852 -/*
   2.853 - * Enable the interrupt indicated by the intr parameter (either
   2.854 - * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
   2.855 - */
   2.856 -static inline int
   2.857 -ia64_sn_irtr_intr_enable(nasid_t nasid, int subch, u64 intr)
   2.858 -{
   2.859 -	struct ia64_sal_retval rv;
   2.860 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_ON,
   2.861 -			   (u64) nasid, (u64) subch, intr, 0, 0, 0);
   2.862 -	return (int) rv.v0;
   2.863 -}
   2.864 -
   2.865 -/*
   2.866 - * Disable the interrupt indicated by the intr parameter (either
   2.867 - * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
   2.868 - */
   2.869 -static inline int
   2.870 -ia64_sn_irtr_intr_disable(nasid_t nasid, int subch, u64 intr)
   2.871 -{
   2.872 -	struct ia64_sal_retval rv;
   2.873 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_OFF,
   2.874 -			   (u64) nasid, (u64) subch, intr, 0, 0, 0);
   2.875 -	return (int) rv.v0;
   2.876 -}
   2.877 -
   2.878 -/*
   2.879 - * Set up a node as the point of contact for system controller
   2.880 - * environmental event delivery.
   2.881 - */
   2.882 -static inline int
   2.883 -ia64_sn_sysctl_event_init(nasid_t nasid)
   2.884 -{
   2.885 -        struct ia64_sal_retval rv;
   2.886 -        SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_EVENT, (u64) nasid,
   2.887 -			   0, 0, 0, 0, 0, 0);
   2.888 -        return (int) rv.v0;
   2.889 -}
   2.890 -
   2.891 -/*
   2.892 - * Ask the system controller on the specified nasid to reset
   2.893 - * the CX corelet clock.  Only valid on TIO nodes.
   2.894 - */
   2.895 -static inline int
   2.896 -ia64_sn_sysctl_tio_clock_reset(nasid_t nasid)
   2.897 -{
   2.898 -	struct ia64_sal_retval rv;
   2.899 -	SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_TIO_JLCK_RST,
   2.900 -			nasid, 0, 0, 0, 0, 0);
   2.901 -	if (rv.status != 0)
   2.902 -		return (int)rv.status;
   2.903 -	if (rv.v0 != 0)
   2.904 -		return (int)rv.v0;
   2.905 -
   2.906 -	return 0;
   2.907 -}
   2.908 -
   2.909 -/*
   2.910 - * Get the associated ioboard type for a given nasid.
   2.911 - */
   2.912 -static inline s64
   2.913 -ia64_sn_sysctl_ioboard_get(nasid_t nasid, u16 *ioboard)
   2.914 -{
   2.915 -	struct ia64_sal_retval isrv;
   2.916 -	SAL_CALL_REENTRANT(isrv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_IOBOARD,
   2.917 -			   nasid, 0, 0, 0, 0, 0);
   2.918 -	if (isrv.v0 != 0) {
   2.919 -		*ioboard = isrv.v0;
   2.920 -		return isrv.status;
   2.921 -	}
   2.922 -	if (isrv.v1 != 0) {
   2.923 -		*ioboard = isrv.v1;
   2.924 -		return isrv.status;
   2.925 -	}
   2.926 -
   2.927 -	return isrv.status;
   2.928 -}
   2.929 -
   2.930 -/**
   2.931 - * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
   2.932 - * @nasid: NASID of node to read
   2.933 - * @index: FIT entry index to be retrieved (0..n)
   2.934 - * @fitentry: 16 byte buffer where FIT entry will be stored.
   2.935 - * @banbuf: optional buffer for retrieving banner
   2.936 - * @banlen: length of banner buffer
   2.937 - *
   2.938 - * Access to the physical PROM chips needs to be serialized since reads and
   2.939 - * writes can't occur at the same time, so we need to call into the SAL when
   2.940 - * we want to look at the FIT entries on the chips.
   2.941 - *
   2.942 - * Returns:
   2.943 - *	%SALRET_OK if ok
   2.944 - *	%SALRET_INVALID_ARG if index too big
   2.945 - *	%SALRET_NOT_IMPLEMENTED if running on older PROM
   2.946 - *	??? if nasid invalid OR banner buffer not large enough
   2.947 - */
   2.948 -static inline int
   2.949 -ia64_sn_get_fit_compt(u64 nasid, u64 index, void *fitentry, void *banbuf,
   2.950 -		      u64 banlen)
   2.951 -{
   2.952 -	struct ia64_sal_retval rv;
   2.953 -	SAL_CALL_NOLOCK(rv, SN_SAL_GET_FIT_COMPT, nasid, index, fitentry,
   2.954 -			banbuf, banlen, 0, 0);
   2.955 -	return (int) rv.status;
   2.956 -}
   2.957 -
   2.958 -/*
   2.959 - * Initialize the SAL components of the system controller
   2.960 - * communication driver; specifically pass in a sizable buffer that
   2.961 - * can be used for allocation of subchannel queues as new subchannels
   2.962 - * are opened.  "buf" points to the buffer, and "len" specifies its
   2.963 - * length.
   2.964 - */
   2.965 -static inline int
   2.966 -ia64_sn_irtr_init(nasid_t nasid, void *buf, int len)
   2.967 -{
   2.968 -	struct ia64_sal_retval rv;
   2.969 -	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INIT,
   2.970 -			   (u64) nasid, (u64) buf, (u64) len, 0, 0, 0);
   2.971 -	return (int) rv.status;
   2.972 -}
   2.973 -
   2.974 -/*
   2.975 - * Returns the nasid, subnode & slice corresponding to a SAPIC ID
   2.976 - *
   2.977 - *  In:
   2.978 - *	arg0 - SN_SAL_GET_SAPIC_INFO
   2.979 - *	arg1 - sapicid (lid >> 16) 
   2.980 - *  Out:
   2.981 - *	v0 - nasid
   2.982 - *	v1 - subnode
   2.983 - *	v2 - slice
   2.984 - */
   2.985 -static inline u64
   2.986 -ia64_sn_get_sapic_info(int sapicid, int *nasid, int *subnode, int *slice)
   2.987 -{
   2.988 -	struct ia64_sal_retval ret_stuff;
   2.989 -
   2.990 -	ret_stuff.status = 0;
   2.991 -	ret_stuff.v0 = 0;
   2.992 -	ret_stuff.v1 = 0;
   2.993 -	ret_stuff.v2 = 0;
   2.994 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SAPIC_INFO, sapicid, 0, 0, 0, 0, 0, 0);
   2.995 -
   2.996 -/***** BEGIN HACK - temp til old proms no longer supported ********/
   2.997 -	if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
   2.998 -		if (nasid) *nasid = sapicid & 0xfff;
   2.999 -		if (subnode) *subnode = (sapicid >> 13) & 1;
  2.1000 -		if (slice) *slice = (sapicid >> 12) & 3;
  2.1001 -		return 0;
  2.1002 -	}
  2.1003 -/***** END HACK *******/
  2.1004 -
  2.1005 -	if (ret_stuff.status < 0)
  2.1006 -		return ret_stuff.status;
  2.1007 -
  2.1008 -	if (nasid) *nasid = (int) ret_stuff.v0;
  2.1009 -	if (subnode) *subnode = (int) ret_stuff.v1;
  2.1010 -	if (slice) *slice = (int) ret_stuff.v2;
  2.1011 -	return 0;
  2.1012 -}
  2.1013 - 
  2.1014 -/*
  2.1015 - * Returns information about the HUB/SHUB.
  2.1016 - *  In:
  2.1017 - *	arg0 - SN_SAL_GET_SN_INFO
  2.1018 - * 	arg1 - 0 (other values reserved for future use)
  2.1019 - *  Out:
  2.1020 - *	v0 
  2.1021 - *		[7:0]   - shub type (0=shub1, 1=shub2)
  2.1022 - *		[15:8]  - Log2 max number of nodes in entire system (includes
  2.1023 - *			  C-bricks, I-bricks, etc)
  2.1024 - *		[23:16] - Log2 of nodes per sharing domain			 
  2.1025 - * 		[31:24] - partition ID
  2.1026 - * 		[39:32] - coherency_id
  2.1027 - * 		[47:40] - regionsize
  2.1028 - *	v1 
  2.1029 - *		[15:0]  - nasid mask (ex., 0x7ff for 11 bit nasid)
  2.1030 - *	 	[23:15] - bit position of low nasid bit
  2.1031 - */
  2.1032 -static inline u64
  2.1033 -ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift, 
  2.1034 -		u8 *systemsize, u8 *sharing_domain_size, u8 *partid, u8 *coher, u8 *reg)
  2.1035 -{
  2.1036 -	struct ia64_sal_retval ret_stuff;
  2.1037 -
  2.1038 -	ret_stuff.status = 0;
  2.1039 -	ret_stuff.v0 = 0;
  2.1040 -	ret_stuff.v1 = 0;
  2.1041 -	ret_stuff.v2 = 0;
  2.1042 -	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SN_INFO, fc, 0, 0, 0, 0, 0, 0);
  2.1043 -
  2.1044 -/***** BEGIN HACK - temp til old proms no longer supported ********/
  2.1045 -	if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
  2.1046 -		int nasid = get_sapicid() & 0xfff;
  2.1047 -#define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL
  2.1048 -#define SH_SHUB_ID_NODES_PER_BIT_SHFT 48
  2.1049 -		if (shubtype) *shubtype = 0;
  2.1050 -		if (nasid_bitmask) *nasid_bitmask = 0x7ff;
  2.1051 -		if (nasid_shift) *nasid_shift = 38;
  2.1052 -		if (systemsize) *systemsize = 10;
  2.1053 -		if (sharing_domain_size) *sharing_domain_size = 8;
  2.1054 -		if (partid) *partid = ia64_sn_sysctl_partition_get(nasid);
  2.1055 -		if (coher) *coher = nasid >> 9;
  2.1056 -		if (reg) *reg = (HUB_L((u64 *) LOCAL_MMR_ADDR(SH1_SHUB_ID)) & SH_SHUB_ID_NODES_PER_BIT_MASK) >>
  2.1057 -			SH_SHUB_ID_NODES_PER_BIT_SHFT;
  2.1058 -		return 0;
  2.1059 -	}
  2.1060 -/***** END HACK *******/
  2.1061 -
  2.1062 -	if (ret_stuff.status < 0)
  2.1063 -		return ret_stuff.status;
  2.1064 -
  2.1065 -	if (shubtype) *shubtype = ret_stuff.v0 & 0xff;
  2.1066 -	if (systemsize) *systemsize = (ret_stuff.v0 >> 8) & 0xff;
  2.1067 -	if (sharing_domain_size) *sharing_domain_size = (ret_stuff.v0 >> 16) & 0xff;
  2.1068 -	if (partid) *partid = (ret_stuff.v0 >> 24) & 0xff;
  2.1069 -	if (coher) *coher = (ret_stuff.v0 >> 32) & 0xff;
  2.1070 -	if (reg) *reg = (ret_stuff.v0 >> 40) & 0xff;
  2.1071 -	if (nasid_bitmask) *nasid_bitmask = (ret_stuff.v1 & 0xffff);
  2.1072 -	if (nasid_shift) *nasid_shift = (ret_stuff.v1 >> 16) & 0xff;
  2.1073 -	return 0;
  2.1074 -}
  2.1075 - 
  2.1076 -/*
  2.1077 - * This is the access point to the Altix PROM hardware performance
  2.1078 - * and status monitoring interface. For info on using this, see
  2.1079 - * include/asm-ia64/sn/sn2/sn_hwperf.h
  2.1080 - */
  2.1081 -static inline int
  2.1082 -ia64_sn_hwperf_op(nasid_t nasid, u64 opcode, u64 a0, u64 a1, u64 a2,
  2.1083 -                  u64 a3, u64 a4, int *v0)
  2.1084 -{
  2.1085 -	struct ia64_sal_retval rv;
  2.1086 -	SAL_CALL_NOLOCK(rv, SN_SAL_HWPERF_OP, (u64)nasid,
  2.1087 -		opcode, a0, a1, a2, a3, a4);
  2.1088 -	if (v0)
  2.1089 -		*v0 = (int) rv.v0;
  2.1090 -	return (int) rv.status;
  2.1091 -}
  2.1092 -#endif /* !XEN */
  2.1093 -
  2.1094 -static inline int
  2.1095 -ia64_sn_ioif_get_pci_topology(u64 buf, u64 len)
  2.1096 -{
  2.1097 -	struct ia64_sal_retval rv;
  2.1098 -	SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY, buf, len, 0, 0, 0, 0, 0);
  2.1099 -	return (int) rv.status;
  2.1100 -}
  2.1101 -
  2.1102 -/*
  2.1103 - * BTE error recovery is implemented in SAL
  2.1104 - */
  2.1105 -static inline int
  2.1106 -ia64_sn_bte_recovery(nasid_t nasid)
  2.1107 -{
  2.1108 -	struct ia64_sal_retval rv;
  2.1109 -
  2.1110 -	rv.status = 0;
  2.1111 -	SAL_CALL_NOLOCK(rv, SN_SAL_BTE_RECOVER, (u64)nasid, 0, 0, 0, 0, 0, 0);
  2.1112 -	if (rv.status == SALRET_NOT_IMPLEMENTED)
  2.1113 -		return 0;
  2.1114 -	return (int) rv.status;
  2.1115 -}
  2.1116 -
  2.1117 -static inline int
  2.1118 -ia64_sn_is_fake_prom(void)
  2.1119 -{
  2.1120 -	struct ia64_sal_retval rv;
  2.1121 -	SAL_CALL_NOLOCK(rv, SN_SAL_FAKE_PROM, 0, 0, 0, 0, 0, 0, 0);
  2.1122 -	return (rv.status == 0);
  2.1123 -}
  2.1124 -
  2.1125 -static inline int
  2.1126 -ia64_sn_get_prom_feature_set(int set, unsigned long *feature_set)
  2.1127 -{
  2.1128 -	struct ia64_sal_retval rv;
  2.1129 -
  2.1130 -	SAL_CALL_NOLOCK(rv, SN_SAL_GET_PROM_FEATURE_SET, set, 0, 0, 0, 0, 0, 0);
  2.1131 -	if (rv.status != 0)
  2.1132 -		return rv.status;
  2.1133 -	*feature_set = rv.v0;
  2.1134 -	return 0;
  2.1135 -}
  2.1136 -
  2.1137 -static inline int
  2.1138 -ia64_sn_set_os_feature(int feature)
  2.1139 -{
  2.1140 -	struct ia64_sal_retval rv;
  2.1141 -
  2.1142 -	SAL_CALL_NOLOCK(rv, SN_SAL_SET_OS_FEATURE_SET, feature, 0, 0, 0, 0, 0, 0);
  2.1143 -	return rv.status;
  2.1144 -}
  2.1145 -
  2.1146 -static inline int
  2.1147 -sn_inject_error(u64 paddr, u64 *data, u64 *ecc)
  2.1148 -{
  2.1149 -	struct ia64_sal_retval ret_stuff;
  2.1150 -
  2.1151 -	ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_INJECT_ERROR, paddr, (u64)data,
  2.1152 -				(u64)ecc, 0, 0, 0, 0);
  2.1153 -	return ret_stuff.status;
  2.1154 -}
  2.1155 -
  2.1156 -static inline int
  2.1157 -ia64_sn_set_cpu_number(int cpu)
  2.1158 -{
  2.1159 -	struct ia64_sal_retval rv;
  2.1160 -
  2.1161 -	SAL_CALL_NOLOCK(rv, SN_SAL_SET_CPU_NUMBER, cpu, 0, 0, 0, 0, 0, 0);
  2.1162 -	return rv.status;
  2.1163 -}
  2.1164 -#endif /* _ASM_IA64_SN_SN_SAL_H */
     3.1 --- a/xen/include/asm-ia64/linux/asm/sn/README.origin	Wed Dec 13 15:23:28 2006 -0700
     3.2 +++ b/xen/include/asm-ia64/linux/asm/sn/README.origin	Thu Dec 14 11:01:37 2006 -0700
     3.3 @@ -18,6 +18,7 @@ shubio.h		-> linux/include/asm-ia64/sn/s
     3.4  simulator.h		-> linux/include/asm-ia64/sn/simulator.h
     3.5  sn_cpuid.h		-> linux/include/asm-ia64/sn/sn_cpuid.h
     3.6  sn_feature_sets.h	-> linux/include/asm-ia64/sn/sn_feature_sets.h
     3.7 +sn_sal.h		-> linux/include/asm-ia64/sn/sn_sal.h
     3.8  tiocp.h			-> linux/include/asm-ia64/sn/tiocp.h
     3.9  xbow.h			-> linux/arch/ia64/sn/include/xtalk/xbow.h
    3.10  xwidgetdev.h		-> linux/arch/ia64/sn/include/xtalk/xwidgetdev.h
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/xen/include/asm-ia64/linux/asm/sn/sn_sal.h	Thu Dec 14 11:01:37 2006 -0700
     4.3 @@ -0,0 +1,1157 @@
     4.4 +#ifndef _ASM_IA64_SN_SN_SAL_H
     4.5 +#define _ASM_IA64_SN_SN_SAL_H
     4.6 +
     4.7 +/*
     4.8 + * System Abstraction Layer definitions for IA64
     4.9 + *
    4.10 + * This file is subject to the terms and conditions of the GNU General Public
    4.11 + * License.  See the file "COPYING" in the main directory of this archive
    4.12 + * for more details.
    4.13 + *
    4.14 + * Copyright (c) 2000-2006 Silicon Graphics, Inc.  All rights reserved.
    4.15 + */
    4.16 +
    4.17 +
    4.18 +#include <asm/sal.h>
    4.19 +#include <asm/sn/sn_cpuid.h>
    4.20 +#include <asm/sn/arch.h>
    4.21 +#include <asm/sn/geo.h>
    4.22 +#include <asm/sn/nodepda.h>
    4.23 +#include <asm/sn/shub_mmr.h>
    4.24 +
    4.25 +// SGI Specific Calls
    4.26 +#define  SN_SAL_POD_MODE                           0x02000001
    4.27 +#define  SN_SAL_SYSTEM_RESET                       0x02000002
    4.28 +#define  SN_SAL_PROBE                              0x02000003
    4.29 +#define  SN_SAL_GET_MASTER_NASID                   0x02000004
    4.30 +#define	 SN_SAL_GET_KLCONFIG_ADDR		   0x02000005
    4.31 +#define  SN_SAL_LOG_CE				   0x02000006
    4.32 +#define  SN_SAL_REGISTER_CE			   0x02000007
    4.33 +#define  SN_SAL_GET_PARTITION_ADDR		   0x02000009
    4.34 +#define  SN_SAL_XP_ADDR_REGION			   0x0200000f
    4.35 +#define  SN_SAL_NO_FAULT_ZONE_VIRTUAL		   0x02000010
    4.36 +#define  SN_SAL_NO_FAULT_ZONE_PHYSICAL		   0x02000011
    4.37 +#define  SN_SAL_PRINT_ERROR			   0x02000012
    4.38 +#define  SN_SAL_SET_ERROR_HANDLING_FEATURES	   0x0200001a	// reentrant
    4.39 +#define  SN_SAL_GET_FIT_COMPT			   0x0200001b	// reentrant
    4.40 +#define  SN_SAL_GET_SAPIC_INFO                     0x0200001d
    4.41 +#define  SN_SAL_GET_SN_INFO                        0x0200001e
    4.42 +#define  SN_SAL_CONSOLE_PUTC                       0x02000021
    4.43 +#define  SN_SAL_CONSOLE_GETC                       0x02000022
    4.44 +#define  SN_SAL_CONSOLE_PUTS                       0x02000023
    4.45 +#define  SN_SAL_CONSOLE_GETS                       0x02000024
    4.46 +#define  SN_SAL_CONSOLE_GETS_TIMEOUT               0x02000025
    4.47 +#define  SN_SAL_CONSOLE_POLL                       0x02000026
    4.48 +#define  SN_SAL_CONSOLE_INTR                       0x02000027
    4.49 +#define  SN_SAL_CONSOLE_PUTB			   0x02000028
    4.50 +#define  SN_SAL_CONSOLE_XMIT_CHARS		   0x0200002a
    4.51 +#define  SN_SAL_CONSOLE_READC			   0x0200002b
    4.52 +#define  SN_SAL_SYSCTL_OP			   0x02000030
    4.53 +#define  SN_SAL_SYSCTL_MODID_GET	           0x02000031
    4.54 +#define  SN_SAL_SYSCTL_GET                         0x02000032
    4.55 +#define  SN_SAL_SYSCTL_IOBRICK_MODULE_GET          0x02000033
    4.56 +#define  SN_SAL_SYSCTL_IO_PORTSPEED_GET            0x02000035
    4.57 +#define  SN_SAL_SYSCTL_SLAB_GET                    0x02000036
    4.58 +#define  SN_SAL_BUS_CONFIG		   	   0x02000037
    4.59 +#define  SN_SAL_SYS_SERIAL_GET			   0x02000038
    4.60 +#define  SN_SAL_PARTITION_SERIAL_GET		   0x02000039
    4.61 +#define  SN_SAL_SYSCTL_PARTITION_GET               0x0200003a
    4.62 +#define  SN_SAL_SYSTEM_POWER_DOWN		   0x0200003b
    4.63 +#define  SN_SAL_GET_MASTER_BASEIO_NASID		   0x0200003c
    4.64 +#define  SN_SAL_COHERENCE                          0x0200003d
    4.65 +#define  SN_SAL_MEMPROTECT                         0x0200003e
    4.66 +#define  SN_SAL_SYSCTL_FRU_CAPTURE		   0x0200003f
    4.67 +
    4.68 +#define  SN_SAL_SYSCTL_IOBRICK_PCI_OP		   0x02000042	// reentrant
    4.69 +#define	 SN_SAL_IROUTER_OP			   0x02000043
    4.70 +#define  SN_SAL_SYSCTL_EVENT                       0x02000044
    4.71 +#define  SN_SAL_IOIF_INTERRUPT			   0x0200004a
    4.72 +#define  SN_SAL_HWPERF_OP			   0x02000050   // lock
    4.73 +#define  SN_SAL_IOIF_ERROR_INTERRUPT		   0x02000051
    4.74 +#define  SN_SAL_IOIF_PCI_SAFE			   0x02000052
    4.75 +#define  SN_SAL_IOIF_SLOT_ENABLE		   0x02000053
    4.76 +#define  SN_SAL_IOIF_SLOT_DISABLE		   0x02000054
    4.77 +#define  SN_SAL_IOIF_GET_HUBDEV_INFO		   0x02000055
    4.78 +#define  SN_SAL_IOIF_GET_PCIBUS_INFO		   0x02000056
    4.79 +#define  SN_SAL_IOIF_GET_PCIDEV_INFO		   0x02000057
    4.80 +#define  SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST	   0x02000058	// deprecated
    4.81 +#define  SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST	   0x0200005a
    4.82 +
    4.83 +#define SN_SAL_HUB_ERROR_INTERRUPT		   0x02000060
    4.84 +#define SN_SAL_BTE_RECOVER			   0x02000061
    4.85 +#define SN_SAL_RESERVED_DO_NOT_USE		   0x02000062
    4.86 +#define SN_SAL_IOIF_GET_PCI_TOPOLOGY		   0x02000064
    4.87 +
    4.88 +#define  SN_SAL_GET_PROM_FEATURE_SET		   0x02000065
    4.89 +#define  SN_SAL_SET_OS_FEATURE_SET		   0x02000066
    4.90 +#define  SN_SAL_INJECT_ERROR			   0x02000067
    4.91 +#define  SN_SAL_SET_CPU_NUMBER			   0x02000068
    4.92 +
    4.93 +/*
    4.94 + * Service-specific constants
    4.95 + */
    4.96 +
    4.97 +/* Console interrupt manipulation */
    4.98 +	/* action codes */
    4.99 +#define SAL_CONSOLE_INTR_OFF    0       /* turn the interrupt off */
   4.100 +#define SAL_CONSOLE_INTR_ON     1       /* turn the interrupt on */
   4.101 +#define SAL_CONSOLE_INTR_STATUS 2	/* retrieve the interrupt status */
   4.102 +	/* interrupt specification & status return codes */
   4.103 +#define SAL_CONSOLE_INTR_XMIT	1	/* output interrupt */
   4.104 +#define SAL_CONSOLE_INTR_RECV	2	/* input interrupt */
   4.105 +
   4.106 +/* interrupt handling */
   4.107 +#define SAL_INTR_ALLOC		1
   4.108 +#define SAL_INTR_FREE		2
   4.109 +
   4.110 +/*
   4.111 + * operations available on the generic SN_SAL_SYSCTL_OP
   4.112 + * runtime service
   4.113 + */
   4.114 +#define SAL_SYSCTL_OP_IOBOARD		0x0001  /*  retrieve board type */
   4.115 +#define SAL_SYSCTL_OP_TIO_JLCK_RST      0x0002  /* issue TIO clock reset */
   4.116 +
   4.117 +/*
   4.118 + * IRouter (i.e. generalized system controller) operations
   4.119 + */
   4.120 +#define SAL_IROUTER_OPEN	0	/* open a subchannel */
   4.121 +#define SAL_IROUTER_CLOSE	1	/* close a subchannel */
   4.122 +#define SAL_IROUTER_SEND	2	/* send part of an IRouter packet */
   4.123 +#define SAL_IROUTER_RECV	3	/* receive part of an IRouter packet */
   4.124 +#define SAL_IROUTER_INTR_STATUS	4	/* check the interrupt status for
   4.125 +					 * an open subchannel
   4.126 +					 */
   4.127 +#define SAL_IROUTER_INTR_ON	5	/* enable an interrupt */
   4.128 +#define SAL_IROUTER_INTR_OFF	6	/* disable an interrupt */
   4.129 +#define SAL_IROUTER_INIT	7	/* initialize IRouter driver */
   4.130 +
   4.131 +/* IRouter interrupt mask bits */
   4.132 +#define SAL_IROUTER_INTR_XMIT	SAL_CONSOLE_INTR_XMIT
   4.133 +#define SAL_IROUTER_INTR_RECV	SAL_CONSOLE_INTR_RECV
   4.134 +
   4.135 +/*
   4.136 + * Error Handling Features
   4.137 + */
   4.138 +#define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV	0x1	// obsolete
   4.139 +#define SAL_ERR_FEAT_LOG_SBES			0x2	// obsolete
   4.140 +#define SAL_ERR_FEAT_MFR_OVERRIDE		0x4
   4.141 +#define SAL_ERR_FEAT_SBE_THRESHOLD		0xffff0000
   4.142 +
   4.143 +/*
   4.144 + * SAL Error Codes
   4.145 + */
   4.146 +#define SALRET_MORE_PASSES	1
   4.147 +#define SALRET_OK		0
   4.148 +#define SALRET_NOT_IMPLEMENTED	(-1)
   4.149 +#define SALRET_INVALID_ARG	(-2)
   4.150 +#define SALRET_ERROR		(-3)
   4.151 +
   4.152 +#define SN_SAL_FAKE_PROM			   0x02009999
   4.153 +
   4.154 +/**
   4.155 +  * sn_sal_revision - get the SGI SAL revision number
   4.156 +  *
   4.157 +  * The SGI PROM stores its version in the sal_[ab]_rev_(major|minor).
   4.158 +  * This routine simply extracts the major and minor values and
   4.159 +  * presents them in a u32 format.
   4.160 +  *
   4.161 +  * For example, version 4.05 would be represented at 0x0405.
   4.162 +  */
   4.163 +static inline u32
   4.164 +sn_sal_rev(void)
   4.165 +{
   4.166 +	struct ia64_sal_systab *systab = __va(efi.sal_systab);
   4.167 +
   4.168 +	return (u32)(systab->sal_b_rev_major << 8 | systab->sal_b_rev_minor);
   4.169 +}
   4.170 +
   4.171 +/*
   4.172 + * Returns the master console nasid, if the call fails, return an illegal
   4.173 + * value.
   4.174 + */
   4.175 +static inline u64
   4.176 +ia64_sn_get_console_nasid(void)
   4.177 +{
   4.178 +	struct ia64_sal_retval ret_stuff;
   4.179 +
   4.180 +	ret_stuff.status = 0;
   4.181 +	ret_stuff.v0 = 0;
   4.182 +	ret_stuff.v1 = 0;
   4.183 +	ret_stuff.v2 = 0;
   4.184 +	SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_NASID, 0, 0, 0, 0, 0, 0, 0);
   4.185 +
   4.186 +	if (ret_stuff.status < 0)
   4.187 +		return ret_stuff.status;
   4.188 +
   4.189 +	/* Master console nasid is in 'v0' */
   4.190 +	return ret_stuff.v0;
   4.191 +}
   4.192 +
   4.193 +/*
   4.194 + * Returns the master baseio nasid, if the call fails, return an illegal
   4.195 + * value.
   4.196 + */
   4.197 +static inline u64
   4.198 +ia64_sn_get_master_baseio_nasid(void)
   4.199 +{
   4.200 +	struct ia64_sal_retval ret_stuff;
   4.201 +
   4.202 +	ret_stuff.status = 0;
   4.203 +	ret_stuff.v0 = 0;
   4.204 +	ret_stuff.v1 = 0;
   4.205 +	ret_stuff.v2 = 0;
   4.206 +	SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_BASEIO_NASID, 0, 0, 0, 0, 0, 0, 0);
   4.207 +
   4.208 +	if (ret_stuff.status < 0)
   4.209 +		return ret_stuff.status;
   4.210 +
   4.211 +	/* Master baseio nasid is in 'v0' */
   4.212 +	return ret_stuff.v0;
   4.213 +}
   4.214 +
   4.215 +static inline void *
   4.216 +ia64_sn_get_klconfig_addr(nasid_t nasid)
   4.217 +{
   4.218 +	struct ia64_sal_retval ret_stuff;
   4.219 +
   4.220 +	ret_stuff.status = 0;
   4.221 +	ret_stuff.v0 = 0;
   4.222 +	ret_stuff.v1 = 0;
   4.223 +	ret_stuff.v2 = 0;
   4.224 +	SAL_CALL(ret_stuff, SN_SAL_GET_KLCONFIG_ADDR, (u64)nasid, 0, 0, 0, 0, 0, 0);
   4.225 +	return ret_stuff.v0 ? __va(ret_stuff.v0) : NULL;
   4.226 +}
   4.227 +
   4.228 +/*
   4.229 + * Returns the next console character.
   4.230 + */
   4.231 +static inline u64
   4.232 +ia64_sn_console_getc(int *ch)
   4.233 +{
   4.234 +	struct ia64_sal_retval ret_stuff;
   4.235 +
   4.236 +	ret_stuff.status = 0;
   4.237 +	ret_stuff.v0 = 0;
   4.238 +	ret_stuff.v1 = 0;
   4.239 +	ret_stuff.v2 = 0;
   4.240 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_GETC, 0, 0, 0, 0, 0, 0, 0);
   4.241 +
   4.242 +	/* character is in 'v0' */
   4.243 +	*ch = (int)ret_stuff.v0;
   4.244 +
   4.245 +	return ret_stuff.status;
   4.246 +}
   4.247 +
   4.248 +/*
   4.249 + * Read a character from the SAL console device, after a previous interrupt
   4.250 + * or poll operation has given us to know that a character is available
   4.251 + * to be read.
   4.252 + */
   4.253 +static inline u64
   4.254 +ia64_sn_console_readc(void)
   4.255 +{
   4.256 +	struct ia64_sal_retval ret_stuff;
   4.257 +
   4.258 +	ret_stuff.status = 0;
   4.259 +	ret_stuff.v0 = 0;
   4.260 +	ret_stuff.v1 = 0;
   4.261 +	ret_stuff.v2 = 0;
   4.262 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_READC, 0, 0, 0, 0, 0, 0, 0);
   4.263 +
   4.264 +	/* character is in 'v0' */
   4.265 +	return ret_stuff.v0;
   4.266 +}
   4.267 +
   4.268 +/*
   4.269 + * Sends the given character to the console.
   4.270 + */
   4.271 +static inline u64
   4.272 +ia64_sn_console_putc(char ch)
   4.273 +{
   4.274 +	struct ia64_sal_retval ret_stuff;
   4.275 +
   4.276 +	ret_stuff.status = 0;
   4.277 +	ret_stuff.v0 = 0;
   4.278 +	ret_stuff.v1 = 0;
   4.279 +	ret_stuff.v2 = 0;
   4.280 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTC, (u64)ch, 0, 0, 0, 0, 0, 0);
   4.281 +
   4.282 +	return ret_stuff.status;
   4.283 +}
   4.284 +
   4.285 +/*
   4.286 + * Sends the given buffer to the console.
   4.287 + */
   4.288 +static inline u64
   4.289 +ia64_sn_console_putb(const char *buf, int len)
   4.290 +{
   4.291 +	struct ia64_sal_retval ret_stuff;
   4.292 +
   4.293 +	ret_stuff.status = 0;
   4.294 +	ret_stuff.v0 = 0; 
   4.295 +	ret_stuff.v1 = 0;
   4.296 +	ret_stuff.v2 = 0;
   4.297 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTB, (u64)buf, (u64)len, 0, 0, 0, 0, 0);
   4.298 +
   4.299 +	if ( ret_stuff.status == 0 ) {
   4.300 +		return ret_stuff.v0;
   4.301 +	}
   4.302 +	return (u64)0;
   4.303 +}
   4.304 +
   4.305 +/*
   4.306 + * Print a platform error record
   4.307 + */
   4.308 +static inline u64
   4.309 +ia64_sn_plat_specific_err_print(int (*hook)(const char*, ...), char *rec)
   4.310 +{
   4.311 +	struct ia64_sal_retval ret_stuff;
   4.312 +
   4.313 +	ret_stuff.status = 0;
   4.314 +	ret_stuff.v0 = 0;
   4.315 +	ret_stuff.v1 = 0;
   4.316 +	ret_stuff.v2 = 0;
   4.317 +	SAL_CALL_REENTRANT(ret_stuff, SN_SAL_PRINT_ERROR, (u64)hook, (u64)rec, 0, 0, 0, 0, 0);
   4.318 +
   4.319 +	return ret_stuff.status;
   4.320 +}
   4.321 +
   4.322 +/*
   4.323 + * Check for Platform errors
   4.324 + */
   4.325 +static inline u64
   4.326 +ia64_sn_plat_cpei_handler(void)
   4.327 +{
   4.328 +	struct ia64_sal_retval ret_stuff;
   4.329 +
   4.330 +	ret_stuff.status = 0;
   4.331 +	ret_stuff.v0 = 0;
   4.332 +	ret_stuff.v1 = 0;
   4.333 +	ret_stuff.v2 = 0;
   4.334 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_LOG_CE, 0, 0, 0, 0, 0, 0, 0);
   4.335 +
   4.336 +	return ret_stuff.status;
   4.337 +}
   4.338 +
   4.339 +/*
   4.340 + * Set Error Handling Features	(Obsolete)
   4.341 + */
   4.342 +static inline u64
   4.343 +ia64_sn_plat_set_error_handling_features(void)
   4.344 +{
   4.345 +	struct ia64_sal_retval ret_stuff;
   4.346 +
   4.347 +	ret_stuff.status = 0;
   4.348 +	ret_stuff.v0 = 0;
   4.349 +	ret_stuff.v1 = 0;
   4.350 +	ret_stuff.v2 = 0;
   4.351 +	SAL_CALL_REENTRANT(ret_stuff, SN_SAL_SET_ERROR_HANDLING_FEATURES,
   4.352 +		SAL_ERR_FEAT_LOG_SBES,
   4.353 +		0, 0, 0, 0, 0, 0);
   4.354 +
   4.355 +	return ret_stuff.status;
   4.356 +}
   4.357 +
   4.358 +/*
   4.359 + * Checks for console input.
   4.360 + */
   4.361 +static inline u64
   4.362 +ia64_sn_console_check(int *result)
   4.363 +{
   4.364 +	struct ia64_sal_retval ret_stuff;
   4.365 +
   4.366 +	ret_stuff.status = 0;
   4.367 +	ret_stuff.v0 = 0;
   4.368 +	ret_stuff.v1 = 0;
   4.369 +	ret_stuff.v2 = 0;
   4.370 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_POLL, 0, 0, 0, 0, 0, 0, 0);
   4.371 +
   4.372 +	/* result is in 'v0' */
   4.373 +	*result = (int)ret_stuff.v0;
   4.374 +
   4.375 +	return ret_stuff.status;
   4.376 +}
   4.377 +
   4.378 +/*
   4.379 + * Checks console interrupt status
   4.380 + */
   4.381 +static inline u64
   4.382 +ia64_sn_console_intr_status(void)
   4.383 +{
   4.384 +	struct ia64_sal_retval ret_stuff;
   4.385 +
   4.386 +	ret_stuff.status = 0;
   4.387 +	ret_stuff.v0 = 0;
   4.388 +	ret_stuff.v1 = 0;
   4.389 +	ret_stuff.v2 = 0;
   4.390 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR, 
   4.391 +		 0, SAL_CONSOLE_INTR_STATUS,
   4.392 +		 0, 0, 0, 0, 0);
   4.393 +
   4.394 +	if (ret_stuff.status == 0) {
   4.395 +	    return ret_stuff.v0;
   4.396 +	}
   4.397 +	
   4.398 +	return 0;
   4.399 +}
   4.400 +
   4.401 +/*
   4.402 + * Enable an interrupt on the SAL console device.
   4.403 + */
   4.404 +static inline void
   4.405 +ia64_sn_console_intr_enable(u64 intr)
   4.406 +{
   4.407 +	struct ia64_sal_retval ret_stuff;
   4.408 +
   4.409 +	ret_stuff.status = 0;
   4.410 +	ret_stuff.v0 = 0;
   4.411 +	ret_stuff.v1 = 0;
   4.412 +	ret_stuff.v2 = 0;
   4.413 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR, 
   4.414 +		 intr, SAL_CONSOLE_INTR_ON,
   4.415 +		 0, 0, 0, 0, 0);
   4.416 +}
   4.417 +
   4.418 +/*
   4.419 + * Disable an interrupt on the SAL console device.
   4.420 + */
   4.421 +static inline void
   4.422 +ia64_sn_console_intr_disable(u64 intr)
   4.423 +{
   4.424 +	struct ia64_sal_retval ret_stuff;
   4.425 +
   4.426 +	ret_stuff.status = 0;
   4.427 +	ret_stuff.v0 = 0;
   4.428 +	ret_stuff.v1 = 0;
   4.429 +	ret_stuff.v2 = 0;
   4.430 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR, 
   4.431 +		 intr, SAL_CONSOLE_INTR_OFF,
   4.432 +		 0, 0, 0, 0, 0);
   4.433 +}
   4.434 +
   4.435 +/*
   4.436 + * Sends a character buffer to the console asynchronously.
   4.437 + */
   4.438 +static inline u64
   4.439 +ia64_sn_console_xmit_chars(char *buf, int len)
   4.440 +{
   4.441 +	struct ia64_sal_retval ret_stuff;
   4.442 +
   4.443 +	ret_stuff.status = 0;
   4.444 +	ret_stuff.v0 = 0;
   4.445 +	ret_stuff.v1 = 0;
   4.446 +	ret_stuff.v2 = 0;
   4.447 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_XMIT_CHARS,
   4.448 +		 (u64)buf, (u64)len,
   4.449 +		 0, 0, 0, 0, 0);
   4.450 +
   4.451 +	if (ret_stuff.status == 0) {
   4.452 +	    return ret_stuff.v0;
   4.453 +	}
   4.454 +
   4.455 +	return 0;
   4.456 +}
   4.457 +
   4.458 +/*
   4.459 + * Returns the iobrick module Id
   4.460 + */
   4.461 +static inline u64
   4.462 +ia64_sn_sysctl_iobrick_module_get(nasid_t nasid, int *result)
   4.463 +{
   4.464 +	struct ia64_sal_retval ret_stuff;
   4.465 +
   4.466 +	ret_stuff.status = 0;
   4.467 +	ret_stuff.v0 = 0;
   4.468 +	ret_stuff.v1 = 0;
   4.469 +	ret_stuff.v2 = 0;
   4.470 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYSCTL_IOBRICK_MODULE_GET, nasid, 0, 0, 0, 0, 0, 0);
   4.471 +
   4.472 +	/* result is in 'v0' */
   4.473 +	*result = (int)ret_stuff.v0;
   4.474 +
   4.475 +	return ret_stuff.status;
   4.476 +}
   4.477 +
   4.478 +/**
   4.479 + * ia64_sn_pod_mode - call the SN_SAL_POD_MODE function
   4.480 + *
   4.481 + * SN_SAL_POD_MODE actually takes an argument, but it's always
   4.482 + * 0 when we call it from the kernel, so we don't have to expose
   4.483 + * it to the caller.
   4.484 + */
   4.485 +static inline u64
   4.486 +ia64_sn_pod_mode(void)
   4.487 +{
   4.488 +	struct ia64_sal_retval isrv;
   4.489 +	SAL_CALL_REENTRANT(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0);
   4.490 +	if (isrv.status)
   4.491 +		return 0;
   4.492 +	return isrv.v0;
   4.493 +}
   4.494 +
   4.495 +/**
   4.496 + * ia64_sn_probe_mem - read from memory safely
   4.497 + * @addr: address to probe
   4.498 + * @size: number bytes to read (1,2,4,8)
   4.499 + * @data_ptr: address to store value read by probe (-1 returned if probe fails)
   4.500 + *
   4.501 + * Call into the SAL to do a memory read.  If the read generates a machine
   4.502 + * check, this routine will recover gracefully and return -1 to the caller.
   4.503 + * @addr is usually a kernel virtual address in uncached space (i.e. the
   4.504 + * address starts with 0xc), but if called in physical mode, @addr should
   4.505 + * be a physical address.
   4.506 + *
   4.507 + * Return values:
   4.508 + *  0 - probe successful
   4.509 + *  1 - probe failed (generated MCA)
   4.510 + *  2 - Bad arg
   4.511 + * <0 - PAL error
   4.512 + */
   4.513 +static inline u64
   4.514 +ia64_sn_probe_mem(long addr, long size, void *data_ptr)
   4.515 +{
   4.516 +	struct ia64_sal_retval isrv;
   4.517 +
   4.518 +	SAL_CALL(isrv, SN_SAL_PROBE, addr, size, 0, 0, 0, 0, 0);
   4.519 +
   4.520 +	if (data_ptr) {
   4.521 +		switch (size) {
   4.522 +		case 1:
   4.523 +			*((u8*)data_ptr) = (u8)isrv.v0;
   4.524 +			break;
   4.525 +		case 2:
   4.526 +			*((u16*)data_ptr) = (u16)isrv.v0;
   4.527 +			break;
   4.528 +		case 4:
   4.529 +			*((u32*)data_ptr) = (u32)isrv.v0;
   4.530 +			break;
   4.531 +		case 8:
   4.532 +			*((u64*)data_ptr) = (u64)isrv.v0;
   4.533 +			break;
   4.534 +		default:
   4.535 +			isrv.status = 2;
   4.536 +		}
   4.537 +	}
   4.538 +	return isrv.status;
   4.539 +}
   4.540 +
   4.541 +/*
   4.542 + * Retrieve the system serial number as an ASCII string.
   4.543 + */
   4.544 +static inline u64
   4.545 +ia64_sn_sys_serial_get(char *buf)
   4.546 +{
   4.547 +	struct ia64_sal_retval ret_stuff;
   4.548 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYS_SERIAL_GET, buf, 0, 0, 0, 0, 0, 0);
   4.549 +	return ret_stuff.status;
   4.550 +}
   4.551 +
   4.552 +extern char sn_system_serial_number_string[];
   4.553 +extern u64 sn_partition_serial_number;
   4.554 +
   4.555 +static inline char *
   4.556 +sn_system_serial_number(void) {
   4.557 +	if (sn_system_serial_number_string[0]) {
   4.558 +		return(sn_system_serial_number_string);
   4.559 +	} else {
   4.560 +		ia64_sn_sys_serial_get(sn_system_serial_number_string);
   4.561 +		return(sn_system_serial_number_string);
   4.562 +	}
   4.563 +}
   4.564 +	
   4.565 +
   4.566 +/*
   4.567 + * Returns a unique id number for this system and partition (suitable for
   4.568 + * use with license managers), based in part on the system serial number.
   4.569 + */
   4.570 +static inline u64
   4.571 +ia64_sn_partition_serial_get(void)
   4.572 +{
   4.573 +	struct ia64_sal_retval ret_stuff;
   4.574 +	ia64_sal_oemcall_reentrant(&ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0,
   4.575 +				   0, 0, 0, 0, 0, 0);
   4.576 +	if (ret_stuff.status != 0)
   4.577 +	    return 0;
   4.578 +	return ret_stuff.v0;
   4.579 +}
   4.580 +
   4.581 +static inline u64
   4.582 +sn_partition_serial_number_val(void) {
   4.583 +	if (unlikely(sn_partition_serial_number == 0)) {
   4.584 +		sn_partition_serial_number = ia64_sn_partition_serial_get();
   4.585 +	}
   4.586 +	return sn_partition_serial_number;
   4.587 +}
   4.588 +
   4.589 +/*
   4.590 + * Returns the partition id of the nasid passed in as an argument,
   4.591 + * or INVALID_PARTID if the partition id cannot be retrieved.
   4.592 + */
   4.593 +static inline partid_t
   4.594 +ia64_sn_sysctl_partition_get(nasid_t nasid)
   4.595 +{
   4.596 +	struct ia64_sal_retval ret_stuff;
   4.597 +	SAL_CALL(ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid,
   4.598 +		0, 0, 0, 0, 0, 0);
   4.599 +	if (ret_stuff.status != 0)
   4.600 +	    return -1;
   4.601 +	return ((partid_t)ret_stuff.v0);
   4.602 +}
   4.603 +
   4.604 +/*
   4.605 + * Returns the physical address of the partition's reserved page through
   4.606 + * an iterative number of calls.
   4.607 + *
   4.608 + * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
   4.609 + * set to the nasid of the partition whose reserved page's address is
   4.610 + * being sought.
   4.611 + * On subsequent calls, pass the values, that were passed back on the
   4.612 + * previous call.
   4.613 + *
   4.614 + * While the return status equals SALRET_MORE_PASSES, keep calling
   4.615 + * this function after first copying 'len' bytes starting at 'addr'
   4.616 + * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
   4.617 + * be the physical address of the partition's reserved page. If the
   4.618 + * return status equals neither of these, an error as occurred.
   4.619 + */
   4.620 +static inline s64
   4.621 +sn_partition_reserved_page_pa(u64 buf, u64 *cookie, u64 *addr, u64 *len)
   4.622 +{
   4.623 +	struct ia64_sal_retval rv;
   4.624 +	ia64_sal_oemcall_reentrant(&rv, SN_SAL_GET_PARTITION_ADDR, *cookie,
   4.625 +				   *addr, buf, *len, 0, 0, 0);
   4.626 +	*cookie = rv.v0;
   4.627 +	*addr = rv.v1;
   4.628 +	*len = rv.v2;
   4.629 +	return rv.status;
   4.630 +}
   4.631 +
   4.632 +/*
   4.633 + * Register or unregister a physical address range being referenced across
   4.634 + * a partition boundary for which certain SAL errors should be scanned for,
   4.635 + * cleaned up and ignored.  This is of value for kernel partitioning code only.
   4.636 + * Values for the operation argument:
   4.637 + *	1 = register this address range with SAL
   4.638 + *	0 = unregister this address range with SAL
   4.639 + * 
   4.640 + * SAL maintains a reference count on an address range in case it is registered
   4.641 + * multiple times.
   4.642 + * 
   4.643 + * On success, returns the reference count of the address range after the SAL
   4.644 + * call has performed the current registration/unregistration.  Returns a
   4.645 + * negative value if an error occurred.
   4.646 + */
   4.647 +static inline int
   4.648 +sn_register_xp_addr_region(u64 paddr, u64 len, int operation)
   4.649 +{
   4.650 +	struct ia64_sal_retval ret_stuff;
   4.651 +	ia64_sal_oemcall(&ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len,
   4.652 +			 (u64)operation, 0, 0, 0, 0);
   4.653 +	return ret_stuff.status;
   4.654 +}
   4.655 +
   4.656 +/*
   4.657 + * Register or unregister an instruction range for which SAL errors should
   4.658 + * be ignored.  If an error occurs while in the registered range, SAL jumps
   4.659 + * to return_addr after ignoring the error.  Values for the operation argument:
   4.660 + *	1 = register this instruction range with SAL
   4.661 + *	0 = unregister this instruction range with SAL
   4.662 + *
   4.663 + * Returns 0 on success, or a negative value if an error occurred.
   4.664 + */
   4.665 +static inline int
   4.666 +sn_register_nofault_code(u64 start_addr, u64 end_addr, u64 return_addr,
   4.667 +			 int virtual, int operation)
   4.668 +{
   4.669 +	struct ia64_sal_retval ret_stuff;
   4.670 +	u64 call;
   4.671 +	if (virtual) {
   4.672 +		call = SN_SAL_NO_FAULT_ZONE_VIRTUAL;
   4.673 +	} else {
   4.674 +		call = SN_SAL_NO_FAULT_ZONE_PHYSICAL;
   4.675 +	}
   4.676 +	ia64_sal_oemcall(&ret_stuff, call, start_addr, end_addr, return_addr,
   4.677 +			 (u64)1, 0, 0, 0);
   4.678 +	return ret_stuff.status;
   4.679 +}
   4.680 +
   4.681 +/*
   4.682 + * Change or query the coherence domain for this partition. Each cpu-based
   4.683 + * nasid is represented by a bit in an array of 64-bit words:
   4.684 + *      0 = not in this partition's coherency domain
   4.685 + *      1 = in this partition's coherency domain
   4.686 + *
   4.687 + * It is not possible for the local system's nasids to be removed from
   4.688 + * the coherency domain.  Purpose of the domain arguments:
   4.689 + *      new_domain = set the coherence domain to the given nasids
   4.690 + *      old_domain = return the current coherence domain
   4.691 + *
   4.692 + * Returns 0 on success, or a negative value if an error occurred.
   4.693 + */
   4.694 +static inline int
   4.695 +sn_change_coherence(u64 *new_domain, u64 *old_domain)
   4.696 +{
   4.697 +	struct ia64_sal_retval ret_stuff;
   4.698 +	ia64_sal_oemcall(&ret_stuff, SN_SAL_COHERENCE, (u64)new_domain,
   4.699 +			 (u64)old_domain, 0, 0, 0, 0, 0);
   4.700 +	return ret_stuff.status;
   4.701 +}
   4.702 +
   4.703 +/*
   4.704 + * Change memory access protections for a physical address range.
   4.705 + * nasid_array is not used on Altix, but may be in future architectures.
   4.706 + * Available memory protection access classes are defined after the function.
   4.707 + */
   4.708 +static inline int
   4.709 +sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
   4.710 +{
   4.711 +	struct ia64_sal_retval ret_stuff;
   4.712 +
   4.713 +	ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_MEMPROTECT, paddr, len,
   4.714 +				(u64)nasid_array, perms, 0, 0, 0);
   4.715 +	return ret_stuff.status;
   4.716 +}
   4.717 +#define SN_MEMPROT_ACCESS_CLASS_0		0x14a080
   4.718 +#define SN_MEMPROT_ACCESS_CLASS_1		0x2520c2
   4.719 +#define SN_MEMPROT_ACCESS_CLASS_2		0x14a1ca
   4.720 +#define SN_MEMPROT_ACCESS_CLASS_3		0x14a290
   4.721 +#define SN_MEMPROT_ACCESS_CLASS_6		0x084080
   4.722 +#define SN_MEMPROT_ACCESS_CLASS_7		0x021080
   4.723 +
   4.724 +/*
   4.725 + * Turns off system power.
   4.726 + */
   4.727 +static inline void
   4.728 +ia64_sn_power_down(void)
   4.729 +{
   4.730 +	struct ia64_sal_retval ret_stuff;
   4.731 +	SAL_CALL(ret_stuff, SN_SAL_SYSTEM_POWER_DOWN, 0, 0, 0, 0, 0, 0, 0);
   4.732 +	while(1)
   4.733 +		cpu_relax();
   4.734 +	/* never returns */
   4.735 +}
   4.736 +
   4.737 +/**
   4.738 + * ia64_sn_fru_capture - tell the system controller to capture hw state
   4.739 + *
   4.740 + * This routine will call the SAL which will tell the system controller(s)
   4.741 + * to capture hw mmr information from each SHub in the system.
   4.742 + */
   4.743 +static inline u64
   4.744 +ia64_sn_fru_capture(void)
   4.745 +{
   4.746 +        struct ia64_sal_retval isrv;
   4.747 +        SAL_CALL(isrv, SN_SAL_SYSCTL_FRU_CAPTURE, 0, 0, 0, 0, 0, 0, 0);
   4.748 +        if (isrv.status)
   4.749 +                return 0;
   4.750 +        return isrv.v0;
   4.751 +}
   4.752 +
   4.753 +/*
   4.754 + * Performs an operation on a PCI bus or slot -- power up, power down
   4.755 + * or reset.
   4.756 + */
   4.757 +static inline u64
   4.758 +ia64_sn_sysctl_iobrick_pci_op(nasid_t n, u64 connection_type, 
   4.759 +			      u64 bus, char slot, 
   4.760 +			      u64 action)
   4.761 +{
   4.762 +	struct ia64_sal_retval rv = {0, 0, 0, 0};
   4.763 +
   4.764 +	SAL_CALL_NOLOCK(rv, SN_SAL_SYSCTL_IOBRICK_PCI_OP, connection_type, n, action,
   4.765 +		 bus, (u64) slot, 0, 0);
   4.766 +	if (rv.status)
   4.767 +	    	return rv.v0;
   4.768 +	return 0;
   4.769 +}
   4.770 +
   4.771 +
   4.772 +/*
   4.773 + * Open a subchannel for sending arbitrary data to the system
   4.774 + * controller network via the system controller device associated with
   4.775 + * 'nasid'.  Return the subchannel number or a negative error code.
   4.776 + */
   4.777 +static inline int
   4.778 +ia64_sn_irtr_open(nasid_t nasid)
   4.779 +{
   4.780 +	struct ia64_sal_retval rv;
   4.781 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_OPEN, nasid,
   4.782 +			   0, 0, 0, 0, 0);
   4.783 +	return (int) rv.v0;
   4.784 +}
   4.785 +
   4.786 +/*
   4.787 + * Close system controller subchannel 'subch' previously opened on 'nasid'.
   4.788 + */
   4.789 +static inline int
   4.790 +ia64_sn_irtr_close(nasid_t nasid, int subch)
   4.791 +{
   4.792 +	struct ia64_sal_retval rv;
   4.793 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_CLOSE,
   4.794 +			   (u64) nasid, (u64) subch, 0, 0, 0, 0);
   4.795 +	return (int) rv.status;
   4.796 +}
   4.797 +
   4.798 +/*
   4.799 + * Read data from system controller associated with 'nasid' on
   4.800 + * subchannel 'subch'.  The buffer to be filled is pointed to by
   4.801 + * 'buf', and its capacity is in the integer pointed to by 'len'.  The
   4.802 + * referent of 'len' is set to the number of bytes read by the SAL
   4.803 + * call.  The return value is either SALRET_OK (for bytes read) or
   4.804 + * SALRET_ERROR (for error or "no data available").
   4.805 + */
   4.806 +static inline int
   4.807 +ia64_sn_irtr_recv(nasid_t nasid, int subch, char *buf, int *len)
   4.808 +{
   4.809 +	struct ia64_sal_retval rv;
   4.810 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_RECV,
   4.811 +			   (u64) nasid, (u64) subch, (u64) buf, (u64) len,
   4.812 +			   0, 0);
   4.813 +	return (int) rv.status;
   4.814 +}
   4.815 +
   4.816 +/*
   4.817 + * Write data to the system controller network via the system
   4.818 + * controller associated with 'nasid' on suchannel 'subch'.  The
   4.819 + * buffer to be written out is pointed to by 'buf', and 'len' is the
   4.820 + * number of bytes to be written.  The return value is either the
   4.821 + * number of bytes written (which could be zero) or a negative error
   4.822 + * code.
   4.823 + */
   4.824 +static inline int
   4.825 +ia64_sn_irtr_send(nasid_t nasid, int subch, char *buf, int len)
   4.826 +{
   4.827 +	struct ia64_sal_retval rv;
   4.828 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_SEND,
   4.829 +			   (u64) nasid, (u64) subch, (u64) buf, (u64) len,
   4.830 +			   0, 0);
   4.831 +	return (int) rv.v0;
   4.832 +}
   4.833 +
   4.834 +/*
   4.835 + * Check whether any interrupts are pending for the system controller
   4.836 + * associated with 'nasid' and its subchannel 'subch'.  The return
   4.837 + * value is a mask of pending interrupts (SAL_IROUTER_INTR_XMIT and/or
   4.838 + * SAL_IROUTER_INTR_RECV).
   4.839 + */
   4.840 +static inline int
   4.841 +ia64_sn_irtr_intr(nasid_t nasid, int subch)
   4.842 +{
   4.843 +	struct ia64_sal_retval rv;
   4.844 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_STATUS,
   4.845 +			   (u64) nasid, (u64) subch, 0, 0, 0, 0);
   4.846 +	return (int) rv.v0;
   4.847 +}
   4.848 +
   4.849 +/*
   4.850 + * Enable the interrupt indicated by the intr parameter (either
   4.851 + * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
   4.852 + */
   4.853 +static inline int
   4.854 +ia64_sn_irtr_intr_enable(nasid_t nasid, int subch, u64 intr)
   4.855 +{
   4.856 +	struct ia64_sal_retval rv;
   4.857 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_ON,
   4.858 +			   (u64) nasid, (u64) subch, intr, 0, 0, 0);
   4.859 +	return (int) rv.v0;
   4.860 +}
   4.861 +
   4.862 +/*
   4.863 + * Disable the interrupt indicated by the intr parameter (either
   4.864 + * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
   4.865 + */
   4.866 +static inline int
   4.867 +ia64_sn_irtr_intr_disable(nasid_t nasid, int subch, u64 intr)
   4.868 +{
   4.869 +	struct ia64_sal_retval rv;
   4.870 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_OFF,
   4.871 +			   (u64) nasid, (u64) subch, intr, 0, 0, 0);
   4.872 +	return (int) rv.v0;
   4.873 +}
   4.874 +
   4.875 +/*
   4.876 + * Set up a node as the point of contact for system controller
   4.877 + * environmental event delivery.
   4.878 + */
   4.879 +static inline int
   4.880 +ia64_sn_sysctl_event_init(nasid_t nasid)
   4.881 +{
   4.882 +        struct ia64_sal_retval rv;
   4.883 +        SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_EVENT, (u64) nasid,
   4.884 +			   0, 0, 0, 0, 0, 0);
   4.885 +        return (int) rv.v0;
   4.886 +}
   4.887 +
   4.888 +/*
   4.889 + * Ask the system controller on the specified nasid to reset
   4.890 + * the CX corelet clock.  Only valid on TIO nodes.
   4.891 + */
   4.892 +static inline int
   4.893 +ia64_sn_sysctl_tio_clock_reset(nasid_t nasid)
   4.894 +{
   4.895 +	struct ia64_sal_retval rv;
   4.896 +	SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_TIO_JLCK_RST,
   4.897 +			nasid, 0, 0, 0, 0, 0);
   4.898 +	if (rv.status != 0)
   4.899 +		return (int)rv.status;
   4.900 +	if (rv.v0 != 0)
   4.901 +		return (int)rv.v0;
   4.902 +
   4.903 +	return 0;
   4.904 +}
   4.905 +
   4.906 +/*
   4.907 + * Get the associated ioboard type for a given nasid.
   4.908 + */
   4.909 +static inline s64
   4.910 +ia64_sn_sysctl_ioboard_get(nasid_t nasid, u16 *ioboard)
   4.911 +{
   4.912 +	struct ia64_sal_retval isrv;
   4.913 +	SAL_CALL_REENTRANT(isrv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_IOBOARD,
   4.914 +			   nasid, 0, 0, 0, 0, 0);
   4.915 +	if (isrv.v0 != 0) {
   4.916 +		*ioboard = isrv.v0;
   4.917 +		return isrv.status;
   4.918 +	}
   4.919 +	if (isrv.v1 != 0) {
   4.920 +		*ioboard = isrv.v1;
   4.921 +		return isrv.status;
   4.922 +	}
   4.923 +
   4.924 +	return isrv.status;
   4.925 +}
   4.926 +
   4.927 +/**
   4.928 + * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
   4.929 + * @nasid: NASID of node to read
   4.930 + * @index: FIT entry index to be retrieved (0..n)
   4.931 + * @fitentry: 16 byte buffer where FIT entry will be stored.
   4.932 + * @banbuf: optional buffer for retrieving banner
   4.933 + * @banlen: length of banner buffer
   4.934 + *
   4.935 + * Access to the physical PROM chips needs to be serialized since reads and
   4.936 + * writes can't occur at the same time, so we need to call into the SAL when
   4.937 + * we want to look at the FIT entries on the chips.
   4.938 + *
   4.939 + * Returns:
   4.940 + *	%SALRET_OK if ok
   4.941 + *	%SALRET_INVALID_ARG if index too big
   4.942 + *	%SALRET_NOT_IMPLEMENTED if running on older PROM
   4.943 + *	??? if nasid invalid OR banner buffer not large enough
   4.944 + */
   4.945 +static inline int
   4.946 +ia64_sn_get_fit_compt(u64 nasid, u64 index, void *fitentry, void *banbuf,
   4.947 +		      u64 banlen)
   4.948 +{
   4.949 +	struct ia64_sal_retval rv;
   4.950 +	SAL_CALL_NOLOCK(rv, SN_SAL_GET_FIT_COMPT, nasid, index, fitentry,
   4.951 +			banbuf, banlen, 0, 0);
   4.952 +	return (int) rv.status;
   4.953 +}
   4.954 +
   4.955 +/*
   4.956 + * Initialize the SAL components of the system controller
   4.957 + * communication driver; specifically pass in a sizable buffer that
   4.958 + * can be used for allocation of subchannel queues as new subchannels
   4.959 + * are opened.  "buf" points to the buffer, and "len" specifies its
   4.960 + * length.
   4.961 + */
   4.962 +static inline int
   4.963 +ia64_sn_irtr_init(nasid_t nasid, void *buf, int len)
   4.964 +{
   4.965 +	struct ia64_sal_retval rv;
   4.966 +	SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INIT,
   4.967 +			   (u64) nasid, (u64) buf, (u64) len, 0, 0, 0);
   4.968 +	return (int) rv.status;
   4.969 +}
   4.970 +
   4.971 +/*
   4.972 + * Returns the nasid, subnode & slice corresponding to a SAPIC ID
   4.973 + *
   4.974 + *  In:
   4.975 + *	arg0 - SN_SAL_GET_SAPIC_INFO
   4.976 + *	arg1 - sapicid (lid >> 16) 
   4.977 + *  Out:
   4.978 + *	v0 - nasid
   4.979 + *	v1 - subnode
   4.980 + *	v2 - slice
   4.981 + */
   4.982 +static inline u64
   4.983 +ia64_sn_get_sapic_info(int sapicid, int *nasid, int *subnode, int *slice)
   4.984 +{
   4.985 +	struct ia64_sal_retval ret_stuff;
   4.986 +
   4.987 +	ret_stuff.status = 0;
   4.988 +	ret_stuff.v0 = 0;
   4.989 +	ret_stuff.v1 = 0;
   4.990 +	ret_stuff.v2 = 0;
   4.991 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SAPIC_INFO, sapicid, 0, 0, 0, 0, 0, 0);
   4.992 +
   4.993 +/***** BEGIN HACK - temp til old proms no longer supported ********/
   4.994 +	if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
   4.995 +		if (nasid) *nasid = sapicid & 0xfff;
   4.996 +		if (subnode) *subnode = (sapicid >> 13) & 1;
   4.997 +		if (slice) *slice = (sapicid >> 12) & 3;
   4.998 +		return 0;
   4.999 +	}
  4.1000 +/***** END HACK *******/
  4.1001 +
  4.1002 +	if (ret_stuff.status < 0)
  4.1003 +		return ret_stuff.status;
  4.1004 +
  4.1005 +	if (nasid) *nasid = (int) ret_stuff.v0;
  4.1006 +	if (subnode) *subnode = (int) ret_stuff.v1;
  4.1007 +	if (slice) *slice = (int) ret_stuff.v2;
  4.1008 +	return 0;
  4.1009 +}
  4.1010 + 
  4.1011 +/*
  4.1012 + * Returns information about the HUB/SHUB.
  4.1013 + *  In:
  4.1014 + *	arg0 - SN_SAL_GET_SN_INFO
  4.1015 + * 	arg1 - 0 (other values reserved for future use)
  4.1016 + *  Out:
  4.1017 + *	v0 
  4.1018 + *		[7:0]   - shub type (0=shub1, 1=shub2)
  4.1019 + *		[15:8]  - Log2 max number of nodes in entire system (includes
  4.1020 + *			  C-bricks, I-bricks, etc)
  4.1021 + *		[23:16] - Log2 of nodes per sharing domain			 
  4.1022 + * 		[31:24] - partition ID
  4.1023 + * 		[39:32] - coherency_id
  4.1024 + * 		[47:40] - regionsize
  4.1025 + *	v1 
  4.1026 + *		[15:0]  - nasid mask (ex., 0x7ff for 11 bit nasid)
  4.1027 + *	 	[23:15] - bit position of low nasid bit
  4.1028 + */
  4.1029 +static inline u64
  4.1030 +ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift, 
  4.1031 +		u8 *systemsize, u8 *sharing_domain_size, u8 *partid, u8 *coher, u8 *reg)
  4.1032 +{
  4.1033 +	struct ia64_sal_retval ret_stuff;
  4.1034 +
  4.1035 +	ret_stuff.status = 0;
  4.1036 +	ret_stuff.v0 = 0;
  4.1037 +	ret_stuff.v1 = 0;
  4.1038 +	ret_stuff.v2 = 0;
  4.1039 +	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SN_INFO, fc, 0, 0, 0, 0, 0, 0);
  4.1040 +
  4.1041 +/***** BEGIN HACK - temp til old proms no longer supported ********/
  4.1042 +	if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
  4.1043 +		int nasid = get_sapicid() & 0xfff;
  4.1044 +#define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL
  4.1045 +#define SH_SHUB_ID_NODES_PER_BIT_SHFT 48
  4.1046 +		if (shubtype) *shubtype = 0;
  4.1047 +		if (nasid_bitmask) *nasid_bitmask = 0x7ff;
  4.1048 +		if (nasid_shift) *nasid_shift = 38;
  4.1049 +		if (systemsize) *systemsize = 10;
  4.1050 +		if (sharing_domain_size) *sharing_domain_size = 8;
  4.1051 +		if (partid) *partid = ia64_sn_sysctl_partition_get(nasid);
  4.1052 +		if (coher) *coher = nasid >> 9;
  4.1053 +		if (reg) *reg = (HUB_L((u64 *) LOCAL_MMR_ADDR(SH1_SHUB_ID)) & SH_SHUB_ID_NODES_PER_BIT_MASK) >>
  4.1054 +			SH_SHUB_ID_NODES_PER_BIT_SHFT;
  4.1055 +		return 0;
  4.1056 +	}
  4.1057 +/***** END HACK *******/
  4.1058 +
  4.1059 +	if (ret_stuff.status < 0)
  4.1060 +		return ret_stuff.status;
  4.1061 +
  4.1062 +	if (shubtype) *shubtype = ret_stuff.v0 & 0xff;
  4.1063 +	if (systemsize) *systemsize = (ret_stuff.v0 >> 8) & 0xff;
  4.1064 +	if (sharing_domain_size) *sharing_domain_size = (ret_stuff.v0 >> 16) & 0xff;
  4.1065 +	if (partid) *partid = (ret_stuff.v0 >> 24) & 0xff;
  4.1066 +	if (coher) *coher = (ret_stuff.v0 >> 32) & 0xff;
  4.1067 +	if (reg) *reg = (ret_stuff.v0 >> 40) & 0xff;
  4.1068 +	if (nasid_bitmask) *nasid_bitmask = (ret_stuff.v1 & 0xffff);
  4.1069 +	if (nasid_shift) *nasid_shift = (ret_stuff.v1 >> 16) & 0xff;
  4.1070 +	return 0;
  4.1071 +}
  4.1072 + 
  4.1073 +/*
  4.1074 + * This is the access point to the Altix PROM hardware performance
  4.1075 + * and status monitoring interface. For info on using this, see
  4.1076 + * include/asm-ia64/sn/sn2/sn_hwperf.h
  4.1077 + */
  4.1078 +static inline int
  4.1079 +ia64_sn_hwperf_op(nasid_t nasid, u64 opcode, u64 a0, u64 a1, u64 a2,
  4.1080 +                  u64 a3, u64 a4, int *v0)
  4.1081 +{
  4.1082 +	struct ia64_sal_retval rv;
  4.1083 +	SAL_CALL_NOLOCK(rv, SN_SAL_HWPERF_OP, (u64)nasid,
  4.1084 +		opcode, a0, a1, a2, a3, a4);
  4.1085 +	if (v0)
  4.1086 +		*v0 = (int) rv.v0;
  4.1087 +	return (int) rv.status;
  4.1088 +}
  4.1089 +
  4.1090 +static inline int
  4.1091 +ia64_sn_ioif_get_pci_topology(u64 buf, u64 len)
  4.1092 +{
  4.1093 +	struct ia64_sal_retval rv;
  4.1094 +	SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY, buf, len, 0, 0, 0, 0, 0);
  4.1095 +	return (int) rv.status;
  4.1096 +}
  4.1097 +
  4.1098 +/*
  4.1099 + * BTE error recovery is implemented in SAL
  4.1100 + */
  4.1101 +static inline int
  4.1102 +ia64_sn_bte_recovery(nasid_t nasid)
  4.1103 +{
  4.1104 +	struct ia64_sal_retval rv;
  4.1105 +
  4.1106 +	rv.status = 0;
  4.1107 +	SAL_CALL_NOLOCK(rv, SN_SAL_BTE_RECOVER, (u64)nasid, 0, 0, 0, 0, 0, 0);
  4.1108 +	if (rv.status == SALRET_NOT_IMPLEMENTED)
  4.1109 +		return 0;
  4.1110 +	return (int) rv.status;
  4.1111 +}
  4.1112 +
  4.1113 +static inline int
  4.1114 +ia64_sn_is_fake_prom(void)
  4.1115 +{
  4.1116 +	struct ia64_sal_retval rv;
  4.1117 +	SAL_CALL_NOLOCK(rv, SN_SAL_FAKE_PROM, 0, 0, 0, 0, 0, 0, 0);
  4.1118 +	return (rv.status == 0);
  4.1119 +}
  4.1120 +
  4.1121 +static inline int
  4.1122 +ia64_sn_get_prom_feature_set(int set, unsigned long *feature_set)
  4.1123 +{
  4.1124 +	struct ia64_sal_retval rv;
  4.1125 +
  4.1126 +	SAL_CALL_NOLOCK(rv, SN_SAL_GET_PROM_FEATURE_SET, set, 0, 0, 0, 0, 0, 0);
  4.1127 +	if (rv.status != 0)
  4.1128 +		return rv.status;
  4.1129 +	*feature_set = rv.v0;
  4.1130 +	return 0;
  4.1131 +}
  4.1132 +
  4.1133 +static inline int
  4.1134 +ia64_sn_set_os_feature(int feature)
  4.1135 +{
  4.1136 +	struct ia64_sal_retval rv;
  4.1137 +
  4.1138 +	SAL_CALL_NOLOCK(rv, SN_SAL_SET_OS_FEATURE_SET, feature, 0, 0, 0, 0, 0, 0);
  4.1139 +	return rv.status;
  4.1140 +}
  4.1141 +
  4.1142 +static inline int
  4.1143 +sn_inject_error(u64 paddr, u64 *data, u64 *ecc)
  4.1144 +{
  4.1145 +	struct ia64_sal_retval ret_stuff;
  4.1146 +
  4.1147 +	ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_INJECT_ERROR, paddr, (u64)data,
  4.1148 +				(u64)ecc, 0, 0, 0, 0);
  4.1149 +	return ret_stuff.status;
  4.1150 +}
  4.1151 +
  4.1152 +static inline int
  4.1153 +ia64_sn_set_cpu_number(int cpu)
  4.1154 +{
  4.1155 +	struct ia64_sal_retval rv;
  4.1156 +
  4.1157 +	SAL_CALL_NOLOCK(rv, SN_SAL_SET_CPU_NUMBER, cpu, 0, 0, 0, 0, 0, 0);
  4.1158 +	return rv.status;
  4.1159 +}
  4.1160 +#endif /* _ASM_IA64_SN_SN_SAL_H */