vserver 2.0 rc7
[linux-2.6.git] / include / asm-ia64 / sn / sn_sal.h
index 4ecc05e..eb0395a 100644 (file)
@@ -8,7 +8,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All rights reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All rights reserved.
  */
 
 
@@ -18,6 +18,7 @@
 #include <asm/sn/arch.h>
 #include <asm/sn/geo.h>
 #include <asm/sn/nodepda.h>
+#include <asm/sn/shub_mmr.h>
 
 // SGI Specific Calls
 #define  SN_SAL_POD_MODE                           0x02000001
@@ -34,8 +35,8 @@
 #define  SN_SAL_PRINT_ERROR                       0x02000012
 #define  SN_SAL_SET_ERROR_HANDLING_FEATURES       0x0200001a   // reentrant
 #define  SN_SAL_GET_FIT_COMPT                     0x0200001b   // reentrant
-#define  SN_SAL_GET_HUB_INFO                       0x0200001c
 #define  SN_SAL_GET_SAPIC_INFO                     0x0200001d
+#define  SN_SAL_GET_SN_INFO                        0x0200001e
 #define  SN_SAL_CONSOLE_PUTC                       0x02000021
 #define  SN_SAL_CONSOLE_GETC                       0x02000022
 #define  SN_SAL_CONSOLE_PUTS                       0x02000023
@@ -63,6 +64,7 @@
 
 #define  SN_SAL_SYSCTL_IOBRICK_PCI_OP             0x02000042   // reentrant
 #define         SN_SAL_IROUTER_OP                         0x02000043
+#define  SN_SAL_SYSCTL_EVENT                       0x02000044
 #define  SN_SAL_IOIF_INTERRUPT                    0x0200004a
 #define  SN_SAL_HWPERF_OP                         0x02000050   // lock
 #define  SN_SAL_IOIF_ERROR_INTERRUPT              0x02000051
@@ -75,7 +77,8 @@
 #define  SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST     0x02000058
 
 #define SN_SAL_HUB_ERROR_INTERRUPT                0x02000060
-
+#define SN_SAL_BTE_RECOVER                        0x02000061
+#define SN_SAL_IOIF_GET_PCI_TOPOLOGY              0x02000062
 
 /*
  * Service-specific constants
 #define SAL_IROUTER_INTR_XMIT  SAL_CONSOLE_INTR_XMIT
 #define SAL_IROUTER_INTR_RECV  SAL_CONSOLE_INTR_RECV
 
+/*
+ * Error Handling Features
+ */
+#define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV    0x1
+#define SAL_ERR_FEAT_LOG_SBES                  0x2
+#define SAL_ERR_FEAT_MFR_OVERRIDE              0x4
+#define SAL_ERR_FEAT_SBE_THRESHOLD             0xffff0000
 
 /*
  * SAL Error Codes
@@ -338,6 +348,25 @@ ia64_sn_plat_cpei_handler(void)
        return ret_stuff.status;
 }
 
+/*
+ * Set Error Handling Features
+ */
+static inline u64
+ia64_sn_plat_set_error_handling_features(void)
+{
+       struct ia64_sal_retval ret_stuff;
+
+       ret_stuff.status = 0;
+       ret_stuff.v0 = 0;
+       ret_stuff.v1 = 0;
+       ret_stuff.v2 = 0;
+       SAL_CALL_REENTRANT(ret_stuff, SN_SAL_SET_ERROR_HANDLING_FEATURES,
+               (SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV | SAL_ERR_FEAT_LOG_SBES),
+               0, 0, 0, 0, 0, 0);
+
+       return ret_stuff.status;
+}
+
 /*
  * Checks for console input.
  */
