1 /* 2 * This file is subject to the terms and conditions of the GNU General Public 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 5 * 6 * SGI specific setup. 7 * 8 * Copyright (C) 1995 - 1997, 1999 Silcon Graphics, Inc. 9 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org) 10 */ 11 #ifndef _ASM_SN_ARCH_H 12 #define _ASM_SN_ARCH_H 13 14 #include <linux/types.h> 15 #include <linux/config.h> 16 17 #if !defined(CONFIG_SGI_IO) 18 #include <asm/sn/types.h> 19 #include <asm/sn/sn0/arch.h> 20 #endif 21 22 23 #ifndef __ASSEMBLY__ 24 #if !defined(CONFIG_SGI_IO) 25 typedef u64 hubreg_t; 26 typedef u64 nic_t; 27 #endif 28 #endif 29 30 #ifdef CONFIG_SGI_IP27 31 #define CPUS_PER_NODE 2 /* CPUs on a single hub */ 32 #define CPUS_PER_NODE_SHFT 1 /* Bits to shift in the node number */ 33 #define CPUS_PER_SUBNODE 2 /* CPUs on a single hub PI */ 34 #endif 35 #define CNODE_NUM_CPUS(_cnode) (NODEPDA(_cnode)->node_num_cpus) 36 37 #define CNODE_TO_CPU_BASE(_cnode) (NODEPDA(_cnode)->node_first_cpu) 38 #define cputocnode(cpu) \ 39 (cpu_data[(cpu)].p_nodeid) 40 #define cputonasid(cpu) \ 41 (cpu_data[(cpu)].p_nasid) 42 #define cputoslice(cpu) \ 43 (cpu_data[(cpu)].p_slice) 44 #define makespnum(_nasid, _slice) \ 45 (((_nasid) << CPUS_PER_NODE_SHFT) | (_slice)) 46 47 #ifndef __ASSEMBLY__ 48 49 #define INVALID_NASID (nasid_t)-1 50 #define INVALID_CNODEID (cnodeid_t)-1 51 #define INVALID_PNODEID (pnodeid_t)-1 52 #define INVALID_MODULE (moduleid_t)-1 53 #define INVALID_PARTID (partid_t)-1 54 55 extern nasid_t get_nasid(void); 56 extern cnodeid_t get_cpu_cnode(cpuid_t); 57 extern int get_cpu_slice(cpuid_t); 58 59 /* 60 * NO ONE should access these arrays directly. The only reason we refer to 61 * them here is to avoid the procedure call that would be required in the 62 * macros below. (Really want private data members here :-) 63 */ 64 extern cnodeid_t nasid_to_compact_node[MAX_NASIDS]; 65 extern nasid_t compact_to_nasid_node[MAX_COMPACT_NODES]; 66 67 /* 68 * These macros are used by various parts of the kernel to convert 69 * between the three different kinds of node numbering. At least some 70 * of them may change to procedure calls in the future, but the macros 71 * will continue to work. Don't use the arrays above directly. 72 */ 73 74 #define NASID_TO_REGION(nnode) \ 75 ((nnode) >> \ 76 (is_fine_dirmode() ? NASID_TO_FINEREG_SHFT : NASID_TO_COARSEREG_SHFT)) 77 78 #if !defined(_STANDALONE) 79 extern cnodeid_t nasid_to_compact_node[MAX_NASIDS]; 80 extern nasid_t compact_to_nasid_node[MAX_COMPACT_NODES]; 81 extern cnodeid_t cpuid_to_compact_node[MAXCPUS]; 82 #endif 83 84 #if !defined(DEBUG) && (!defined(SABLE) || defined(_STANDALONE)) 85 86 #define NASID_TO_COMPACT_NODEID(nnode) (nasid_to_compact_node[nnode]) 87 #define COMPACT_TO_NASID_NODEID(cnode) (compact_to_nasid_node[cnode]) 88 #define CPUID_TO_COMPACT_NODEID(cpu) (cpuid_to_compact_node[(cpu)]) 89 #else 90 91 /* 92 * These functions can do type checking and fail if they need to return 93 * a bad nodeid, but they're not as fast so just use 'em for debug kernels. 94 */ 95 cnodeid_t nasid_to_compact_nodeid(nasid_t nasid); 96 nasid_t compact_to_nasid_nodeid(cnodeid_t cnode); 97 98 #define NASID_TO_COMPACT_NODEID(nnode) nasid_to_compact_nodeid(nnode) 99 #define COMPACT_TO_NASID_NODEID(cnode) compact_to_nasid_nodeid(cnode) 100 #define CPUID_TO_COMPACT_NODEID(cpu) (cpuid_to_compact_node[(cpu)]) 101 #endif 102 103 extern int node_getlastslot(cnodeid_t); 104 105 #endif /* !__ASSEMBLY__ */ 106 107 #define SLOT_BITMASK (MAX_MEM_SLOTS - 1) 108 #define SLOT_SIZE (1LL<<SLOT_SHIFT) 109 110 #define node_getnumslots(node) (MAX_MEM_SLOTS) 111 #define NODE_MAX_MEM_SIZE SLOT_SIZE * MAX_MEM_SLOTS 112 113 /* 114 * New stuff in here from Irix sys/pfdat.h. 115 */ 116 #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) 117 #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) 118 #define mkpfn(nasid, off) (((pfn_t)(nasid) << PFN_NASIDSHFT) | (off)) 119 #define slot_getbasepfn(node,slot) \ 120 (mkpfn(COMPACT_TO_NASID_NODEID(node), slot<<SLOT_PFNSHIFT)) 121 #endif /* _ASM_SN_ARCH_H */ 122