mmzone_32.h 3.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5
/*
 * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
 *
 */

H
H. Peter Anvin 已提交
6 7
#ifndef _ASM_X86_MMZONE_32_H
#define _ASM_X86_MMZONE_32_H
L
Linus Torvalds 已提交
8 9 10

#include <asm/smp.h>

11
#ifdef CONFIG_NUMA
12 13
extern struct pglist_data *node_data[];
#define NODE_DATA(nid)	(node_data[nid])
L
Linus Torvalds 已提交
14

15 16 17
#include <asm/numaq.h>
/* summit or generic arch */
#include <asm/srat.h>
L
Linus Torvalds 已提交
18

19
extern int get_memcfg_numa_flat(void);
20 21 22 23 24 25 26
/*
 * This allows any one NUMA architecture to be compiled
 * for, and still fall back to the flat function if it
 * fails.
 */
static inline void get_memcfg_numa(void)
{
27

28 29 30 31 32 33 34
	if (get_memcfg_numaq())
		return;
	if (get_memcfg_from_srat())
		return;
	get_memcfg_numa_flat();
}

35 36
extern void resume_map_numa_kva(pgd_t *pgd);

37
#else /* !CONFIG_NUMA */
38

39
#define get_memcfg_numa get_memcfg_numa_flat
40

41 42
static inline void resume_map_numa_kva(pgd_t *pgd) {}

43 44 45
#endif /* CONFIG_NUMA */

#ifdef CONFIG_DISCONTIGMEM
L
Linus Torvalds 已提交
46 47 48 49

/*
 * generic node memory support, the following assumptions apply:
 *
50
 * 1) memory comes in 64Mb contigious chunks which are either present or not
L
Linus Torvalds 已提交
51 52 53 54 55 56
 * 2) we will not have more than 64Gb in total
 *
 * for now assume that 64Gb is max amount of RAM for whole system
 *    64Gb / 4096bytes/page = 16777216 pages
 */
#define MAX_NR_PAGES 16777216
57
#define MAX_ELEMENTS 1024
L
Linus Torvalds 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
#define PAGES_PER_ELEMENT (MAX_NR_PAGES/MAX_ELEMENTS)

extern s8 physnode_map[];

static inline int pfn_to_nid(unsigned long pfn)
{
#ifdef CONFIG_NUMA
	return((int) physnode_map[(pfn) / PAGES_PER_ELEMENT]);
#else
	return 0;
#endif
}

/*
 * Following are macros that each numa implmentation must define.
 */

#define node_start_pfn(nid)	(NODE_DATA(nid)->node_start_pfn)
#define node_end_pfn(nid)						\
({									\
	pg_data_t *__pgdat = NODE_DATA(nid);				\
	__pgdat->node_start_pfn + __pgdat->node_spanned_pages;		\
})

static inline int pfn_valid(int pfn)
{
	int nid = pfn_to_nid(pfn);

	if (nid >= 0)
		return (pfn < node_end_pfn(nid));
	return 0;
}
90 91 92 93

#endif /* CONFIG_DISCONTIGMEM */

#ifdef CONFIG_NEED_MULTIPLE_NODES
L
Linus Torvalds 已提交
94 95

/*
96
 * Following are macros that are specific to this numa platform.
L
Linus Torvalds 已提交
97
 */
98 99
#define reserve_bootmem(addr, size, flags) \
	reserve_bootmem_node(NODE_DATA(0), (addr), (size), (flags))
100 101
#define alloc_bootmem(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
102 103 104
#define alloc_bootmem_nopanic(x) \
	__alloc_bootmem_node_nopanic(NODE_DATA(0), (x), SMP_CACHE_BYTES, \
				__pa(MAX_DMA_ADDRESS))
105 106 107 108
#define alloc_bootmem_low(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0)
#define alloc_bootmem_pages(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
109 110 111
#define alloc_bootmem_pages_nopanic(x) \
	__alloc_bootmem_node_nopanic(NODE_DATA(0), (x), PAGE_SIZE, \
				__pa(MAX_DMA_ADDRESS))
112 113
#define alloc_bootmem_low_pages(x) \
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
114 115
#define alloc_bootmem_node(pgdat, x)					\
({									\
D
David Rientjes 已提交
116
	struct pglist_data  __maybe_unused			\
117 118 119 120 121 122
				*__alloc_bootmem_node__pgdat = (pgdat);	\
	__alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES,	\
						__pa(MAX_DMA_ADDRESS));	\
})
#define alloc_bootmem_pages_node(pgdat, x)				\
({									\
D
David Rientjes 已提交
123
	struct pglist_data  __maybe_unused			\
124 125
				*__alloc_bootmem_node__pgdat = (pgdat);	\
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE,		\
126
						__pa(MAX_DMA_ADDRESS));	\
127 128 129
})
#define alloc_bootmem_low_pages_node(pgdat, x)				\
({									\
D
David Rientjes 已提交
130
	struct pglist_data  __maybe_unused			\
131 132 133
				*__alloc_bootmem_node__pgdat = (pgdat);	\
	__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0);		\
})
134
#endif /* CONFIG_NEED_MULTIPLE_NODES */
135

H
H. Peter Anvin 已提交
136
#endif /* _ASM_X86_MMZONE_32_H */