@@ -469,7 +498,7 @@ static inline u64
 ia64_sn_pod_mode(void)
 {
        struct ia64_sal_retval isrv;
-       SAL_CALL(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0);
+       SAL_CALL_REENTRANT(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0);
        if (isrv.status)
                return 0;
        return isrv.v0;
@@ -554,7 +583,8 @@ static inline u64
 ia64_sn_partition_serial_get(void)
 {
        struct ia64_sal_retval ret_stuff;
-       SAL_CALL(ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0, 0, 0, 0, 0, 0, 0);
+       ia64_sal_oemcall_reentrant(&ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0,
+                                  0, 0, 0, 0, 0, 0);
        if (ret_stuff.status != 0)
            return 0;
        return ret_stuff.v0;
@@ -562,11 +592,10 @@ ia64_sn_partition_serial_get(void)
 
 static inline u64
 sn_partition_serial_number_val(void) {
-       if (sn_partition_serial_number) {
-               return(sn_partition_serial_number);
-       } else {
-               return(sn_partition_serial_number = ia64_sn_partition_serial_get());
+       if (unlikely(sn_partition_serial_number == 0)) {
+               sn_partition_serial_number = ia64_sn_partition_serial_get();
        }
+       return sn_partition_serial_number;
 }
 
 /*
@@ -577,8 +606,8 @@ static inline partid_t
 ia64_sn_sysctl_partition_get(nasid_t nasid)
 {
        struct ia64_sal_retval ret_stuff;
-       SAL_CALL(ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid,
-                0, 0, 0, 0, 0, 0);
+       ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid,
+                               0, 0, 0, 0, 0, 0);
        if (ret_stuff.status != 0)
            return INVALID_PARTID;
        return ((partid_t)ret_stuff.v0);
@@ -592,11 +621,38 @@ extern partid_t sn_partid;
 
 static inline partid_t
 sn_local_partid(void) {
-       if (sn_partid < 0) {
-               return (sn_partid = ia64_sn_sysctl_partition_get(cpuid_to_nasid(smp_processor_id())));
-       } else {
-               return sn_partid;
+       if (unlikely(sn_partid < 0)) {
+               sn_partid = ia64_sn_sysctl_partition_get(cpuid_to_nasid(smp_processor_id()));
        }
+       return sn_partid;
+}
+
+/*
+ * Returns the physical address of the partition's reserved page through
+ * an iterative number of calls.
+ *
+ * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
+ * set to the nasid of the partition whose reserved page's address is
+ * being sought.
+ * On subsequent calls, pass the values, that were passed back on the
+ * previous call.
+ *
+ * While the return status equals SALRET_MORE_PASSES, keep calling
+ * this function after first copying 'len' bytes starting at 'addr'
+ * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
+ * be the physical address of the partition's reserved page. If the
+ * return status equals neither of these, an error as occurred.
+ */
+static inline s64
+sn_partition_reserved_page_pa(u64 buf, u64 *cookie, u64 *addr, u64 *len)
+{
+       struct ia64_sal_retval rv;
+       ia64_sal_oemcall_reentrant(&rv, SN_SAL_GET_PARTITION_ADDR, *cookie,
+                                  *addr, buf, *len, 0, 0, 0);
+       *cookie = rv.v0;
+       *addr = rv.v1;
+       *len = rv.v2;
+       return rv.status;
 }
 
 /*
@@ -618,8 +674,8 @@ static inline int
 sn_register_xp_addr_region(u64 paddr, u64 len, int operation)
 {
        struct ia64_sal_retval ret_stuff;
-       SAL_CALL(ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len, (u64)operation,
-                0, 0, 0, 0);
+       ia64_sal_oemcall(&ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len,
+                        (u64)operation, 0, 0, 0, 0);
        return ret_stuff.status;
 }
 
@@ -643,8 +699,8 @@ sn_register_nofault_code(u64 start_addr, u64 end_addr, u64 return_addr,
        } else {
                call = SN_SAL_NO_FAULT_ZONE_PHYSICAL;
        }
-       SAL_CALL(ret_stuff, call, start_addr, end_addr, return_addr, (u64)1,
-                0, 0, 0);
+       ia64_sal_oemcall(&ret_stuff, call, start_addr, end_addr, return_addr,
+                        (u64)1, 0, 0, 0);
        return ret_stuff.status;
 }
 
@@ -665,8 +721,8 @@ static inline int
 sn_change_coherence(u64 *new_domain, u64 *old_domain)
 {
        struct ia64_sal_retval ret_stuff;
-       SAL_CALL(ret_stuff, SN_SAL_COHERENCE, new_domain, old_domain, 0, 0,
-                0, 0, 0);
+       ia64_sal_oemcall(&ret_stuff, SN_SAL_COHERENCE, (u64)new_domain,
+                        (u64)old_domain, 0, 0, 0, 0, 0);
        return ret_stuff.status;
 }
 
@@ -685,8 +741,8 @@ sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
        cnodeid = nasid_to_cnodeid(get_node_number(paddr));
        // spin_lock(&NODEPDA(cnodeid)->bist_lock);
        local_irq_save(irq_flags);
-       SAL_CALL_NOLOCK(ret_stuff, SN_SAL_MEMPROTECT, paddr, len, nasid_array,
-                perms, 0, 0, 0);
+       ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_MEMPROTECT, paddr, len,
+                               (u64)nasid_array, perms, 0, 0, 0);
        local_irq_restore(irq_flags);
        // spin_unlock(&NODEPDA(cnodeid)->bist_lock);
        return ret_stuff.status;
@@ -848,6 +904,19 @@ ia64_sn_irtr_intr_disable(nasid_t nasid, int subch, u64 intr)
        return (int) rv.v0;
 }
 
+/*
+ * Set up a node as the point of contact for system controller
+ * environmental event delivery.
+ */
+static inline int
+ia64_sn_sysctl_event_init(nasid_t nasid)
+{
+        struct ia64_sal_retval rv;
+        SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_EVENT, (u64) nasid,
+                          0, 0, 0, 0, 0, 0);
+        return (int) rv.v0;
+}
+
 /**
  * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
  * @nasid: NASID of node to read
@@ -935,15 +1004,24 @@ ia64_sn_get_sapic_info(int sapicid, int *nasid, int *subnode, int *slice)
 /*
  * Returns information about the HUB/SHUB.
  *  In:
- *     arg0 - SN_SAL_GET_HUB_INFO
+ *     arg0 - SN_SAL_GET_SN_INFO
  *     arg1 - 0 (other values reserved for future use)
  *  Out:
- *     v0 - shub type (0=shub1, 1=shub2)
- *     v1 - masid mask (ex., 0x7ff for 11 bit nasid)
- *     v2 - bit position of low nasid bit
+ *     v0 
+ *             [7:0]   - shub type (0=shub1, 1=shub2)
+ *             [15:8]  - Log2 max number of nodes in entire system (includes
+ *                       C-bricks, I-bricks, etc)
+ *             [23:16] - Log2 of nodes per sharing domain                       
+ *             [31:24] - partition ID
+ *             [39:32] - coherency_id
+ *             [47:40] - regionsize
+ *     v1 
+ *             [15:0]  - nasid mask (ex., 0x7ff for 11 bit nasid)
+ *             [23:15] - bit position of low nasid bit
  */
 static inline u64
-ia64_sn_get_hub_info(int fc, u64 *arg1, u64 *arg2, u64 *arg3)
+ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift, 
+               u8 *systemsize, u8 *sharing_domain_size, u8 *partid, u8 *coher, u8 *reg)
 {
        struct ia64_sal_retval ret_stuff;
 
@@ -951,13 +1029,22 @@ ia64_sn_get_hub_info(int fc, u64 *arg1, u64 *arg2, u64 *arg3)
        ret_stuff.v0 = 0;
        ret_stuff.v1 = 0;
        ret_stuff.v2 = 0;
-       SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_HUB_INFO, fc, 0, 0, 0, 0, 0, 0);
+       SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SN_INFO, fc, 0, 0, 0, 0, 0, 0);
 
 /***** BEGIN HACK - temp til old proms no longer supported ********/
        if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
