mmzone.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Written by Kanoj Sarcar (kanoj@sgi.com) Aug 99
  3. * Adapted for the alpha wildfire architecture Jan 2001.
  4. */
  5. #ifndef _ASM_MMZONE_H_
  6. #define _ASM_MMZONE_H_
  7. #include <asm/smp.h>
  8. struct bootmem_data_t; /* stupid forward decl. */
  9. /*
  10. * Following are macros that are specific to this numa platform.
  11. */
  12. extern pg_data_t node_data[];
  13. #define alpha_pa_to_nid(pa) \
  14. (alpha_mv.pa_to_nid \
  15. ? alpha_mv.pa_to_nid(pa) \
  16. : (0))
  17. #define node_mem_start(nid) \
  18. (alpha_mv.node_mem_start \
  19. ? alpha_mv.node_mem_start(nid) \
  20. : (0UL))
  21. #define node_mem_size(nid) \
  22. (alpha_mv.node_mem_size \
  23. ? alpha_mv.node_mem_size(nid) \
  24. : ((nid) ? (0UL) : (~0UL)))
  25. #define pa_to_nid(pa) alpha_pa_to_nid(pa)
  26. #define NODE_DATA(nid) (&node_data[(nid)])
  27. #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
  28. #if 1
  29. #define PLAT_NODE_DATA_LOCALNR(p, n) \
  30. (((p) >> PAGE_SHIFT) - PLAT_NODE_DATA(n)->gendata.node_start_pfn)
  31. #else
  32. static inline unsigned long
  33. PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
  34. {
  35. unsigned long temp;
  36. temp = p >> PAGE_SHIFT;
  37. return temp - PLAT_NODE_DATA(n)->gendata.node_start_pfn;
  38. }
  39. #endif
  40. #ifdef CONFIG_DISCONTIGMEM
  41. /*
  42. * Following are macros that each numa implementation must define.
  43. */
  44. /*
  45. * Given a kernel address, find the home node of the underlying memory.
  46. */
  47. #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
  48. /*
  49. * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
  50. * and returns the kaddr corresponding to first physical page in the
  51. * node's mem_map.
  52. */
  53. #define LOCAL_BASE_ADDR(kaddr) \
  54. ((unsigned long)__va(NODE_DATA(kvaddr_to_nid(kaddr))->node_start_pfn \
  55. << PAGE_SHIFT))
  56. /* XXX: FIXME -- nyc */
  57. #define kern_addr_valid(kaddr) (0)
  58. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  59. #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> 32))
  60. #define pgd_page(pgd) (pfn_to_page(pgd_val(pgd) >> 32))
  61. #define pte_pfn(pte) (pte_val(pte) >> 32)
  62. #define mk_pte(page, pgprot) \
  63. ({ \
  64. pte_t pte; \
  65. unsigned long pfn; \
  66. \
  67. pfn = page_to_pfn(page) << 32; \
  68. pte_val(pte) = pfn | pgprot_val(pgprot); \
  69. \
  70. pte; \
  71. })
  72. #define pte_page(x) \
  73. ({ \
  74. unsigned long kvirt; \
  75. struct page * __xx; \
  76. \
  77. kvirt = (unsigned long)__va(pte_val(x) >> (32-PAGE_SHIFT)); \
  78. __xx = virt_to_page(kvirt); \
  79. \
  80. __xx; \
  81. })
  82. #define page_to_pa(page) \
  83. (page_to_pfn(page) << PAGE_SHIFT)
  84. #define pfn_to_nid(pfn) pa_to_nid(((u64)(pfn) << PAGE_SHIFT))
  85. #define pfn_valid(pfn) \
  86. (((pfn) - node_start_pfn(pfn_to_nid(pfn))) < \
  87. node_spanned_pages(pfn_to_nid(pfn))) \
  88. #define virt_addr_valid(kaddr) pfn_valid((__pa(kaddr) >> PAGE_SHIFT))
  89. #endif /* CONFIG_DISCONTIGMEM */
  90. #endif /* _ASM_MMZONE_H_ */