io.c 2.5 KB

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