-               if (arg1) *arg1 = 0;
-               if (arg2) *arg2 = 0x7ff;
-               if (arg3) *arg3 = 38;
+               int nasid = get_sapicid() & 0xfff;;
+#define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL                                               
+#define SH_SHUB_ID_NODES_PER_BIT_SHFT 48                                                               
+               if (shubtype) *shubtype = 0;
+               if (nasid_bitmask) *nasid_bitmask = 0x7ff;
+               if (nasid_shift) *nasid_shift = 38;
+               if (systemsize) *systemsize = 11;
+               if (sharing_domain_size) *sharing_domain_size = 9;
+               if (partid) *partid = ia64_sn_sysctl_partition_get(nasid);
+               if (coher) *coher = nasid >> 9;
+               if (reg) *reg = (HUB_L((u64 *) LOCAL_MMR_ADDR(SH1_SHUB_ID)) & SH_SHUB_ID_NODES_PER_BIT_MASK) >>
+                       SH_SHUB_ID_NODES_PER_BIT_SHFT;
                return 0;
        }
 /***** END HACK *******/
@@ -965,9 +1052,14 @@ ia64_sn_get_hub_info(int fc, u64 *arg1, u64 *arg2, u64 *arg3)
        if (ret_stuff.status < 0)
                return ret_stuff.status;
 
-       if (arg1) *arg1 = ret_stuff.v0;
-       if (arg2) *arg2 = ret_stuff.v1;
-       if (arg3) *arg3 = ret_stuff.v2;
+       if (shubtype) *shubtype = ret_stuff.v0 & 0xff;
+       if (systemsize) *systemsize = (ret_stuff.v0 >> 8) & 0xff;
+       if (sharing_domain_size) *sharing_domain_size = (ret_stuff.v0 >> 16) & 0xff;
+       if (partid) *partid = (ret_stuff.v0 >> 24) & 0xff;
+       if (coher) *coher = (ret_stuff.v0 >> 32) & 0xff;
+       if (reg) *reg = (ret_stuff.v0 >> 40) & 0xff;
+       if (nasid_bitmask) *nasid_bitmask = (ret_stuff.v1 & 0xffff);
+       if (nasid_shift) *nasid_shift = (ret_stuff.v1 >> 16) & 0xff;
        return 0;
 }
  
@@ -988,4 +1080,29 @@ ia64_sn_hwperf_op(nasid_t nasid, u64 opcode, u64 a0, u64 a1, u64 a2,
        return (int) rv.status;
 }
 
+static inline int
+ia64_sn_ioif_get_pci_topology(u64 rack, u64 bay, u64 slot, u64 slab,
+                             u64 buf, u64 len)
+{
+       struct ia64_sal_retval rv;
+       SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY,
+               rack, bay, slot, slab, buf, len, 0);
+       return (int) rv.status;
+}
+
+/*
+ * BTE error recovery is implemented in SAL
+ */
+static inline int
+ia64_sn_bte_recovery(nasid_t nasid)
+{
+       struct ia64_sal_retval rv;
+
+       rv.status = 0;
+       SAL_CALL_NOLOCK(rv, SN_SAL_BTE_RECOVER, 0, 0, 0, 0, 0, 0, 0);
+       if (rv.status == SALRET_NOT_IMPLEMENTED)
+               return 0;
+       return (int) rv.status;
+}
+
 #endif /* _ASM_IA64_SN_SN_SAL_H */