mmzone.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_MMZONE_H
  15. #define _ASM_TILE_MMZONE_H
  16. extern struct pglist_data node_data[];
  17. #define NODE_DATA(nid) (&node_data[nid])
  18. extern void get_memcfg_numa(void);
  19. #ifdef CONFIG_DISCONTIGMEM
  20. #include <asm/page.h>
  21. /*
  22. * Generally, memory ranges are always doled out by the hypervisor in
  23. * fixed-size, power-of-two increments. That would make computing the node
  24. * very easy. We could just take a couple high bits of the PA, which
  25. * denote the memory shim, and we'd be done. However, when we're doing
  26. * memory striping, this may not be true; PAs with different high bit
  27. * values might be in the same node. Thus, we keep a lookup table to
  28. * translate the high bits of the PFN to the node number.
  29. */
  30. extern int highbits_to_node[];
  31. static inline int pfn_to_nid(unsigned long pfn)
  32. {
  33. return highbits_to_node[__pfn_to_highbits(pfn)];
  34. }
  35. /*
  36. * Following are macros that each numa implmentation must define.
  37. */
  38. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
  39. #define node_end_pfn(nid) \
  40. ({ \
  41. pg_data_t *__pgdat = NODE_DATA(nid); \
  42. __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
  43. })
  44. #define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)
  45. static inline int pfn_valid(int pfn)
  46. {
  47. int nid = pfn_to_nid(pfn);
  48. if (nid >= 0)
  49. return (pfn < node_end_pfn(nid));
  50. return 0;
  51. }
  52. /* Information on the NUMA nodes that we compute early */
  53. extern unsigned long node_start_pfn[];
  54. extern unsigned long node_end_pfn[];
  55. extern unsigned long node_memmap_pfn[];
  56. extern unsigned long node_percpu_pfn[];
  57. extern unsigned long node_free_pfn[];
  58. #ifdef CONFIG_HIGHMEM
  59. extern unsigned long node_lowmem_end_pfn[];
  60. #endif
  61. #ifdef CONFIG_PCI
  62. extern unsigned long pci_reserve_start_pfn;
  63. extern unsigned long pci_reserve_end_pfn;
  64. #endif
  65. #endif /* CONFIG_DISCONTIGMEM */
  66. #endif /* _ASM_TILE_MMZONE_H */