mmzone_sn2.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:6k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef _ASM_IA64_SN_MMZONE_SN2_H
  2. #define _ASM_IA64_SN_MMZONE_SN2_H
  3. /*
  4.  * This file is subject to the terms and conditions of the GNU General Public
  5.  * License.  See the file "COPYING" in the main directory of this archive
  6.  * for more details.
  7.  *
  8.  * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All rights reserved.
  9.  */
  10. #include <linux/config.h>
  11. /*
  12.  * SGI SN2 Arch defined values
  13.  *
  14.  *  An SN2 physical address is broken down as follows:
  15.  *
  16.  *             +-----------------------------------------+
  17.  *             |         |      |    |   node offset     |
  18.  *             | unused  | node | AS |-------------------|
  19.  *             |         |      |    | cn | clump offset |
  20.  *             +-----------------------------------------+
  21.  *              6       4 4    3 3  3 3  3 3            0
  22.  *              3       9 8    8 7  6 5  4 3            0
  23.  *
  24.  * bits 63-49 Unused - must be zero
  25.  * bits 48-38 Node number. Note that some configurations do NOT
  26.  * have a node zero.
  27.  * bits 37-36 Address space ID. Cached memory has a value of 3 (!!!).
  28.  * Chipset & IO addresses have other values.
  29.  *   (Yikes!! The hardware folks hate us...)
  30.  * bits 35-0 Node offset.
  31.  *
  32.  * The node offset can be further broken down as:
  33.  * bits 35-34 Clump (bank) number.
  34.  * bits 33-0 Clump (bank) offset.
  35.  *
  36.  * A node consists of up to 4 clumps (banks) of memory. A clump may be empty, or may be
  37.  * populated with a single contiguous block of memory starting at clump
  38.  * offset 0. The size of the block is (2**n) * 64MB, where 0<n<9.
  39.  *
  40.  * Important notes:
  41.  * - IO space addresses are embedded with the range of valid memory addresses.
  42.  * - All cached memory addresses have bits 36 & 37 set to 1's.
  43.  * - There is no physical address 0.
  44.  *
  45.  * NOTE: This file exports symbols prefixed with "PLAT_". Symbols prefixed with
  46.  *  "SN_" are intended for internal use only and should not be used in
  47.  *  any platform independent code. 
  48.  *
  49.  *  This file is also responsible for exporting the following definitions:
  50.  * cnodeid_t Define a compact node id. 
  51.  */
  52. typedef signed short cnodeid_t;
  53. #define SN2_BANKS_PER_NODE 4
  54. #define SN2_NODE_SIZE (64UL*1024*1024*1024) /* 64GB per node */
  55. #define SN2_BANK_SIZE (SN2_NODE_SIZE/SN2_BANKS_PER_NODE)
  56. #define SN2_NODE_SHIFT 38
  57. #define SN2_NODE_MASK 0x7ffUL
  58. #define SN2_NODE_OFFSET_MASK (SN2_NODE_SIZE-1)
  59. #define SN2_NODE_NUMBER(addr) (((unsigned long)(addr) >> SN2_NODE_SHIFT) & SN2_NODE_MASK)
  60. #define SN2_NODE_CLUMP_NUMBER(kaddr) (((unsigned long)(kaddr) >>34) & 3)
  61. #define SN2_NODE_OFFSET(addr) (((unsigned long)(addr)) & SN2_NODE_OFFSET_MASK)
  62. #define SN2_KADDR(nasid, offset) (((unsigned long)(nasid)<<SN2_NODE_SHIFT) | (offset) | SN2_PAGE_OFFSET)
  63. #define SN2_PAGE_OFFSET 0xe000003000000000UL      /* Cacheable memory space */
  64. #define PLAT_MAX_NODE_NUMBER 2048 /* Maximum node number + 1 */
  65. #define PLAT_MAX_COMPACT_NODES 128 /* Maximum number of nodes in SSI system */
  66. #define PLAT_MAX_PHYS_MEMORY (1UL << 49)
  67. /*
  68.  * On the SN platforms, a clump is the same as a memory bank.
  69.  */
  70. #define PLAT_CLUMPS_PER_NODE SN2_BANKS_PER_NODE
  71. #define PLAT_CLUMP_OFFSET(addr) ((unsigned long)(addr) & 0x3ffffffffUL)
  72. #define PLAT_CLUMPSIZE (SN2_NODE_SIZE/PLAT_CLUMPS_PER_NODE)
  73. #define PLAT_MAXCLUMPS (PLAT_CLUMPS_PER_NODE * PLAT_MAX_COMPACT_NODES)
  74. /*
  75.  * PLAT_VALID_MEM_KADDR returns a boolean to indicate if a kaddr is potentially a
  76.  * valid cacheable identity mapped RAM memory address.
  77.  * Note that the RAM may or may not actually be present!!
  78.  */
  79. #define SN2_VALID_KERN_ADDR_MASK 0xffff003000000000UL
  80. #define SN2_VALID_KERN_ADDR_VALUE 0xe000003000000000UL
  81. #define PLAT_VALID_MEM_KADDR(kaddr) (((unsigned long)(kaddr) & SN2_VALID_KERN_ADDR_MASK) == SN2_VALID_KERN_ADDR_VALUE)
  82. /*
  83.  * Memory is conceptually divided into chunks. A chunk is either
  84.  * completely present, or else the kernel assumes it is completely
  85.  * absent. Each node consists of a number of possibly contiguous chunks.
  86.  */
  87. #define SN2_CHUNKSHIFT 25 /* 32 MB */
  88. #define PLAT_CHUNKSIZE (1UL << SN2_CHUNKSHIFT)
  89. #define PLAT_CHUNKNUM(addr) ({unsigned long _p=(unsigned long)(addr);
  90. (((_p&SN2_NODE_MASK)>>2) | 
  91. (_p&SN2_NODE_OFFSET_MASK)) >>SN2_CHUNKSHIFT;})
  92. /*
  93.  * Given a kaddr, find the nid (compact nodeid)
  94.  */
  95. #ifdef CONFIG_IA64_SGI_SN_DEBUG
  96. #define DISCONBUG(kaddr) panic("DISCONTIG BUG: line %d, %s. kaddr 0x%lx",  
  97. __LINE__, __FILE__, (long)(kaddr))
  98. #define KVADDR_TO_NID(kaddr) ({long _ktn=(long)(kaddr);
  99. kern_addr_valid(_ktn) ? 
  100. local_node_data->physical_node_map[SN2_NODE_NUMBER(_ktn)] :
  101. (DISCONBUG(_ktn), 0UL);})
  102. #else
  103. #define KVADDR_TO_NID(kaddr) (local_node_data->physical_node_map[SN2_NODE_NUMBER(kaddr)])
  104. #endif
  105. /*
  106.  * Given a kaddr, find the index into the clump_mem_map_base array of the page struct entry 
  107.  * for the first page of the clump.
  108.  */
  109. #define PLAT_CLUMP_MEM_MAP_INDEX(kaddr) ({long _kmmi=(long)(kaddr);
  110. KVADDR_TO_NID(_kmmi) * PLAT_CLUMPS_PER_NODE +
  111. SN2_NODE_CLUMP_NUMBER(_kmmi);})
  112. /*
  113.  * Calculate a "goal" value to be passed to __alloc_bootmem_node for allocating structures on
  114.  * nodes so that they dont alias to the same line in the cache as the previous allocated structure.
  115.  * This macro takes an address of the end of previous allocation, rounds it to a page boundary & 
  116.  * changes the node number.
  117.  */
  118. #define PLAT_BOOTMEM_ALLOC_GOAL(cnode,kaddr) __pa(SN2_KADDR(PLAT_PXM_TO_PHYS_NODE_NUMBER(nid_to_pxm_map[cnode]),        
  119.  (SN2_NODE_OFFSET(kaddr) + PAGE_SIZE - 1) >> PAGE_SHIFT << PAGE_SHIFT))
  120. /*
  121.  * Convert a proximity domain number (from the ACPI tables) into a physical node number.
  122.  * Note: on SN2, the promity domain number is the same as bits [8:1] of the NASID. The following
  123.  * algorithm relies on:
  124.  * - bit 0 of the NASID for cpu nodes is always 0
  125.  * - bits [10:9] of all NASIDs in a partition are always the same
  126.  * - hard_smp_processor_id return the SAPIC of the current cpu &
  127.  * bits 0..11 contain the NASID.
  128.  *
  129.  * All of this complexity is because MS architectually limited proximity domain numbers to
  130.  * 8 bits. 
  131.  */
  132. #define PLAT_PXM_TO_PHYS_NODE_NUMBER(pxm) (((pxm)<<1) | (hard_smp_processor_id() & 0x300))
  133. #endif /* _ASM_IA64_SN_MMZONE_SN2_H */