virtconvert.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __VIRT_CONVERT__
  2. #define __VIRT_CONVERT__
  3. /*
  4. * Macros used for converting between virtual and physical mappings.
  5. */
  6. #ifdef __KERNEL__
  7. #include <linux/config.h>
  8. #include <linux/compiler.h>
  9. #include <asm/setup.h>
  10. #include <asm/page.h>
  11. #ifdef CONFIG_AMIGA
  12. #include <asm/amigahw.h>
  13. #endif
  14. /*
  15. * Change virtual addresses to physical addresses and vv.
  16. */
  17. #ifndef CONFIG_SUN3
  18. extern unsigned long mm_vtop(unsigned long addr) __attribute_const__;
  19. extern unsigned long mm_ptov(unsigned long addr) __attribute_const__;
  20. #else
  21. static inline unsigned long mm_vtop(unsigned long vaddr)
  22. {
  23. return __pa(vaddr);
  24. }
  25. static inline unsigned long mm_ptov(unsigned long paddr)
  26. {
  27. return (unsigned long)__va(paddr);
  28. }
  29. #endif
  30. #ifdef CONFIG_SINGLE_MEMORY_CHUNK
  31. static inline unsigned long virt_to_phys(void *vaddr)
  32. {
  33. return (unsigned long)vaddr - PAGE_OFFSET + m68k_memory[0].addr;
  34. }
  35. static inline void * phys_to_virt(unsigned long paddr)
  36. {
  37. return (void *)(paddr - m68k_memory[0].addr + PAGE_OFFSET);
  38. }
  39. #else
  40. static inline unsigned long virt_to_phys(void *address)
  41. {
  42. return mm_vtop((unsigned long)address);
  43. }
  44. static inline void *phys_to_virt(unsigned long address)
  45. {
  46. return (void *) mm_ptov(address);
  47. }
  48. #endif
  49. /* Permanent address of a page. */
  50. #define __page_address(page) (PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT))
  51. #define page_to_phys(page) virt_to_phys((void *)__page_address(page))
  52. /*
  53. * IO bus memory addresses are 1:1 with the physical address,
  54. * except on the PCI bus of the Hades.
  55. */
  56. #ifdef CONFIG_HADES
  57. #define virt_to_bus(a) (virt_to_phys(a) + (MACH_IS_HADES ? 0x80000000 : 0))
  58. #define bus_to_virt(a) (phys_to_virt((a) - (MACH_IS_HADES ? 0x80000000 : 0)))
  59. #else
  60. #define virt_to_bus virt_to_phys
  61. #define bus_to_virt phys_to_virt
  62. #endif
  63. #endif
  64. #endif