io.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * arch/xtensa/io.c
  3. *
  4. * IO primitives
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * Copied from sparc.
  12. *
  13. * Chris Zankel <chris@zankel.net>
  14. *
  15. */
  16. #include <asm/io.h>
  17. #include <asm/byteorder.h>
  18. void outsb(unsigned long addr, const void *src, unsigned long count) {
  19. while (count) {
  20. count -= 1;
  21. writeb(*(const char *)src, addr);
  22. src += 1;
  23. addr += 1;
  24. }
  25. }
  26. void outsw(unsigned long addr, const void *src, unsigned long count) {
  27. while (count) {
  28. count -= 2;
  29. writew(*(const short *)src, addr);
  30. src += 2;
  31. addr += 2;
  32. }
  33. }
  34. void outsl(unsigned long addr, const void *src, unsigned long count) {
  35. while (count) {
  36. count -= 4;
  37. writel(*(const long *)src, addr);
  38. src += 4;
  39. addr += 4;
  40. }
  41. }
  42. void insb(unsigned long addr, void *dst, unsigned long count) {
  43. while (count) {
  44. count -= 1;
  45. *(unsigned char *)dst = readb(addr);
  46. dst += 1;
  47. addr += 1;
  48. }
  49. }
  50. void insw(unsigned long addr, void *dst, unsigned long count) {
  51. while (count) {
  52. count -= 2;
  53. *(unsigned short *)dst = readw(addr);
  54. dst += 2;
  55. addr += 2;
  56. }
  57. }
  58. void insl(unsigned long addr, void *dst, unsigned long count) {
  59. while (count) {
  60. count -= 4;
  61. /*
  62. * XXX I am sure we are in for an unaligned trap here.
  63. */
  64. *(unsigned long *)dst = readl(addr);
  65. dst += 4;
  66. addr += 4;
  67. }
  68. }