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
7 * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
11 #ifndef _ASM_IA64_SN_SN_CPUID_H
12 #define _ASM_IA64_SN_SN_CPUID_H
14 #include <linux/config.h>
15 #include <linux/smp.h>
16 #include <asm/sn/pda.h>
17 #include <asm/intrinsics.h>
21 * Functions for converting between cpuids, nodeids and NASIDs.
23 * These are for SGI platforms only.
31 * Definitions of terms (these definitions are for IA64 ONLY. Other architectures
32 * use cpuid/cpunum quite defferently):
34 * CPUID - a number in range of 0..NR_CPUS-1 that uniquely identifies
35 * the cpu. The value cpuid has no significance on IA64 other than
37 * smp_processor_id() returns the cpuid of the current cpu.
39 * CPUNUM - On IA64, a cpunum and cpuid are the same. This is NOT true
40 * on other architectures like IA32.
42 * CPU_PHYSICAL_ID (also known as HARD_PROCESSOR_ID)
43 * This is the same as 31:24 of the processor LID register
44 * hard_smp_processor_id()- cpu_physical_id of current processor
45 * cpu_physical_id(cpuid) - convert a <cpuid> to a <physical_cpuid>
46 * cpu_logical_id(phy_id) - convert a <physical_cpuid> to a <cpuid>
47 * * not real efficient - don't use in perf critical code
49 * LID - processor defined register (see PRM V2).
52 * 31:28 - id Contains 0-3 to identify the cpu on the node
53 * 27:16 - eid Contains the NASID
57 * The following assumes the following mappings for LID register values:
59 * The macros convert between cpu physical ids & slice/nasid/cnodeid.
60 * These terms are described below:
64 * ----- ----- ----- ----- CPU
65 * | 0 | | 1 | | 0 | | 1 | SLICE
66 * ----- ----- ----- -----
69 * 0 | | 2 0 | | 2 FSB SLOT
74 * ------------ -------------
76 * | SHUB | | SHUB | NASID (0..MAX_NASIDS)
77 * | |----- | | CNODEID (0..num_compact_nodes-1)
80 * ------------ -------------
87 #define cpu_logical_id(cpu) 0
88 #define cpu_physical_id(cpuid) ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
92 * macros for some of these exist in sn/addrs.h & sn/arch.h, etc. However,
93 * trying #include these files here causes circular dependencies.
95 #define cpu_physical_id_to_nasid(cpi) ((cpi) &0xfff)
96 #define cpu_physical_id_to_slice(cpi) ((cpi>>12) & 3)
97 #define get_nasid() ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xfff)
98 #define get_slice() ((ia64_getreg(_IA64_REG_CR_LID) >> 28) & 0xf)
99 #define get_node_number(addr) (((unsigned long)(addr)>>38) & 0x7ff)
102 * NOTE: id & eid refer to Intel's definitions of the LID register
104 * NOTE: on non-MP systems, only cpuid 0 exists
106 #define id_eid_to_cpu_physical_id(id,eid) (((id)<<8) | (eid))
108 #define nasid_slice_to_cpuid(nasid,slice) (cpu_logical_id(nasid_slice_to_cpu_physical_id((nasid),(slice))))
110 #define nasid_slice_to_cpu_physical_id(nasid, slice) (((slice)<<12) | (nasid))
113 * The following table/struct is used for managing PTC coherency domains.
121 extern sn_sapicid_info_t sn_sapicid_info[]; /* indexed by cpuid */
122 extern short physical_node_map[]; /* indexed by nasid to get cnode */
126 * cpuid_to_slice - convert a cpuid to the slice that it resides on
127 * There are 4 cpus per node. This function returns 0 .. 3)
129 #define cpuid_to_slice(cpuid) (cpu_physical_id_to_slice(cpu_physical_id(cpuid)))
133 * cpuid_to_nasid - convert a cpuid to the NASID that it resides on
135 #define cpuid_to_nasid(cpuid) (cpu_physical_id_to_nasid(cpu_physical_id(cpuid)))
139 * cpuid_to_cnodeid - convert a cpuid to the cnode that it resides on
141 #define cpuid_to_cnodeid(cpuid) (physical_node_map[cpuid_to_nasid(cpuid)])
145 * cnodeid_to_nasid - convert a cnodeid to a NASID
146 * Macro relies on pg_data for a node being on the node itself.
147 * Just extract the NASID from the pointer.
150 #define cnodeid_to_nasid(cnodeid) pda->cnodeid_to_nasid_table[cnodeid]
154 * nasid_to_cnodeid - convert a NASID to a cnodeid
156 #define nasid_to_cnodeid(nasid) (physical_node_map[nasid])
160 * cnode_slice_to_cpuid - convert a codeid & slice to a cpuid
163 #define cnode_slice_to_cpuid(cnodeid,slice) (nasid_slice_to_cpuid(cnodeid_to_nasid(cnodeid),(slice)))
167 * cpuid_to_subnode - convert a cpuid to the subnode it resides on.
168 * slice 0 & 1 are on subnode 0
169 * slice 2 & 3 are on subnode 1.
171 #define cpuid_to_subnode(cpuid) ((cpuid_to_slice(cpuid)<2) ? 0 : 1)
174 #define smp_physical_node_id() (cpuid_to_nasid(smp_processor_id()))
177 #endif /* _ASM_IA64_SN_SN_CPUID_H */