Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/asm-sh/mmzone.h |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
| 8 | #ifndef __ASM_SH_MMZONE_H |
| 9 | #define __ASM_SH_MMZONE_H |
| 10 | |
| 11 | #include <linux/config.h> |
| 12 | |
| 13 | #ifdef CONFIG_DISCONTIGMEM |
| 14 | |
| 15 | /* Currently, just for HP690 */ |
| 16 | #define PHYSADDR_TO_NID(phys) ((((phys) - __MEMORY_START) >= 0x01000000)?1:0) |
| 17 | |
| 18 | extern pg_data_t discontig_page_data[MAX_NUMNODES]; |
| 19 | extern bootmem_data_t discontig_node_bdata[MAX_NUMNODES]; |
| 20 | |
| 21 | /* |
| 22 | * Following are macros that each numa implmentation must define. |
| 23 | */ |
| 24 | |
| 25 | /* |
| 26 | * Given a kernel address, find the home node of the underlying memory. |
| 27 | */ |
| 28 | #define KVADDR_TO_NID(kaddr) PHYSADDR_TO_NID(__pa(kaddr)) |
| 29 | |
| 30 | /* |
| 31 | * Return a pointer to the node data for node n. |
| 32 | */ |
| 33 | #define NODE_DATA(nid) (&discontig_page_data[nid]) |
| 34 | |
| 35 | /* |
| 36 | * NODE_MEM_MAP gives the kaddr for the mem_map of the node. |
| 37 | */ |
| 38 | #define NODE_MEM_MAP(nid) (NODE_DATA(nid)->node_mem_map) |
| 39 | |
| 40 | #define phys_to_page(phys) \ |
| 41 | ({ unsigned int node = PHYSADDR_TO_NID(phys); \ |
| 42 | NODE_MEM_MAP(node) \ |
| 43 | + (((phys) - NODE_DATA(node)->node_start_paddr) >> PAGE_SHIFT); }) |
| 44 | |
| 45 | static inline int is_valid_page(struct page *page) |
| 46 | { |
| 47 | unsigned int i; |
| 48 | |
| 49 | for (i = 0; i < MAX_NUMNODES; i++) { |
| 50 | if (page >= NODE_MEM_MAP(i) && |
| 51 | page < NODE_MEM_MAP(i) + NODE_DATA(i)->node_size) |
| 52 | return 1; |
| 53 | } |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | #define VALID_PAGE(page) is_valid_page(page) |
| 58 | #define page_to_phys(page) PHYSADDR(page_address(page)) |
| 59 | |
| 60 | #endif /* CONFIG_DISCONTIGMEM */ |
| 61 | #endif |