aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-parisc/mmzone.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-parisc/mmzone.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-parisc/mmzone.h')
-rw-r--r--include/asm-parisc/mmzone.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/include/asm-parisc/mmzone.h b/include/asm-parisc/mmzone.h
new file mode 100644
index 000000000000..928bf50c4693
--- /dev/null
+++ b/include/asm-parisc/mmzone.h
@@ -0,0 +1,102 @@
1#ifndef _PARISC_MMZONE_H
2#define _PARISC_MMZONE_H
3
4#ifdef CONFIG_DISCONTIGMEM
5
6#define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
7extern int npmem_ranges;
8
9struct node_map_data {
10 pg_data_t pg_data;
11};
12
13extern struct node_map_data node_data[];
14
15#define NODE_DATA(nid) (&node_data[nid].pg_data)
16
17/*
18 * Given a kernel address, find the home node of the underlying memory.
19 */
20#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
21
22#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
23#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
24#define node_end_pfn(nid) \
25({ \
26 pg_data_t *__pgdat = NODE_DATA(nid); \
27 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
28})
29#define node_localnr(pfn, nid) ((pfn) - node_start_pfn(nid))
30
31#define local_mapnr(kvaddr) \
32({ \
33 unsigned long __pfn = __pa(kvaddr) >> PAGE_SHIFT; \
34 (__pfn - node_start_pfn(pfn_to_nid(__pfn))); \
35})
36
37#define pfn_to_page(pfn) \
38({ \
39 unsigned long __pfn = (pfn); \
40 int __node = pfn_to_nid(__pfn); \
41 &node_mem_map(__node)[node_localnr(__pfn,__node)]; \
42})
43
44#define page_to_pfn(pg) \
45({ \
46 struct page *__page = pg; \
47 struct zone *__zone = page_zone(__page); \
48 BUG_ON(__zone == NULL); \
49 (unsigned long)(__page - __zone->zone_mem_map) \
50 + __zone->zone_start_pfn; \
51})
52
53/* We have these possible memory map layouts:
54 * Astro: 0-3.75, 67.75-68, 4-64
55 * zx1: 0-1, 257-260, 4-256
56 * Stretch (N-class): 0-2, 4-32, 34-xxx
57 */
58
59/* Since each 1GB can only belong to one region (node), we can create
60 * an index table for pfn to nid lookup; each entry in pfnnid_map
61 * represents 1GB, and contains the node that the memory belongs to. */
62
63#define PFNNID_SHIFT (30 - PAGE_SHIFT)
64#define PFNNID_MAP_MAX 512 /* support 512GB */
65extern unsigned char pfnnid_map[PFNNID_MAP_MAX];
66
67#ifndef __LP64__
68#define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
69#else
70/* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
71#define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
72#endif
73
74static inline int pfn_to_nid(unsigned long pfn)
75{
76 unsigned int i;
77 unsigned char r;
78
79 if (unlikely(pfn_is_io(pfn)))
80 return 0;
81
82 i = pfn >> PFNNID_SHIFT;
83 BUG_ON(i >= sizeof(pfnnid_map) / sizeof(pfnnid_map[0]));
84 r = pfnnid_map[i];
85 BUG_ON(r == 0xff);
86
87 return (int)r;
88}
89
90static inline int pfn_valid(int pfn)
91{
92 int nid = pfn_to_nid(pfn);
93
94 if (nid >= 0)
95 return (pfn < node_end_pfn(nid));
96 return 0;
97}
98
99#else /* !CONFIG_DISCONTIGMEM */
100#define MAX_PHYSMEM_RANGES 1
101#endif
102#endif /* _PARISC_MMZONE_H */