page.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef _ASM_ARM_XEN_PAGE_H
  2. #define _ASM_ARM_XEN_PAGE_H
  3. #include <asm/page.h>
  4. #include <asm/pgtable.h>
  5. #include <linux/pfn.h>
  6. #include <linux/types.h>
  7. #include <linux/dma-mapping.h>
  8. #include <xen/xen.h>
  9. #include <xen/interface/grant_table.h>
  10. #define phys_to_machine_mapping_valid(pfn) (1)
  11. #define pte_mfn pte_pfn
  12. #define mfn_pte pfn_pte
  13. /* Xen machine address */
  14. typedef struct xmaddr {
  15. phys_addr_t maddr;
  16. } xmaddr_t;
  17. /* Xen pseudo-physical address */
  18. typedef struct xpaddr {
  19. phys_addr_t paddr;
  20. } xpaddr_t;
  21. #define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
  22. #define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
  23. #define INVALID_P2M_ENTRY (~0UL)
  24. unsigned long __pfn_to_mfn(unsigned long pfn);
  25. extern struct rb_root phys_to_mach;
  26. /* Pseudo-physical <-> Guest conversion */
  27. static inline unsigned long pfn_to_gfn(unsigned long pfn)
  28. {
  29. return pfn;
  30. }
  31. static inline unsigned long gfn_to_pfn(unsigned long gfn)
  32. {
  33. return gfn;
  34. }
  35. /* Pseudo-physical <-> BUS conversion */
  36. static inline unsigned long pfn_to_bfn(unsigned long pfn)
  37. {
  38. unsigned long mfn;
  39. if (phys_to_mach.rb_node != NULL) {
  40. mfn = __pfn_to_mfn(pfn);
  41. if (mfn != INVALID_P2M_ENTRY)
  42. return mfn;
  43. }
  44. return pfn;
  45. }
  46. static inline unsigned long bfn_to_pfn(unsigned long bfn)
  47. {
  48. return bfn;
  49. }
  50. #define bfn_to_local_pfn(bfn) bfn_to_pfn(bfn)
  51. /* VIRT <-> GUEST conversion */
  52. #define virt_to_gfn(v) (pfn_to_gfn(virt_to_pfn(v)))
  53. #define gfn_to_virt(m) (__va(gfn_to_pfn(m) << PAGE_SHIFT))
  54. /* Only used in PV code. But ARM guests are always HVM. */
  55. static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
  56. {
  57. BUG();
  58. }
  59. /* TODO: this shouldn't be here but it is because the frontend drivers
  60. * are using it (its rolled in headers) even though we won't hit the code path.
  61. * So for right now just punt with this.
  62. */
  63. static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
  64. {
  65. BUG();
  66. return NULL;
  67. }
  68. extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
  69. struct gnttab_map_grant_ref *kmap_ops,
  70. struct page **pages, unsigned int count);
  71. extern int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
  72. struct gnttab_unmap_grant_ref *kunmap_ops,
  73. struct page **pages, unsigned int count);
  74. bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
  75. bool __set_phys_to_machine_multi(unsigned long pfn, unsigned long mfn,
  76. unsigned long nr_pages);
  77. static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
  78. {
  79. return __set_phys_to_machine(pfn, mfn);
  80. }
  81. #define xen_remap(cookie, size) ioremap_cache((cookie), (size))
  82. #define xen_unmap(cookie) iounmap((cookie))
  83. bool xen_arch_need_swiotlb(struct device *dev,
  84. unsigned long pfn,
  85. unsigned long bfn);
  86. unsigned long xen_get_swiotlb_free_pages(unsigned int order);
  87. #endif /* _ASM_ARM_XEN_PAGE_H */