virtconvert.h 912 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __VIRT_CONVERT__
  3. #define __VIRT_CONVERT__
  4. /*
  5. * Macros used for converting between virtual and physical mappings.
  6. */
  7. #ifdef __KERNEL__
  8. #include <linux/compiler.h>
  9. #include <linux/mmzone.h>
  10. #include <asm/setup.h>
  11. #include <asm/page.h>
  12. /*
  13. * Change virtual addresses to physical addresses and vv.
  14. */
  15. #define virt_to_phys virt_to_phys
  16. static inline unsigned long virt_to_phys(void *address)
  17. {
  18. return __pa(address);
  19. }
  20. #define phys_to_virt phys_to_virt
  21. static inline void *phys_to_virt(unsigned long address)
  22. {
  23. return __va(address);
  24. }
  25. /* Permanent address of a page. */
  26. #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
  27. /*
  28. * IO bus memory addresses are 1:1 with the physical address,
  29. * deprecated globally but still used on two machines.
  30. */
  31. #if defined(CONFIG_AMIGA) || defined(CONFIG_VME)
  32. #define virt_to_bus virt_to_phys
  33. #endif
  34. #endif
  35. #endif