normalDataOperation.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * arch/arm/include/asm/io.h
  3. *
  4. * Copyright (C) 1996-2000 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Modifications:
  11. * 16-Sep-1996 RMK Inlined the inx/outx functions & optimised for both
  12. * constant addresses and variable addresses.
  13. * 04-Dec-1997 RMK Moved a lot of this stuff to the new architecture
  14. * specific IO header files.
  15. * 27-Mar-1999 PJB Second parameter of memcpy_toio is const..
  16. * 04-Apr-1999 PJB Added check_signature.
  17. * 12-Dec-1999 RMK More cleanups
  18. * 18-Jun-2000 RMK Removed virt_to_* and friends definitions
  19. * 05-Oct-2004 BJD Moved memory string functions to use void __iomem
  20. */
  21. #ifndef __ASM_ARM_IO_H
  22. #define __ASM_ARM_IO_H
  23. #ifdef __KERNEL__
  24. #include <linux/types.h>
  25. #include <asm/byteorder.h>
  26. #include <asm/memory.h>
  27. #include <asm-generic/pci_iomap.h>
  28. /*
  29. * ISA I/O bus memory addresses are 1:1 with the physical address.
  30. */
  31. #define isa_virt_to_bus virt_to_phys
  32. #define isa_page_to_bus page_to_phys
  33. #define isa_bus_to_virt phys_to_virt
  34. /*
  35. * Generic IO read/write. These perform native-endian accesses. Note
  36. * that some architectures will want to re-define __raw_{read,write}w.
  37. */
  38. extern void __raw_writesb(void __iomem *addr, const void *data, int bytelen);
  39. extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen);
  40. extern void __raw_writesl(void __iomem *addr, const void *data, int longlen);
  41. extern void __raw_readsb(const void __iomem *addr, void *data, int bytelen);
  42. extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen);
  43. extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
  44. #if __LINUX_ARM_ARCH__ < 6
  45. /*
  46. * Half-word accesses are problematic with RiscPC due to limitations of
  47. * the bus. Rather than special-case the machine, just let the compiler
  48. * generate the access for CPUs prior to ARMv6.
  49. */
  50. #define __raw_readw(a) (__chk_io_ptr(a), *(volatile unsigned short __force *)(a))
  51. #define __raw_writew(v,a) ((void)(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v)))
  52. #else
  53. /*
  54. * When running under a hypervisor, we want to avoid I/O accesses with
  55. * writeback addressing modes as these incur a significant performance
  56. * overhead (the address generation must be emulated in software).
  57. */
  58. static inline void __raw_writew(u16 val, volatile void __iomem *addr)
  59. {
  60. asm volatile("strh %1, %0"
  61. : "+Q" (*(volatile u16 __force *)addr)
  62. : "r" (val));
  63. }
  64. static inline u16 __raw_readw(const volatile void __iomem *addr)
  65. {
  66. u16 val;
  67. asm volatile("ldrh %1, %0"
  68. : "+Q" (*(volatile u16 __force *)addr),
  69. "=r" (val));
  70. return val;
  71. }
  72. #endif
  73. static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
  74. {
  75. asm volatile("strb %1, %0"
  76. : "+Qo" (*(volatile u8 __force *)addr)
  77. : "r" (val));
  78. }
  79. static inline void __raw_writel(u32 val, volatile void __iomem *addr)