io.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/module.h>
  3. #include <linux/types.h>
  4. #include <asm/io.h>
  5. /*
  6. * Copy data from IO memory space to "real" memory space.
  7. * This needs to be optimized.
  8. */
  9. void memcpy_fromio(void *to, const volatile void __iomem *from, long count)
  10. {
  11. char *dst = to;
  12. while (count) {
  13. count--;
  14. *dst++ = readb(from++);
  15. }
  16. }
  17. EXPORT_SYMBOL(memcpy_fromio);
  18. /*
  19. * Copy data from "real" memory space to IO memory space.
  20. * This needs to be optimized.
  21. */
  22. void memcpy_toio(volatile void __iomem *to, const void *from, long count)
  23. {
  24. const char *src = from;
  25. while (count) {
  26. count--;
  27. writeb(*src++, to++);
  28. }
  29. }
  30. EXPORT_SYMBOL(memcpy_toio);
  31. /*
  32. * "memset" on IO memory space.
  33. * This needs to be optimized.
  34. */
  35. void memset_io(volatile void __iomem *dst, int c, long count)
  36. {
  37. unsigned char ch = (char)(c & 0xff);
  38. while (count) {
  39. count--;
  40. writeb(ch, dst);
  41. dst++;
  42. }
  43. }
  44. EXPORT_SYMBOL(memset_io);
  45. #ifdef CONFIG_IA64_GENERIC
  46. #undef __ia64_inb
  47. #undef __ia64_inw
  48. #undef __ia64_inl
  49. #undef __ia64_outb
  50. #undef __ia64_outw
  51. #undef __ia64_outl
  52. #undef __ia64_readb
  53. #undef __ia64_readw
  54. #undef __ia64_readl
  55. #undef __ia64_readq
  56. #undef __ia64_readb_relaxed
  57. #undef __ia64_readw_relaxed
  58. #undef __ia64_readl_relaxed
  59. #undef __ia64_readq_relaxed
  60. #undef __ia64_writeb
  61. #undef __ia64_writew
  62. #undef __ia64_writel
  63. #undef __ia64_writeq
  64. #undef __ia64_mmiowb
  65. unsigned int
  66. __ia64_inb (unsigned long port)
  67. {
  68. return ___ia64_inb(port);
  69. }
  70. unsigned int
  71. __ia64_inw (unsigned long port)
  72. {
  73. return ___ia64_inw(port);
  74. }
  75. unsigned int
  76. __ia64_inl (unsigned long port)
  77. {
  78. return ___ia64_inl(port);
  79. }
  80. void
  81. __ia64_outb (unsigned char val, unsigned long port)
  82. {
  83. ___ia64_outb(val, port);
  84. }
  85. void
  86. __ia64_outw (unsigned short val, unsigned long port)
  87. {
  88. ___ia64_outw(val, port);
  89. }
  90. void
  91. __ia64_outl (unsigned int val, unsigned long port)
  92. {
  93. ___ia64_outl(val, port);
  94. }
  95. unsigned char
  96. __ia64_readb (void __iomem *addr)
  97. {
  98. return ___ia64_readb (addr);
  99. }
  100. unsigned short
  101. __ia64_readw (void __iomem *addr)
  102. {
  103. return ___ia64_readw (addr);
  104. }
  105. unsigned int
  106. __ia64_readl (void __iomem *addr)
  107. {
  108. return ___ia64_readl (addr);
  109. }
  110. unsigned long
  111. __ia64_readq (void __iomem *addr)
  112. {
  113. return ___ia64_readq (addr);
  114. }
  115. unsigned char
  116. __ia64_readb_relaxed (void __iomem *addr)
  117. {
  118. return ___ia64_readb (addr);
  119. }
  120. unsigned short
  121. __ia64_readw_relaxed (void __iomem *addr)
  122. {
  123. return ___ia64_readw (addr);
  124. }
  125. unsigned int
  126. __ia64_readl_relaxed (void __iomem *addr)
  127. {
  128. return ___ia64_readl (addr);
  129. }
  130. unsigned long
  131. __ia64_readq_relaxed (void __iomem *addr)
  132. {
  133. return ___ia64_readq (addr);
  134. }
  135. void
  136. __ia64_mmiowb(void)
  137. {
  138. ___ia64_mmiowb();
  139. }
  140. #endif /* CONFIG_IA64_GENERIC */