sn_cpuid.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. *
  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
  5. * for more details.
  6. *
  7. * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
  8. */
  9. #ifndef _ASM_IA64_SN_SN_CPUID_H
  10. #define _ASM_IA64_SN_SN_CPUID_H
  11. #include <linux/config.h>
  12. #include <linux/smp.h>
  13. #include <asm/sn/addrs.h>
  14. #include <asm/sn/pda.h>
  15. #include <asm/intrinsics.h>
  16. /*
  17. * Functions for converting between cpuids, nodeids and NASIDs.
  18. *
  19. * These are for SGI platforms only.
  20. *
  21. */
  22. /*
  23. * Definitions of terms (these definitions are for IA64 ONLY. Other architectures
  24. * use cpuid/cpunum quite defferently):
  25. *
  26. * CPUID - a number in range of 0..NR_CPUS-1 that uniquely identifies
  27. * the cpu. The value cpuid has no significance on IA64 other than
  28. * the boot cpu is 0.
  29. * smp_processor_id() returns the cpuid of the current cpu.
  30. *
  31. * CPU_PHYSICAL_ID (also known as HARD_PROCESSOR_ID)
  32. * This is the same as 31:24 of the processor LID register
  33. * hard_smp_processor_id()- cpu_physical_id of current processor
  34. * cpu_physical_id(cpuid) - convert a <cpuid> to a <physical_cpuid>
  35. * cpu_logical_id(phy_id) - convert a <physical_cpuid> to a <cpuid>
  36. * * not real efficient - don't use in perf critical code
  37. *
  38. * SLICE - a number in the range of 0 - 3 (typically) that represents the
  39. * cpu number on a brick.
  40. *
  41. * SUBNODE - (almost obsolete) the number of the FSB that a cpu is
  42. * connected to. This is also the same as the PI number. Usually 0 or 1.
  43. *
  44. * NOTE!!!: the value of the bits in the cpu physical id (SAPICid or LID) of a cpu has no
  45. * significance. The SAPIC id (LID) is a 16-bit cookie that has meaning only to the PROM.
  46. *
  47. *
  48. * The macros convert between cpu physical ids & slice/nasid/cnodeid.
  49. * These terms are described below:
  50. *
  51. *
  52. * Brick
  53. * ----- ----- ----- ----- CPU
  54. * | 0 | | 1 | | 0 | | 1 | SLICE
  55. * ----- ----- ----- -----
  56. * | | | |
  57. * | | | |
  58. * 0 | | 2 0 | | 2 FSB SLOT
  59. * ------- -------
  60. * | |
  61. * | |
  62. * | |
  63. * ------------ -------------
  64. * | | | |
  65. * | SHUB | | SHUB | NASID (0..MAX_NASIDS)
  66. * | |----- | | CNODEID (0..num_compact_nodes-1)
  67. * | | | |
  68. * | | | |
  69. * ------------ -------------
  70. * | |
  71. *
  72. *
  73. */
  74. #define get_node_number(addr) NASID_GET(addr)
  75. /*
  76. * NOTE: on non-MP systems, only cpuid 0 exists
  77. */
  78. extern short physical_node_map[]; /* indexed by nasid to get cnode */
  79. /*
  80. * Macros for retrieving info about current cpu
  81. */
  82. #define get_nasid() (sn_nodepda->phys_cpuid[smp_processor_id()].nasid)
  83. #define get_subnode() (sn_nodepda->phys_cpuid[smp_processor_id()].subnode)
  84. #define get_slice() (sn_nodepda->phys_cpuid[smp_processor_id()].slice)
  85. #define get_cnode() (sn_nodepda->phys_cpuid[smp_processor_id()].cnode)
  86. #define get_sapicid() ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
  87. /*
  88. * Macros for retrieving info about an arbitrary cpu
  89. * cpuid - logical cpu id
  90. */
  91. #define cpuid_to_nasid(cpuid) (sn_nodepda->phys_cpuid[cpuid].nasid)
  92. #define cpuid_to_subnode(cpuid) (sn_nodepda->phys_cpuid[cpuid].subnode)
  93. #define cpuid_to_slice(cpuid) (sn_nodepda->phys_cpuid[cpuid].slice)
  94. #define cpuid_to_cnodeid(cpuid) (physical_node_map[cpuid_to_nasid(cpuid)])
  95. /*
  96. * Dont use the following in performance critical code. They require scans
  97. * of potentially large tables.
  98. */
  99. extern int nasid_slice_to_cpuid(int, int);
  100. #define nasid_slice_to_cpu_physical_id(nasid, slice) \
  101. cpu_physical_id(nasid_slice_to_cpuid(nasid, slice))
  102. /*
  103. * cnodeid_to_nasid - convert a cnodeid to a NASID
  104. */
  105. #define cnodeid_to_nasid(cnodeid) (sn_cnodeid_to_nasid[cnodeid])
  106. /*
  107. * nasid_to_cnodeid - convert a NASID to a cnodeid
  108. */
  109. #define nasid_to_cnodeid(nasid) (physical_node_map[nasid])
  110. /*
  111. * partition_coherence_id - get the coherence ID of the current partition
  112. */
  113. extern u8 sn_coherency_id;
  114. #define partition_coherence_id() (sn_coherency_id)
  115. #endif /* _ASM_IA64_SN_SN_CPUID_H */