blob: 55728e12147364d9ab1ffd9beed91e8dcc09cca8 [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
Tejun Heod0ead152011-07-12 09:44:22 +020037#define MAX_SECTIONS 1024
38#define PAGES_PER_SECTION (MAX_NR_PAGES/MAX_SECTIONS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40extern s8 physnode_map[];
41
42static inline int pfn_to_nid(unsigned long pfn)
43{
44#ifdef CONFIG_NUMA
Tejun Heod0ead152011-07-12 09:44:22 +020045 return((int) physnode_map[(pfn) / PAGES_PER_SECTION]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#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
Tejun Heoa26474e2011-06-28 11:41:07 +020060#define early_pfn_valid(pfn) pfn_valid((pfn))
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#endif /* CONFIG_DISCONTIGMEM */
Andy Whitcroftb159d432005-06-23 00:07:52 -070063
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070064#ifdef CONFIG_NEED_MULTIPLE_NODES
Tejun Heoc1329372009-02-24 11:57:20 +090065/* always use node 0 for bootmem on this numa platform */
Tejun Heod0c4f572009-03-01 16:06:56 +090066#define bootmem_arch_preferred_node(__bdata, size, align, goal, limit) \
67 (NODE_DATA(0)->bdata)
Andy Whitcroft05b79bd2005-06-23 00:07:57 -070068#endif /* CONFIG_NEED_MULTIPLE_NODES */
69
H. Peter Anvin1965aae2008-10-22 22:26:29 -070070#endif /* _ASM_X86_MMZONE_32_H */