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