blob: d721143dbd47596f4387c8ba72f9baa1153c4ef1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Written by Kanoj Sarcar (kanoj@sgi.com) Aug 99
3 * Rewritten for Linux 2.6 by Christoph Hellwig (hch@lst.de) Jan 2004
4 */
5#ifndef _ASM_MMZONE_H_
6#define _ASM_MMZONE_H_
7
8#include <asm/page.h>
9#include <mmzone.h>
10
Yoichi Yuasab4819b52005-06-25 14:54:31 -070011#ifdef CONFIG_DISCONTIGMEM
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#define kvaddr_to_nid(kvaddr) pa_to_nid(__pa(kvaddr))
14#define pfn_to_nid(pfn) pa_to_nid((pfn) << PAGE_SHIFT)
15
16#define pfn_valid(pfn) \
17({ \
18 unsigned long __pfn = (pfn); \
19 int __n = pfn_to_nid(__pfn); \
20 ((__n >= 0) ? (__pfn < NODE_DATA(__n)->node_start_pfn + \
21 NODE_DATA(__n)->node_spanned_pages) : 0);\
22})
23
24#define pfn_to_page(pfn) \
25({ \
26 unsigned long __pfn = (pfn); \
27 pg_data_t *__pg = NODE_DATA(pfn_to_nid(__pfn)); \
28 __pg->node_mem_map + (__pfn - __pg->node_start_pfn); \
29})
30
31#define page_to_pfn(p) \
32({ \
33 struct page *__p = (p); \
34 struct zone *__z = page_zone(__p); \
35 ((__p - __z->zone_mem_map) + __z->zone_start_pfn); \
36})
37
38/* XXX: FIXME -- wli */
39#define kern_addr_valid(addr) (0)
40
Yoichi Yuasab4819b52005-06-25 14:54:31 -070041#endif /* CONFIG_DISCONTIGMEM */
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#endif /* _ASM_MMZONE_H_ */