blob: 224e8c5eb3070351fe06a6838a611b6a5a1799bb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
3 *
4 */
5
H. Peter Anvin1965aae2008-10-22 22:26:29 -07006#ifndef _ASM_X86_MMZONE_32_H
7#define _ASM_X86_MMZONE_32_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9#include <asm/smp.h>
10
Dave Jones8ff8b272005-07-07 17:56:39 -070011#ifdef CONFIG_NUMA
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070012extern struct pglist_data *node_data[];
13#define NODE_DATA(nid) (node_data[nid])
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Yinghai Lud49c4282008-06-08 18:31:54 -070015#include <asm/numaq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Rafael J. Wysocki97a70e52008-11-12 23:22:35 +010017extern void resume_map_numa_kva(pgd_t *pgd);
18
Dave Jones8ff8b272005-07-07 17:56:39 -070019#else /* !CONFIG_NUMA */
keith mannthey91023302006-09-25 23:31:03 -070020
Rafael J. Wysocki97a70e52008-11-12 23:22:35 +010021static inline void resume_map_numa_kva(pgd_t *pgd) {}
22
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070023#endif /* CONFIG_NUMA */
24
25#ifdef CONFIG_DISCONTIGMEM
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27/*
28 * generic node memory support, the following assumptions apply:
29 *
André Goddard Rosaaf901ca2009-11-14 13:09:05 -020030 * 1) memory comes in 64Mb contiguous chunks which are either present or not
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 * 2) we will not have more than 64Gb in total
32 *
33 * for now assume that 64Gb is max amount of RAM for whole system
34 * 64Gb / 4096bytes/page = 16777216 pages
35 */
36#define MAX_NR_PAGES 16777216
Yinghai Luba924c82008-05-31 22:51:51 -070037#define MAX_ELEMENTS 1024
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define PAGES_PER_ELEMENT (MAX_NR_PAGES/MAX_ELEMENTS)
39
40extern s8 physnode_map[];
41
42static inline int pfn_to_nid(unsigned long pfn)
43{
44#ifdef CONFIG_NUMA
45 return((int) physnode_map[(pfn) / PAGES_PER_ELEMENT]);
46#else
47 return 0;
48#endif
49}
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051static inline int pfn_valid(int pfn)
52{
53 int nid = pfn_to_nid(pfn);
54
55 if (nid >= 0)
56 return (pfn < node_end_pfn(nid));
57 return 0;
58}
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#endif /* CONFIG_DISCONTIGMEM */
Andy Whitcroftb159d432005-06-23 00:07:52 -070061
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070062#ifdef CONFIG_NEED_MULTIPLE_NODES
Tejun Heoc1329372009-02-24 11:57:20 +090063/* always use node 0 for bootmem on this numa platform */
Tejun Heod0c4f572009-03-01 16:06:56 +090064#define bootmem_arch_preferred_node(__bdata, size, align, goal, limit) \
65 (NODE_DATA(0)->bdata)
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070066#endif /* CONFIG_NEED_MULTIPLE_NODES */
67
H. Peter Anvin1965aae2008-10-22 22:26:29 -070068#endif /* _ASM_X86_MMZONE_32_H */