11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 61965aae3c98397aad957412413c07e97b1bd4e64H. Peter Anvin#ifndef _ASM_X86_MMZONE_32_H 71965aae3c98397aad957412413c07e97b1bd4e64H. Peter Anvin#define _ASM_X86_MMZONE_32_H 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/smp.h> 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 118ff8b27bb8ebfd863b49653da1b7bbd8609fcd7eDave Jones#ifdef CONFIG_NUMA 1205b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroftextern struct pglist_data *node_data[]; 1305b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft#define NODE_DATA(nid) (node_data[nid]) 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 15d49c4288407b2ffa8cab270cb5bc6882abe969f6Yinghai Lu#include <asm/numaq.h> 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1797a70e548bd97d5a46ae9d44f24aafcc013fd701Rafael J. Wysockiextern void resume_map_numa_kva(pgd_t *pgd); 1897a70e548bd97d5a46ae9d44f24aafcc013fd701Rafael J. Wysocki 198ff8b27bb8ebfd863b49653da1b7bbd8609fcd7eDave Jones#else /* !CONFIG_NUMA */ 2091023300057e96de7f46e95166a3e02394ae72f9keith mannthey 2197a70e548bd97d5a46ae9d44f24aafcc013fd701Rafael J. Wysockistatic inline void resume_map_numa_kva(pgd_t *pgd) {} 2297a70e548bd97d5a46ae9d44f24aafcc013fd701Rafael J. Wysocki 2305b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft#endif /* CONFIG_NUMA */ 2405b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft 2505b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft#ifdef CONFIG_DISCONTIGMEM 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * generic node memory support, the following assumptions apply: 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 30af901ca181d92aac3a7dc265144a9081a86d8f39André Goddard Rosa * 1) memory comes in 64Mb contiguous chunks which are either present or not 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2) we will not have more than 64Gb in total 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * for now assume that 64Gb is max amount of RAM for whole system 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 64Gb / 4096bytes/page = 16777216 pages 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MAX_NR_PAGES 16777216 37d0ead157387f19801beb1b419568723b2e9b7c79Tejun Heo#define MAX_SECTIONS 1024 38d0ead157387f19801beb1b419568723b2e9b7c79Tejun Heo#define PAGES_PER_SECTION (MAX_NR_PAGES/MAX_SECTIONS) 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern s8 physnode_map[]; 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline int pfn_to_nid(unsigned long pfn) 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_NUMA 45d0ead157387f19801beb1b419568723b2e9b7c79Tejun Heo return((int) physnode_map[(pfn) / PAGES_PER_SECTION]); 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline int pfn_valid(int pfn) 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int nid = pfn_to_nid(pfn); 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (nid >= 0) 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (pfn < node_end_pfn(nid)); 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 5905b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft 60a26474e8649643e82d71e3a386d5c4bcc0b207efTejun Heo#define early_pfn_valid(pfn) pfn_valid((pfn)) 61a26474e8649643e82d71e3a386d5c4bcc0b207efTejun Heo 6205b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft#endif /* CONFIG_DISCONTIGMEM */ 6305b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft 6405b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft#ifdef CONFIG_NEED_MULTIPLE_NODES 65c132937556f56ee4b831ef4b23f1846e05fde102Tejun Heo/* always use node 0 for bootmem on this numa platform */ 66d0c4f570276cb4d2dc4215b90eb7cb6e2bdd4a15Tejun Heo#define bootmem_arch_preferred_node(__bdata, size, align, goal, limit) \ 67d0c4f570276cb4d2dc4215b90eb7cb6e2bdd4a15Tejun Heo (NODE_DATA(0)->bdata) 6805b79bdcb48c18cd9b580c39e3efb9a1ab078151Andy Whitcroft#endif /* CONFIG_NEED_MULTIPLE_NODES */ 69b159d43fbf7eaaac6ecc647f51cf4257332db47bAndy Whitcroft 701965aae3c98397aad957412413c07e97b1bd4e64H. Peter Anvin#endif /* _ASM_X86_MMZONE_32_H */ 71