io.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <asm/machvec.h>
  16. #include <asm/io.h>
  17. /*
  18. * Copy data from IO memory space to "real" memory space.
  19. * This needs to be optimized.
  20. */
  21. void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
  22. {
  23. unsigned char *p = to;
  24. while (count) {
  25. count--;
  26. *p = readb(from);
  27. p++;
  28. from++;
  29. }
  30. }
  31. EXPORT_SYMBOL(memcpy_fromio);
  32. /*
  33. * Copy data from "real" memory space to IO memory space.
  34. * This needs to be optimized.
  35. */
  36. void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
  37. {
  38. const unsigned char *p = from;
  39. while (count) {
  40. count--;
  41. writeb(*p, to);
  42. p++;
  43. to++;
  44. }
  45. }
  46. EXPORT_SYMBOL(memcpy_toio);
  47. /*
  48. * "memset" on IO memory space.
  49. * This needs to be optimized.
  50. */
  51. void memset_io(volatile void __iomem *dst, int c, unsigned long count)
  52. {
  53. while (count) {
  54. count--;
  55. writeb(c, dst);
  56. dst++;
  57. }
  58. }
  59. EXPORT_SYMBOL(memset_io);
  60. void __iomem *ioport_map(unsigned long port, unsigned int nr)
  61. {
  62. void __iomem *ret;
  63. ret = __ioport_map_trapped(port, nr);
  64. if (ret)
  65. return ret;
  66. return __ioport_map(port, nr);
  67. }
  68. EXPORT_SYMBOL(ioport_map);
  69. void ioport_unmap(void __iomem *addr)
  70. {
  71. sh_mv.mv_ioport_unmap(addr);
  72. }
  73. EXPORT_SYMBOL(ioport_unmap);