io.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * linux/arch/sh/kernel/io.c
  3. *
  4. * Copyright (C) 2000 Stuart Menefy
  5. * Copyright (C) 2005 Paul Mundt
  6. *
  7. * Provide real functions which expand to whatever the header file defined.
  8. * Also definitions of machine independent IO functions.
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file "COPYING" in the main directory of this archive
  12. * for more details.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/pci.h>
  16. #include <asm/machvec.h>
  17. #include <asm/io.h>
  18. /*
  19. * Copy data from IO memory space to "real" memory space.
  20. * This needs to be optimized.
  21. */
  22. void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
  23. {
  24. unsigned char *p = to;
  25. while (count) {
  26. count--;
  27. *p = readb(from);
  28. p++;
  29. from++;
  30. }
  31. }
  32. EXPORT_SYMBOL(memcpy_fromio);
  33. /*
  34. * Copy data from "real" memory space to IO memory space.
  35. * This needs to be optimized.
  36. */
  37. void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
  38. {
  39. const unsigned char *p = from;
  40. while (count) {
  41. count--;
  42. writeb(*p, to);
  43. p++;
  44. to++;
  45. }
  46. }
  47. EXPORT_SYMBOL(memcpy_toio);
  48. /*
  49. * "memset" on IO memory space.
  50. * This needs to be optimized.
  51. */
  52. void memset_io(volatile void __iomem *dst, int c, unsigned long count)
  53. {
  54. while (count) {
  55. count--;
  56. writeb(c, dst);
  57. dst++;
  58. }
  59. }
  60. EXPORT_SYMBOL(memset_io);
  61. void __iomem *ioport_map(unsigned long port, unsigned int nr)
  62. {
  63. void __iomem *ret;
  64. ret = __ioport_map_trapped(port, nr);
  65. if (ret)
  66. return ret;
  67. return __ioport_map(port, nr);
  68. }
  69. EXPORT_SYMBOL(ioport_map);
  70. void ioport_unmap(void __iomem *addr)
  71. {
  72. sh_mv.mv_ioport_unmap(addr);
  73. }
  74. EXPORT_SYMBOL(ioport_unmap);