blob: 5e83a416eca8941410c0b93a99beff853831f433 [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 -070051/*
52 * Following are macros that each numa implmentation must define.
53 */
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
56#define node_end_pfn(nid) \
57({ \
58 pg_data_t *__pgdat = NODE_DATA(nid); \
59 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
60})
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062static inline int pfn_valid(int pfn)
63{
64 int nid = pfn_to_nid(pfn);
65
66 if (nid >= 0)
67 return (pfn < node_end_pfn(nid));
68 return 0;
69}
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71#endif /* CONFIG_DISCONTIGMEM */
Andy Whitcroftb159d432005-06-23 00:07:52 -070072
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070073#ifdef CONFIG_NEED_MULTIPLE_NODES
Tejun Heoc1329372009-02-24 11:57:20 +090074/* always use node 0 for bootmem on this numa platform */
Tejun Heod0c4f572009-03-01 16:06:56 +090075#define bootmem_arch_preferred_node(__bdata, size, align, goal, limit) \
76 (NODE_DATA(0)->bdata)
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070077#endif /* CONFIG_NEED_MULTIPLE_NODES */
78
H. Peter Anvin1965aae2008-10-22 22:26:29 -070079#endif /* _ASM_X86_MMZONE_32_H */