page.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef _ASM_ARM_XEN_PAGE_H
  2. #define _ASM_ARM_XEN_PAGE_H
  3. #include <asm/mach/map.h>
  4. #include <asm/page.h>
  5. #include <asm/pgtable.h>
  6. #include <linux/pfn.h>
  7. #include <linux/types.h>
  8. #include <xen/interface/grant_table.h>
  9. #define pfn_to_mfn(pfn) (pfn)
  10. #define phys_to_machine_mapping_valid(pfn) (1)
  11. #define mfn_to_pfn(mfn) (mfn)
  12. #define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
  13. #define pte_mfn pte_pfn
  14. #define mfn_pte pfn_pte
  15. /* Xen machine address */
  16. typedef struct xmaddr {
  17. phys_addr_t maddr;
  18. } xmaddr_t;
  19. /* Xen pseudo-physical address */
  20. typedef struct xpaddr {
  21. phys_addr_t paddr;
  22. } xpaddr_t;
  23. #define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
  24. #define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
  25. #define INVALID_P2M_ENTRY (~0UL)
  26. static inline xmaddr_t phys_to_machine(xpaddr_t phys)
  27. {
  28. unsigned offset = phys.paddr & ~PAGE_MASK;
  29. return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
  30. }
  31. static inline xpaddr_t machine_to_phys(xmaddr_t machine)
  32. {
  33. unsigned offset = machine.maddr & ~PAGE_MASK;
  34. return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
  35. }
  36. /* VIRT <-> MACHINE conversion */
  37. #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
  38. #define virt_to_pfn(v) (PFN_DOWN(__pa(v)))
  39. #define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
  40. #define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
  41. static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
  42. {
  43. /* TODO: assuming it is mapped in the kernel 1:1 */
  44. return virt_to_machine(vaddr);
  45. }
  46. /* TODO: this shouldn't be here but it is because the frontend drivers
  47. * are using it (its rolled in headers) even though we won't hit the code path.
  48. * So for right now just punt with this.
  49. */
  50. static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
  51. {
  52. BUG();
  53. return NULL;
  54. }
  55. static inline int m2p_add_override(unsigned long mfn, struct page *page,
  56. struct gnttab_map_grant_ref *kmap_op)
  57. {
  58. return 0;
  59. }
  60. static inline int m2p_remove_override(struct page *page, bool clear_pte)
  61. {
  62. return 0;
  63. }
  64. static inline bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
  65. {
  66. BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
  67. return true;
  68. }
  69. static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
  70. {
  71. return __set_phys_to_machine(pfn, mfn);
  72. }
  73. #define xen_remap(cookie, size) __arm_ioremap((cookie), (size), MT_MEMORY);
  74. #endif /* _ASM_ARM_XEN_PAGE_H */