mmzone.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
  3. *
  4. */
  5. #ifndef _ASM_MMZONE_H_
  6. #define _ASM_MMZONE_H_
  7. #include <asm/smp.h>
  8. #ifdef CONFIG_DISCONTIGMEM
  9. extern struct pglist_data *node_data[];
  10. #define NODE_DATA(nid) (node_data[nid])
  11. #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
  12. #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
  13. /*
  14. * pfn_valid should be made as fast as possible, and the current definition
  15. * is valid for machines that are NUMA, but still contiguous, which is what
  16. * is currently supported. A more generalised, but slower definition would
  17. * be something like this - mbligh:
  18. * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) )
  19. */
  20. #if 1 /* M32R_FIXME */
  21. #define pfn_valid(pfn) (1)
  22. #else
  23. #define pfn_valid(pfn) ((pfn) < num_physpages)
  24. #endif
  25. /*
  26. * generic node memory support, the following assumptions apply:
  27. */
  28. static __inline__ int pfn_to_nid(unsigned long pfn)
  29. {
  30. int node;
  31. for (node = 0 ; node < MAX_NUMNODES ; node++)
  32. if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
  33. break;
  34. return node;
  35. }
  36. static __inline__ struct pglist_data *pfn_to_pgdat(unsigned long pfn)
  37. {
  38. return(NODE_DATA(pfn_to_nid(pfn)));
  39. }
  40. #endif /* CONFIG_DISCONTIGMEM */
  41. #endif /* _ASM_MMZONE_H_ */